Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 01:34
    Hawxy commented #107
  • May 04 13:52
    nghhoese commented #70
  • May 02 17:13
    jasper-ci removed as member
  • Apr 25 13:44
    marcindruzgala opened #107
  • Mar 23 08:52
    AdaskoTheBeAsT commented #106
  • Mar 22 18:02
    AdaskoTheBeAsT opened #106
  • Feb 26 02:14
    dependabot[bot] labeled #105
  • Feb 26 02:14
    dependabot[bot] labeled #105
  • Feb 26 02:14
    dependabot[bot] opened #105
  • Feb 26 02:14

    dependabot[bot] on npm_and_yarn

    Bump prismjs from 1.25.0 to 1.2… (compare)

  • Feb 09 15:01

    jeremydmiller on gh-pages

    Documentation Update for 6.1.0 (compare)

  • Feb 06 12:41

    Hawxy on gh-pages

    Documentation Update for 6.1.0 (compare)

  • Feb 06 12:00

    github-actions[bot] on v6.1.0

    (compare)

  • Feb 06 10:29

    Hawxy on master

    Move to package license express… (compare)

  • Feb 06 10:29
    Hawxy closed #104
  • Feb 06 10:28
    Hawxy opened #104
  • Feb 06 10:17

    dependabot[bot] on npm_and_yarn

    (compare)

  • Feb 06 10:17

    Hawxy on master

    Bump nanoid from 3.1.30 to 3.2.… (compare)

  • Feb 06 10:17
    Hawxy closed #102
  • Feb 06 10:17

    Hawxy on master

    v6.1.0 (#103) * Minor code + d… (compare)

Craig Quillen
@cquillen
       public async Task Test_Logging()

        {

            var builder = BusinessRulesEngine.Web.Program.CreateWebHostBuilder(new string[] { });



            using (var system = new SystemUnderTest(builder, typeof(Startup).Assembly))

            {

                await system.Scenario(_ =>

                {

                    _.Get.Url("/home/TestLogging");

                    _.ContentShouldBe("");

                    _.StatusCodeShouldBeOk();

                });



            }

        }
thoughts on why it doesn't like the hostname?
@jeremydmiller
Jeremy D. Miller
@jeremydmiller
I have no idea, I’ve never seen that before. Can you post the actual stacktrace? Something tripping up inside of AspNetCore itself I’d expect. Something in your code looking for the host name off of the HttpContext?
Craig Quillen
@cquillen
I actually just figured it out.
had mixed runtime refs between app and test projects.
added these to test.csproj
<TargetLatestRuntimePatch >true</TargetLatestRuntimePatch >
Jeremy D. Miller
@jeremydmiller
AspNetCore 2.*? I think that’s in the Alba documentation isn’t it?
Not an issue w/ AspNetCore 3.0 I believe
Craig Quillen
@cquillen
and <project sdk="microsoft.net.sdk.web"
yeah 2.2
i was also getting the multiple version warning during assembly binding
all better now
not sure about the docs. I'll look again.
now i'm getting authorization failures, but that I understand. I've not done anything to set an auth header for my test request.
pretty sure it's working
Jeremy D. Miller
@jeremydmiller
Cool, and feel free to yell back here about any holes in the docs
For 3.0, they changed things for Nuget references for AspNetCore yet again. Alba just targets netcoreapp3.0 and the references will float based on the runtime version now. Should soften up the exact problems you saw
Tomasz Jaskula
@tjaskula
Hey, I started to use Alba and it's really cool, however there is one thing I would like to ask for. BeforeEach actions passes in not fully initialized HttpContext. For example RequestedServices collection is uninitialized which would be useful in some cases. WDYT ?
Jeremy D. Miller
@jeremydmiller
That’s filled in by ASP.net Core itself as part of the request. That’s actually done by middleware in the execution pipeline
Tomasz Jaskula
@tjaskula
Ok, that means that there is no mean to resolve a service before the request ?
Jeremy D. Miller
@jeremydmiller
Not from the request’s own scope container. You can from the root application container
Tomasz Jaskula
@tjaskula
I have another issue as well, in some cases the HttpContext handed over to IScenarioAssertion has RequestServices == null. Is this something you've noticed ?
Jeremy D. Miller
@jeremydmiller
I can’t say that I have, no, but again, Alba itself depends on ASP.Net Core to deal with that. What are you needing to do? Why does it need to be the request scoped services?
Tomasz Jaskula
@tjaskula

I have this code to assert on GraphQL queries

public class SuccessResultAssertion : GraphQLAssertion
    {
        private readonly string _result;

        public SuccessResultAssertion(string result) => _result = result;

        public override void Assert(Scenario scenario, HttpContext context, ScenarioAssertionException ex)
        {
            var writer = (IDocumentWriter) context.RequestServices.GetService(typeof(IDocumentWriter));
            var expectedResult = writer.Write(CreateQueryResult(_result));

            var body = ex.ReadBody(context);
            if (!body.Equals(expectedResult))
            {
                ex.Add($"Expected '{expectedResult}' but got '{body}'");
            }
        }
    }

So I noticed that while executing tests only the first test has context.RequestServices filled, the scond tests throws an exception as RequestServices is null

GraphQLAssertion is abstract class implementing IScenarioAssertion
Jeremy D. Miller
@jeremydmiller
How is IDocumentWriter scoped? Can you not pull it out of the application services instead?
Tomasz Jaskula
@tjaskula
how can I access the application service container from here ?
Jeremy D. Miller
@jeremydmiller
Trying to figure that out myself;)
Sorry, gotta go finish getting kids ready for school. I’ll be back later today
Tomasz Jaskula
@tjaskula
ok, thanks :)
Jeremy D. Miller
@jeremydmiller
Wait, duh, it’s IHost.Services that you can get to off the SystemUnderTest
Tomasz Jaskula
@tjaskula
Ok so I'll have to pass it somehow to the assertion
Tomasz Jaskula
@tjaskula
After looking a bit, there is no mean I can access IHost.Services from inside the IScenarioAssertion. Scenario passed in to Assert method would need to expose the SystemUnderTests but it's not the case. It's kept internally
Jeremy D. Miller
@jeremydmiller
We could do a quick Alba 4.1 and add an overload of some kind to make it easier to do this kind of thing
And what Graph QL toolkit are you using out of curiosity? Is it the one from @joemcbride ?
Tomasz Jaskula
@tjaskula
That would be awesome if we could access somehow the app services container as we cannot rely on HttpContext. I'm using https://github.com/graphql-dotnet/graphql-dotnet
Jeremy D. Miller
@jeremydmiller
Cool, Joe is a former colleague of mine. He helped with Alba in the early days too
Tomasz Jaskula
@tjaskula
Oh, that's awesome. This world is so small
Do you think there is a chance for a release of Alba with this feature anytime soon then ?
Tomasz Jaskula
@tjaskula
@jeremydmiller I've opened the issue for reference JasperFx/alba#69
Jeremy D. Miller
@jeremydmiller
With me having 2 weeks off for Christmas, yes;)
Tomasz Jaskula
@tjaskula
I can do a PR if you prefer :)
Jeremy D. Miller
@jeremydmiller
I will very happily take that. If we expose IServiceProvider for the app off of the Scenario class it should make it easier to add declarative assertions. That’s my first thought
Tomasz Jaskula
@tjaskula
yep :)
that would be awesome
Tomasz Jaskula
@tjaskula

what I see as benefit as well is that on UT actions as here

[Test]
        public async Task SearchOneFondsQueries()
        {
            await Run(
                _ =>
                {
                    var input = new GraphQLRequest
                    {
                        Query = @"{ funds(searchQuery: ""Fond de Test Hedge en Duration"") { name } }"
                    };
                    _.Post.Json(input).ToUrl("/graphql");
                    _.StatusCodeShouldBe(HttpStatusCode.OK);
                    _.GraphQL()
                        .ShouldBeSuccess(@"{ ""funds"": [
                                            {
                                                ""name"": ""Fond de Test Hedge en Duration""
                                            }]}");
                });
        }

where Scenario is passed in into the Run function, I could add extensions method that would allow for me to retrieve a dependency, and configure expectations on it. Because for my test some fake dependencies are registered in within the test startup and initialized with SystemUnderTest.ForStartup<T>(builder =>... so that way I would have an easy way to retrieve them and set expectations based on test requirements

Jeremy D. Miller
@jeremydmiller
I’ll totally by that. What version of Alba are you using btw?
Tomasz Jaskula
@tjaskula
I'm using 3.0. because the last release is not compatible with standard 2.0