public TestData SetupTestData(bool expectNotification) { var mockClientFactory = new MockHttpClientFactory(); var factory = new TestAppFactory(); factory.ConfigureServices(services => { services.AddControllers() .AddApplicationPart(typeof(GitHubHookController).Assembly) .AddGitHubWebHooks(); services.Configure <TeamMentionForwardingOptions>(o => { o.IgnoreRepos = new [] { IgnoredRepo }; o.WatchedTeam = WatchedTeam; o.TeamsWebHookUri = TestTeamsWebHookUri; }); services.AddScoped <ITeamMentionForwarder, TeamMentionForwarder>(); services.AddSingleton <Microsoft.Extensions.Internal.ISystemClock, TestClock>(); services.AddLogging(); services.AddSingleton <IHttpClientFactory>(mockClientFactory); services.AddSingleton(Mock.Of <IGitHubApplicationClientFactory>()); services.AddSingleton(Mock.Of <ITimelineIssueTriage>()); services.RemoveAll <GitHubVerifySignatureFilter>(); services.AddSingleton <TestVerifySignatureFilter>(); services.Configure <MvcOptions>(o => { o.Filters.Remove(o.Filters.OfType <ServiceFilterAttribute>() .First(f => f.ServiceType == typeof(GitHubVerifySignatureFilter))); o.Filters.AddService <TestVerifySignatureFilter>(); }); }); factory.ConfigureBuilder(app => { app.Use(async(context, next) => { await next(); }); app.UseRouting(); app.UseEndpoints(e => e.MapControllers()); }); if (expectNotification) { mockClientFactory.AddCannedResponse(TestTeamsWebHookUri, null, HttpStatusCode.NoContent, null, HttpMethod.Post); } return(new TestData(factory.CreateClient(new WebApplicationFactoryClientOptions { BaseAddress = new Uri("https://example.test", UriKind.Absolute), AllowAutoRedirect = false, }), factory, mockClientFactory)); }
public TestData() { var factory = new TestAppFactory(); factory.ConfigureServices(services => { services.AddControllers() .AddApplicationPart(typeof(AnnotationsController).Assembly); services.Configure <GrafanaOptions>(options => { options.TableUri = "https://127.0.0.1:10002/devstoreaccount1/deployments"; }); services.AddLogging(); }); factory.ConfigureBuilder(app => { app.UseRouting(); app.UseEndpoints(e => e.MapControllers()); }); Client = factory.CreateClient(); }