private void StartServer(DateTime date) { TestAppFactory.FakeTimeProvider.SetDateTime(date); var server = TestAppFactory.MakeFakeApp(); _client = server.CreateClient(); }
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)); }
internal void ModuleIsolation( TestAppFactory appFactory, HttpClient client, string response ) { USING["a WebApplicationFactory"] = () => appFactory = new TestAppFactory(); USING["a client"] = () => client = appFactory.CreateClient(); When["issuing a request to first module"] = async() => response = await client.GetSuccessful("/mod1/test"); THEN["the response is built using the Container of first module"] = () => response.Should().Be("Root:Module 1"); When["issuing a request to second module"] = async() => response = await client.GetSuccessful("/mod2/test"); THEN["the response is built using the Container of second module"] = () => response.Should().Be("Root:Module 2"); }
public CorrelateMiddlewareTests(TestAppFactory <Startup> factory) { _options = new CorrelateOptions(); _mockHttp = new MockHttpHandler(); _rootFactory = factory; _rootFactory.LoggingEnabled = true; _factory = factory.WithWebHostBuilder(builder => builder .ConfigureTestServices(services => { services.AddTransient(_ => _mockHttp); services.AddSingleton <IOptions <CorrelateOptions> >(new OptionsWrapper <CorrelateOptions>(_options)); }) ); }
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(); }
public void AlignAll() { _appFactory = new TestAppFactory(); }
public PlanetsControllerTests(TestAppFactory <Startup> factory) { _factory = factory; }
public TestData(HttpClient client, TestAppFactory factory, MockHttpClientFactory mockClientFactory) { Client = client; Factory = factory; MockClientFactory = mockClientFactory; }
public VersionControllerTests(TestAppFactory <Startup> factory) { _factory = factory; }