public virtual void TestInitialize() { var services = new ServiceCollection(); this.Clock = new ClockStub(); services.AddSingleton <ISystemClock>(this.Clock); this.AuthenticationManager = new AuthenticationManagerStub(); services.AddSingleton <IAuthenticationManager>(this.AuthenticationManager); var httpContextAccessor = new HttpContextAccessorStub(); services.AddSingleton <IHttpContextAccessor>(httpContextAccessor); var options = new SpotifyOptions { ClientId = ClientId, ClientSecret = ClientSecret, }; var optionsSnapshotMock = new Mock <IOptionsSnapshot <SpotifyOptions> >(); optionsSnapshotMock.Setup(x => x.Value).Returns(options); services.AddSingleton(optionsSnapshotMock.Object); this.MockHttp = new MockHttpMessageHandler(); var builder = services.AddHttpClient("TestClient"); builder .ConfigurePrimaryHttpMessageHandler(() => this.MockHttp); builder .AddSpotifyAuthorizationCodeFlow() .ConfigureTokenHttpClientBuilder(b => b.ConfigurePrimaryHttpMessageHandler(() => this.MockHttp)); this.serviceProvider = services.BuildServiceProvider(); httpContextAccessor.ServiceProvider = this.serviceProvider; this.TestClient = this.serviceProvider.GetRequiredService <IHttpClientFactory>().CreateClient("TestClient"); }
public UserManagmentTests(TestsFixture fixture) { this.fixture = fixture; contextAccessor = new HttpContextAccessorStub(); logicValidation = new UserManagmentLogicValidation(fixture.dbAuth, new StatusMessageFactory(), contextAccessor, new PasswordHashStub()); }
public LogProviderTests(TestsFixture fixture) { this.fixture = fixture; httpContextAccessor = new HttpContextAccessorStub(); logProvider = new LogProvider(fixture.dbAuth, httpContextAccessor); }