Inheritance: BaseEndpoint
Exemplo n.º 1
0
		public async Task TestGetAccountAlbums()
		{
			var imgurClient = await AuthenticationHelpers.CreateOAuth2AuthenticatedImgurClient();
			var accountEndpoint = new AccountEndpoint(imgurClient);
			var accountAlbums = await accountEndpoint.GetAccountAlbumsAsync(0);

			// Assert the Response
			Assert.IsNotNull(accountAlbums.Data);
			Assert.AreEqual(accountAlbums.Success, true);
			Assert.AreEqual(accountAlbums.Status, HttpStatusCode.OK);
		}
Exemplo n.º 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));
		}
Exemplo n.º 3
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);
		}
Exemplo n.º 4
0
		public async Task TestDeleteAccountImage()
		{
			var imgurClient = await AuthenticationHelpers.CreateOAuth2AuthenticatedImgurClient();
			var accountEndpoint = new AccountEndpoint(imgurClient);
			var imageEndpoint = new ImageEndpoint(imgurClient);

			// Upload Image
			var filePath = VariousFunctions.GetTestsAssetDirectory() + @"\upload-image-example.jpg";
			var imageBinary = File.ReadAllBytes(filePath);
			var image = await imageEndpoint.UploadImageFromBinaryAsync(imageBinary);

			// Delete Image
			var deletedImage = await accountEndpoint.DeleteAccountImageAsync(image.Data.DeleteHash);

			// Assert the Response
			Assert.IsNotNull(deletedImage.Data);
			Assert.AreEqual(deletedImage.Success, true);
			Assert.AreEqual(deletedImage.Status, HttpStatusCode.OK);
			Assert.AreEqual(deletedImage.Data, true);
		}
Exemplo n.º 5
0
		public async Task TestGetAccountImageDetails()
		{
			var imgurClient = await AuthenticationHelpers.CreateOAuth2AuthenticatedImgurClient();
			var accountEndpoint = new AccountEndpoint(imgurClient);
			var accountImageCount = await accountEndpoint.GetAccountImageIdsAsync();
			if (accountImageCount.Data.Length == 0) return;
			var accountImageDetails = await accountEndpoint.GetAccountImageDetailsAsync(accountImageCount.Data[0]);

			// Assert the Response
			Assert.IsNotNull(accountImageDetails.Data);
			Assert.AreEqual(accountImageDetails.Success, true);
			Assert.AreEqual(accountImageDetails.Status, HttpStatusCode.OK);
		}
Exemplo n.º 6
0
		public async Task TestDeleteAccountAlbum()
		{
			var imgurClient = await AuthenticationHelpers.CreateOAuth2AuthenticatedImgurClient();
			var albumEndpoint = new AlbumEndpoint(imgurClient);
			var accountEndpoint = new AccountEndpoint(imgurClient);
			var accountAlbum = await albumEndpoint.CreateAlbumAsync(title: "swag");
			var response = await accountEndpoint.DeleteAccountAlbumAsync(accountAlbum.Data.DeleteHash);

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