示例#1
0
        public async Task TestGetBadAccount()
        {
            var imgurClient     = AuthenticationHelpers.CreateClientAuthenticatedImgurClient();
            var accountEndpoint = new AccountEndpoint(imgurClient);
            ImgurResponse <Account> imgurResponse = null;

            try
            {
                imgurResponse = await accountEndpoint.GetAccountDetailsAsync("black-dicks (this account doesn't exist, perfect for le test)");
            }
            catch (ImgurResponseFailedException exception)
            {
                // Assert the Response
                Assert.IsNotNull(exception.ImgurResponse.Data);
                Assert.AreEqual(exception.ImgurResponse.Success, false);
                Assert.AreEqual(exception.ImgurResponse.Status, HttpStatusCode.BadRequest);

                // Assert the Data
                Assert.AreEqual(exception.ImgurResponse.Data.ErrorDescription, "A username is required.");
                Assert.AreEqual(exception.ImgurResponse.Data.Method, "GET");
                Assert.AreEqual(exception.ImgurResponse.Data.Request, "/3/account/black-dicks (this account doesn't exist, perfect for le test)");
            }

            Assert.IsNull(imgurResponse);
        }
示例#2
0
        public async Task TestGetAccount()
        {
            var imgurClient     = AuthenticationHelpers.CreateClientAuthenticatedImgurClient();
            var accountEndpoint = new AccountEndpoint(imgurClient);
            var response        = await accountEndpoint.GetAccountDetailsAsync("xerax");

            // Assert the Response
            Assert.IsNotNull(response.Data);
            Assert.AreEqual(response.Success, true);
            Assert.AreEqual(response.Status, HttpStatusCode.OK);

            // Assert the Data
            Assert.AreEqual(response.Data.Id, 2662650);
            Assert.AreEqual(response.Data.Created, new DateTime(2012, 12, 16, 04, 12, 1));
        }