Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Mar 17 11:08
    LodewijkSioen commented #73
  • Mar 17 11:08
    LodewijkSioen closed #73
  • Mar 17 08:58
    LodewijkSioen opened #73
  • Feb 29 09:09
    dependabot[bot] labeled #72
  • Feb 29 09:09
    dependabot[bot] opened #72
  • Feb 29 09:09

    dependabot[bot] on bundler

    Bump rake from 11.3.0 to 12.3.3… (compare)

  • Feb 25 14:52
    jeremydmiller closed #71
  • Feb 25 14:52

    jeremydmiller on master

    corrected access to IServicePro… (compare)

  • Feb 25 14:50
    jeremydmiller labeled #71
  • Feb 25 14:50
    jeremydmiller opened #71
  • Feb 19 11:32
    mronnblom-cint commented #32
  • Jan 08 15:30
    tjaskula closed #69
  • Jan 08 15:30
    tjaskula commented #69
  • Jan 06 17:01
    tjaskula commented #69
  • Jan 06 16:16
    jeremydmiller commented #69
  • Jan 06 16:01
    tjaskula commented #69
  • Dec 20 2019 15:35
    jakobgn opened #70
  • Dec 16 2019 13:51
    tjaskula opened #69
  • Dec 02 2019 18:41
    Nitin5acc closed #68
  • Dec 02 2019 18:41
    Nitin5acc commented #68
Craig Quillen
@cquillen
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
Jeremy D. Miller
@jeremydmiller
You can still use it with ASP.Net Core 2.*
the latest I mean. Took a lot of conditional compilation to make it happen of course. Multi-targeting asp.net core versions is rough right now with the churn
Tomasz Jaskula
@tjaskula
yes, our test project targets right now net472
Jeremy D. Miller
@jeremydmiller
Ah, shoot, okay. I think we gave up on ASP.Net Core < 2 in the latest
Tomasz Jaskula
@tjaskula
that's why, we have a lot of "legacy" dependencies, we cannot migrate it easily
Jeremy D. Miller
@jeremydmiller
I completely get it
Tomasz Jaskula
@tjaskula
ahhh
I understand maintaining old platforms is not easy for you
Jeremy D. Miller
@jeremydmiller
It is when the platform changes a lot in a few years
Ralph Hendriks
@ralphhendriks

@jeremydmiller I just started playing around with Alba for some HTTP API integration tests. So far, I like it a lot. One thing that bugs me though is that the built-in assertion on the content type behaves not as I would expect. I have configured my scenario _.ContentTypeShouldBe("application/problem+json"), which then fails with:

Alba.ScenarioAssertionException : Expected a single header value of 'content-type'='application/problem+json', but the actual value was 'application/problem+json; charset=utf-8'

Of course I can include the charset on the expected value. However, it feels a bit clunky to do so. I could make a contribution to improve this if you like, but I am not sure if this fits in your ideas how the library should develop.

Jeremy D. Miller
@jeremydmiller
A PR for this would be very welcome. I think you’d end up making hte content type check be a custom assertion so it can be smart enough to parse mime types