コード例 #1
0
        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");
        }
コード例 #2
0
 public UserManagmentTests(TestsFixture fixture)
 {
     this.fixture    = fixture;
     contextAccessor = new HttpContextAccessorStub();
     logicValidation = new UserManagmentLogicValidation(fixture.dbAuth, new StatusMessageFactory(), contextAccessor, new PasswordHashStub());
 }
コード例 #3
0
 public LogProviderTests(TestsFixture fixture)
 {
     this.fixture        = fixture;
     httpContextAccessor = new HttpContextAccessorStub();
     logProvider         = new LogProvider(fixture.dbAuth, httpContextAccessor);
 }