コード例 #1
0
 /// <summary>
 /// The SpotifyClient has a dependency on the userId of the user that sent a message.
 /// So, we create the client at runtime with a factory.
 /// </summary>
 public SpotifyClientFactory(
     IAuthorizationTokenRepository authorizationTokenRepository,
     IMapper mapper,
     IOptions <SpotifyOptions> spotifyOptions)
 {
     _authorizationTokenRepository = authorizationTokenRepository;
     _mapper         = mapper;
     _spotifyOptions = spotifyOptions.Value;
 }
コード例 #2
0
        public SpotifyController(SpotifyOptions spotify)
        {
            Spotify = spotify;

            HttpClient = new HttpClient
            {
                BaseAddress = new Uri(Spotify.BaseUrl),
                Timeout     = TimeSpan.FromSeconds(Spotify.TimeoutSeconds)
            };
        }
コード例 #3
0
 public AuthorizationService(
     IAuthorizationTokenRepository authorizationTokenRepository,
     ILoginRequestService loginRequestService,
     IMapper mapper,
     IOptions <SpotifyOptions> spotifyOptions,
     IOptions <AzureOptions> azureOptions)
 {
     _authorizationTokenRepository = authorizationTokenRepository;
     _loginRequestService          = loginRequestService;
     _mapper         = mapper;
     _spotifyOptions = spotifyOptions.Value;
     _azureOptions   = azureOptions.Value;
 }
コード例 #4
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");
        }
コード例 #5
0
 public SpotifyService(IOptions <SpotifyOptions> options, IHttpClientFactory httpClientFactory)
 {
     _httpClientFactory = httpClientFactory;
     _options           = options.Value;
 }
コード例 #6
0
 public ExternalAccountRepository(BotContext botContext, AesCryptography aes, IOptions <SpotifyOptions> options)
 {
     _botContext = botContext;
     _aes        = aes;
     _options    = options.Value;
 }
コード例 #7
0
 public LinkSpotifyModel(IOptions <SpotifyOptions> options, IExternalAccountRepository externalAccountRepository)
 {
     _externalAccountRepository = externalAccountRepository;
     _options = options.Value;
 }