public async Task VerifyEmailAsync_IsTrue()
        {
            var client   = new MashapeClient(ClientId, ClientSecret, MashapeKey, OAuth2Token);
            var endpoint = new AccountEndpoint(client);

            var verified = await endpoint.VerifyEmailAsync();

            Assert.IsTrue(verified);
        }
        public async Task VerifyEmailAsync_IsTrue()
        {
            var client   = new ImgurClient(ClientId, ClientSecret, await GetOAuth2Token());
            var endpoint = new AccountEndpoint(client);

            var verified = await endpoint.VerifyEmailAsync();

            Assert.IsTrue(verified);
        }
Пример #3
0
        public async Task VerifyEmailAsync_True()
        {
            var mockUrl      = "https://api.imgur.com/3/account/me/verifyemail";
            var mockResponse = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(MockAccountEndpointResponses.VerifyEmail)
            };

            var client   = new ImgurClient("123", "1234", MockOAuth2Token);
            var endpoint = new AccountEndpoint(client, new HttpClient(new MockHttpMessageHandler(mockUrl, mockResponse)));
            var updated  = await endpoint.VerifyEmailAsync().ConfigureAwait(false);

            Assert.True(updated);
        }
Пример #4
0
        public async Task VerifyEmailAsync_OAuth2Null_ThrowsArgumentNullException()
        {
            var client   = new ImgurClient("123", "1234");
            var endpoint = new AccountEndpoint(client);

            var exception =
                await
                Record.ExceptionAsync(
                    async() => await endpoint.VerifyEmailAsync().ConfigureAwait(false))
                .ConfigureAwait(false);

            Assert.NotNull(exception);
            Assert.IsType <ArgumentNullException>(exception);
        }
Пример #5
0
        public async Task VerifyEmailAsync_ThrowsImgurException()
        {
            var fakeHttpMessageHandler = new FakeHttpMessageHandler();
            var fakeResponse           = new HttpResponseMessage(HttpStatusCode.BadRequest)
            {
                Content = new StringContent(AccountEndpointResponses.VerifyEmailErrorResponse)
            };

            fakeHttpMessageHandler.AddFakeResponse(new Uri("https://api.imgur.com/3/account/me/verifyemail"),
                                                   fakeResponse);

            var fakeOAuth2Handler = new FakeOAuth2TokenHandler();
            var client            = new ImgurClient("123", "1234", fakeOAuth2Handler.GetOAuth2TokenCodeResponse());
            var endpoint          = new AccountEndpoint(client, new HttpClient(fakeHttpMessageHandler));
            var updated           = await endpoint.VerifyEmailAsync();

            Assert.IsTrue(updated);
        }
Пример #6
0
        public async Task VerifyEmailAsync_ThrowsImgurException()
        {
            var mockUrl      = "https://api.imgur.com/3/account/me/verifyemail";
            var mockResponse = new HttpResponseMessage(HttpStatusCode.BadRequest)
            {
                Content = new StringContent(MockAccountEndpointResponses.VerifyEmailError)
            };

            var client   = new ImgurClient("123", "1234", MockOAuth2Token);
            var endpoint = new AccountEndpoint(client, new HttpClient(new MockHttpMessageHandler(mockUrl, mockResponse)));

            var exception =
                await
                Record.ExceptionAsync(
                    async() => await endpoint.VerifyEmailAsync().ConfigureAwait(false))
                .ConfigureAwait(false);

            Assert.NotNull(exception);
            Assert.IsType <ImgurException>(exception);
        }
Пример #7
0
 public async Task VerifyEmailAsync_OAuth2Null_ThrowsArgumentNullException()
 {
     var client   = new ImgurClient("123", "1234");
     var endpoint = new AccountEndpoint(client);
     await endpoint.VerifyEmailAsync();
 }