by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jun 03 05:20
    dionfoster edited #77
  • Jun 02 08:38
    JosephWoodward closed #65
  • Jun 02 02:21
    dionfoster edited #77
  • Jun 02 02:21
    dionfoster opened #77
  • May 12 16:28
    jeremydmiller commented #74
  • May 12 16:27
    jeremydmiller closed #76
  • May 12 16:27
    jeremydmiller commented #76
  • May 12 16:27
    jeremydmiller closed #75
  • May 12 16:27

    jeremydmiller on master

    Failing test for #75 Fix for log BeforeEachAsync(). … (compare)

  • May 12 15:45

    dependabot[bot] on bundler

    (compare)

  • May 12 15:45

    jeremydmiller on master

    Bump rake from 11.3.0 to 12.3.3… (compare)

  • May 12 15:45
    jeremydmiller closed #72
  • May 04 13:42
    LodewijkSioen commented #75
  • May 04 09:42
    LodewijkSioen edited #76
  • May 04 09:40
    LodewijkSioen commented #75
  • May 04 09:33
    LodewijkSioen opened #76
  • Apr 29 14:46
    LodewijkSioen opened #75
  • Apr 15 17:29
    kmughal opened #74
  • Mar 17 11:08
    LodewijkSioen commented #73
  • Mar 17 11:08
    LodewijkSioen closed #73
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
dionfoster
@dionfoster
:wave:
hi guys, i'm looking to use alba for integration testing of a dotnet core 3.1 api endpoint
it is using multipart/formdata with an IFormFile
i don't mind putting together a PR for this but need some help
first off, is there a way to view the raw request alba is sending?
Jeremy D. Miller
@jeremydmiller
Right now the answer is “debugger”. I’d happily take a PR if you want an optional sink to display the incoming request.
dionfoster
@dionfoster
:thumbsup:
dionfoster
@dionfoster
hey guys i've posted a PR for review to add support for multipart form data and IFormFile, hopefully a starting point for conversation on a few aspects
dionfoster
@dionfoster
feedback appreciated
Jeremy D. Miller
@jeremydmiller
@dionfoster I’ll get something to you tomorrow. It was on my TODO list in the morning, but I didn’t get to it
dionfoster
@dionfoster
no problems! thanks!
dionfoster
@dionfoster
depending on what is desirable from an api perspective, might need some implementation changes with regards to the formcollection as the only way i could get this going was to replace the entire formcollection on the HttpRequest