Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Sep 29 20:54

    jeremydmiller on master

    fixing up the IHostBuilder supp… (compare)

  • Sep 29 20:14

    jeremydmiller on gh-pages

    Documentation Update for 3.1.0 (compare)

  • Sep 29 20:13

    jeremydmiller on master

    docs for netcoreapp3.0 (compare)

  • Sep 29 19:25

    jeremydmiller on master

    Angle brackets correction in We… (compare)

  • Sep 29 19:25
    jeremydmiller closed #66
  • Sep 29 19:25

    jeremydmiller on master

    - Code compiles and tests pass … Upgraded to RTM deps for netcor… Fixed some warnings with netcor… and 8 more (compare)

  • Sep 29 19:25
    jeremydmiller closed #67
  • Sep 26 14:57
    rytmis synchronize #67
  • Sep 26 14:37
    rytmis synchronize #67
  • Sep 26 13:10
    rytmis synchronize #67
  • Sep 26 12:14
    rytmis synchronize #67
  • Sep 26 10:49
    rytmis synchronize #67
  • Sep 26 08:30
    rytmis synchronize #67
  • Sep 25 17:34
    rytmis synchronize #67
  • Aug 22 10:55
    rytmis opened #67
  • Feb 19 13:13
    anth12 opened #66
  • Jan 15 11:08
    JosephWoodward edited #65
  • Jan 15 11:05
    JosephWoodward opened #65
  • Jan 09 16:24

    jeremydmiller on gh-pages

    Documentation Update for 3.0.0 (compare)

  • Jan 09 16:22

    jeremydmiller on gh-pages

    Documentation Update for 3.0.0 (compare)

Jeremy D. Miller
@jeremydmiller
I did the 2.0 changes fast to get it ready to use on a client project and didn’t necessarily think things all the way through, so there might be other things to add. It’s using the ASP.Net Core TestHost this time
Jeremy D. Miller
@jeremydmiller
Hey everyone, there’s actually a much improved v3 out on Nuget: https://jeremydmiller.com/2019/01/09/alba-3-0-testhost-on-steroids-and-http-contract-testing-for-net/
Joe McBride
@joemcbride
👍
Jeremy D. Miller
@jeremydmiller
Oh hey Joe, there’s a videocast coming soon on Alba I recorded a couple days ago w/ a shoutout to you on it
Joe McBride
@joemcbride
Cool, I’ll look for it.
Erik Simon
@darman96
Is there anything I have to consider when using alba with a startup class which uses lamar as DI container? I always get a InvalidOperationException which says that IServiceProviderFactory<ServiceRegistry> is not Registered.
Jeremy D. Miller
@jeremydmiller
Does your app start up normally? As in, this is just an Alba issue? And what version of Alba, because the bootstrapping changed quite a bit in 3.0
Erik Simon
@darman96
The Web App runs normally only when i try to run my Tests it fails
It's version 3
My guess was that it fails to get the ServiceRegistry for the ConfigureContainer Method in the Startup
Jeremy D. Miller
@jeremydmiller
Any chance you could post your bootstrapping code? And you can use a one on one window if you don’t want that public here
Erik Simon
@darman96
Sure
Seyedamirhossein Hesamian
@amir734jj
I just started using Alba and I am wondering is there a way to inject AllowAnonymous attribute while doing integration testing?
Jeremy D. Miller
@jeremydmiller
How would you inject an attribute? Are you just wanting to disable security during test runs?
Seyedamirhossein Hesamian
@amir734jj
yes
Jeremy D. Miller
@jeremydmiller
Not through Alba directly, but you could do that thru AspNetCore itself by not applying any kind of authorization or authentication middleware in “Testing” mode, then make sure you bootstrap the app in “Testing” mode
Seyedamirhossein Hesamian
@amir734jj
You mean UseEnvironment("Testing?")
Jeremy D. Miller
@jeremydmiller
Yes
Seyedamirhossein Hesamian
@amir734jj
Excellent, Thank you
larsest1
@larsest1

Hi
I am trying to override service registrations

I have used to code from the documentation "Hosting and Other Configuration" (http://jasperfx.github.io/alba/documentation/bootstrapping/)

But it still runs ConfigureServices in startup.cs when I hit
var system = new SystemUnderTest(builder, applicationAssembly:typeof(Startup).Assembly);

How can I avid that this happens?

See my test below

TokenSettings = new GitTokenSettings();
TokenSettings.UserName = "Test username";
TokenSettings.Token = "h8976879sgsd98sgag78";

Options = new Mock<IOptions<GitTokenSettings>>();
Options.Setup(git => git.Value).Returns(TokenSettings);

MockpullRequestStatusService = new Mock<IPullRequestStatusService>();
MockpullRequestStatusService.Setup((x => x.SetPullRequestStatus(String.Empty, string.Empty, string.Empty, string.Empty))).Returns((Task.FromResult(200)));

MockPullReqClient = new Mock<IPullRequestStatusClient>();
MockPullReqClient.Setup(x => x.GetOpenPullRequests("bla", "blabla")).Returns(It.IsAny<string>());

var builder = WebHost.CreateDefaultBuilder()
.UseStartup<Startup>()
.UseContentRoot(@"C:\Repos\tools-branch-status-check-service\BranchStatusCheckService")
.ConfigureServices(s => {
s.AddTransient(x => MockpullRequestStatusService.Object);
s.AddTransient(x => Options.Object);
s.AddTransient(x => MockPullReqClient.Object);
});

TheSystem = new SystemUnderTest(builder, applicationAssembly: typeof(Startup).Assembly);

Jeremy D. Miller
@jeremydmiller
The ConfigureServices() call will happen regardless of the usage of Startup. I honestly don’t remember the order, but I’m guessing from this question that the ConfigureServices() is called after and the overrides don’t get to apply?
larsest1
@larsest1
Yep
Jeremy D. Miller
@jeremydmiller
Ugh, okay. And I’m guessing that you want everything that the Startup does, but also to override services just in testing as well?
larsest1
@larsest1
That would be nice :)
Jeremy D. Miller
@jeremydmiller
Used to be really easy in my old FubuMVC + StructureMap combo years ago.
It is possible w/ AspNetCore hosting, but they don’t make it easy or obvious at all. You might need to let me think about this for awhile and see if there’s an easier way to expose this in a reusable API in Alba
larsest1
@larsest1
I am not that experienced with aps.net core. A colleague of mine just recommended Alba to me :)
Ok, thanks :)
Jeremy D. Miller
@jeremydmiller
Easiest thing to do is to do some conditional registration based on the HostingEnvironment, but that means either making a hard coupling from production code to testing fakes or doing something that tries to dynamically load registrations
Hmm.
larsest1
@larsest1
Found the solution!
You have to use TryAddTransient in configureServices()
Then it won't register anything, if it has already been registered.
Jeremy D. Miller
@jeremydmiller
Sure, but that doesn’t help you out with the ordering per se
Unless you mean to do that in the STartup
larsest1
@larsest1
But it does not overwrtie my mocks
Yes, doing it in startup
Jeremy D. Miller
@jeremydmiller
Then this sounds like a documentation effort now
Lauri Kotilainen
@rytmis
@jeremydmiller Hi! Do you know if anyone has taken a look at adapting Alba for ASP.NET Core 3.0? There seems to be at least one rather major obstacle, which is that TestServer will now forcibly replace the Response Body stream with an implementation that doesn't allow for seeking -- this happens regardless of whether one uses an earlier phase of the pipeline to stick in e.g. a MemoryStream.
Jeremy D. Miller
@jeremydmiller
Not that I know of yet if you’re volunteering;) It’s hopefully less churn than it was going from 1 to 2 this time.
Lauri Kotilainen
@rytmis
Haha. Ahahaha.
See, the thing is, now that they're moving to a monorepo model, the NuGet packages that had the word "Internal" in them are in fact going to become internal.
Most of that seems to have only minor effects. But the TestServer changes might actually hurt. I'm trying to bother David Fowler about this over at the aspnetcore slack.
Lauri Kotilainen
@rytmis
On that note, what are your thoughts about versioning this time around? Should I assume that netcoreapp3.0 means ASP.NET Core 3.0? It's either that or yet another separate package, I guess.
Jeremy D. Miller
@jeremydmiller
I’d like to try to multi-target this time. Even knowing that means some conditional compilation.
Lauri Kotilainen
@rytmis
I thought as much.
Jeremy D. Miller
@jeremydmiller
How close is 3.0 to hitting?
Lauri Kotilainen
@rytmis
It's RC with a Go-live license with a commitment to avoid API breakage from now on.
Jeremy D. Miller
@jeremydmiller
Gotcha. I’d been ignoring it for about this reason
Lauri Kotilainen
@rytmis

The new TestServer usage pattern is to use a sort of builder to construct it and then it provides you with a HttpClient that will dispatch the request, so you get the ResponseMessage with its assorted things. Most of the APIs Alba uses are still available -- I've got some initial work with conditional compilation locally. It's the response body that's giving me headache right now.

I should probably look more closely into the TestServer APIs at some point to see if there are other ways of going about this.