Exemplo n.º 1
0
        protected async Task <string> GetAuthTokenAsync()
        {
            var configurationValues = new TheTvDbConfigurationValuesV4(new TestConfigurationValues());
            var localPaths          = new TestLocalPaths();
            var apiDownloader       = CreateDownloader();
            var authenticator       =
                new TheTvDbAuthenticatorV4(new RealTimeDateProvider(), configurationValues, localPaths, apiDownloader);

            return(await authenticator.GetAuthTokenAsync(null));
        }
Exemplo n.º 2
0
        public async Task AuthenticatorShouldRetrieveAndReturnToken()
        {
            // Arrange
            var configurationValues = new TheTvDbConfigurationValuesV4(new TestConfigurationValues());
            var localPaths          = new TestLocalPaths();
            var apiDownloader       = new TheTvDbApiDownloaderV4(configurationValues, new HttpDownloader());
            var sut = new TheTvDbAuthenticatorV4(new RealTimeDateProvider(), configurationValues, localPaths, apiDownloader);

            // Act
            var actual = await sut.GetAuthTokenAsync(null);

            // Assert
            Assert.That(actual, Is.Not.Null);
            Assert.That(actual, Is.Not.Empty);

            Console.WriteLine(actual);
        }
Exemplo n.º 3
0
        public async Task LoginShouldReturnToken()
        {
            // Arrange
            var configurationValues = new TheTvDbConfigurationValuesV4(new TestConfigurationValues());
            var sut = new TheTvDbApiDownloaderV4(configurationValues, new HttpDownloader());

            // Act
            var actual = await sut.GetAuthTokenAsync(null);

            // Assert
            Assert.That(actual, Is.Not.Null);
            Assert.That(actual, Is.Not.Empty);

            TheTvDbApiResponse <TheTvDbAuthToken> response =
                JsonConvert.DeserializeObject <TheTvDbApiResponse <TheTvDbAuthToken> >(actual);

            Assert.That(response, Is.Not.Null);
            Assert.That(response.Status, Is.EqualTo("success"));
            Assert.That(response.Data, Is.Not.Null);
            Assert.That(response.Data.Token, Is.Not.Null);
            Assert.That(response.Data.Token, Is.Not.Empty);

            Console.WriteLine(response.Data.Token);
        }
Exemplo n.º 4
0
        protected ITheTvDbApiDownloaderV4 CreateDownloader()
        {
            var configurationValues = new TheTvDbConfigurationValuesV4(new TestConfigurationValues());

            return(new TheTvDbApiDownloaderV4(configurationValues, new HttpDownloader()));
        }