public UploadImageFromBinaryAsync ( byte imageBinary, string albumId = null, string name = null, string title = null, string description = null ) : Task |
||
imageBinary | byte | |
albumId | string | |
name | string | |
title | string | |
description | string | |
return | Task |
public async Task TestCreateAlbum() { var imgurClient = await AuthenticationHelpers.CreateOAuth2AuthenticatedImgurClient(); var albumEndpoint = new AlbumEndpoint(imgurClient); var imageEndpoint = new ImageEndpoint(imgurClient); var filePath = VariousFunctions.GetTestsAssetDirectory() + @"\upload-image-example.jpg"; var imageBinary = File.ReadAllBytes(filePath); var title = String.Format("dicks-{0}", new Random().Next(100, 1337)); var description = String.Format("black dicks, yo-{0}", new Random().Next(100, 1337)); var uploadedImages = new List<Image>(); for (var i = 0; i < 2; i++) uploadedImages.Add((await imageEndpoint.UploadImageFromBinaryAsync(imageBinary)).Data); var createdAlbum = await albumEndpoint.CreateAlbumAsync(uploadedImages.ToArray(), uploadedImages[0], title, description); // Assert the Reponse Assert.IsNotNull(createdAlbum.Data); Assert.AreEqual(createdAlbum.Success, true); Assert.AreEqual(createdAlbum.Status, HttpStatusCode.OK); // Assert the data Assert.AreEqual(createdAlbum.Data.Title, title); Assert.AreEqual(createdAlbum.Data.Description, description); }
public async Task TestDeleteImage() { var filePath = VariousFunctions.GetTestsAssetDirectory() + @"\upload-image-example.jpg"; var imageBinary = File.ReadAllBytes(filePath); var imgurClient = AuthenticationHelpers.CreateClientAuthenticatedImgurClient(); var imageEndpoint = new ImageEndpoint(imgurClient); var uploadedImage = await imageEndpoint.UploadImageFromBinaryAsync(imageBinary); var response = await imageEndpoint.DeleteImageAsync(uploadedImage.Data.DeleteHash); // Assert the Reponse Assert.IsNotNull(response.Data); Assert.AreEqual(response.Success, true); Assert.AreEqual(response.Status, HttpStatusCode.OK); Assert.IsTrue(response.Data); }
public async Task TestUpdateImageDetails() { var filePath = VariousFunctions.GetTestsAssetDirectory() + @"\upload-image-example.jpg"; var imageBinary = File.ReadAllBytes(filePath); var imgurClient = await AuthenticationHelpers.CreateOAuth2AuthenticatedImgurClient(); var imageEndpoint = new ImageEndpoint(imgurClient); var uploadedImage = await imageEndpoint.UploadImageFromBinaryAsync(imageBinary); var imageTitle = String.Format("title-{0}", new Random().Next(0, 100)); var imageDescription = String.Format("description-{0}", new Random().Next(0, 100)); var editedImageResponse = await imageEndpoint.UpdateImageDetailsAsync(uploadedImage.Data.Id, imageTitle, imageDescription); // Assert the Reponse Assert.IsNotNull(editedImageResponse.Data); Assert.AreEqual(editedImageResponse.Success, true); Assert.AreEqual(editedImageResponse.Status, HttpStatusCode.OK); // Assert the Data Assert.AreEqual(editedImageResponse.Data, true); }
public async Task TestGalleryImageSubmission() { var imgurClient = await AuthenticationHelpers.CreateOAuth2AuthenticatedImgurClient(); var imageEndpoint = new ImageEndpoint(imgurClient); var galleryEndpoint = new GalleryEndpoint(imgurClient); var filePath = VariousFunctions.GetTestsAssetDirectory() + @"\upload-image-example.jpg"; var imageBinary = File.ReadAllBytes(filePath); var uploadedImage = await imageEndpoint.UploadImageFromBinaryAsync(imageBinary); var response = await galleryEndpoint.SubmitImageToGalleryAsync(uploadedImage.Data.Id, "test submission - brace for downvotes"); // Assert the Reponse Assert.IsNotNull(response.Data); Assert.AreEqual(response.Success, true); Assert.AreEqual(response.Status, HttpStatusCode.OK); // Assert the Data Assert.AreEqual(response.Data, true); }
public async Task TestRemoveImagesFromAlbum() { var imgurClient = await AuthenticationHelpers.CreateOAuth2AuthenticatedImgurClient(); var albumEndpoint = new AlbumEndpoint(imgurClient); var imageEndpoint = new ImageEndpoint(imgurClient); var filePath = VariousFunctions.GetTestsAssetDirectory() + @"\upload-image-example.jpg"; var imageBinary = File.ReadAllBytes(filePath); var createdAlbum = await albumEndpoint.CreateAlbumAsync(new[] {(await imageEndpoint.UploadImageFromBinaryAsync(imageBinary)).Data}); await albumEndpoint.RemoveImageFromAlbumAsync(createdAlbum.Data.Id, createdAlbum.Data.Images[0].Id); var updatedAlbum = await albumEndpoint.GetAlbumDetailsAsync(createdAlbum.Data.Id); // Assert the Reponse Assert.IsNotNull(updatedAlbum.Data); Assert.AreEqual(updatedAlbum.Success, true); Assert.AreEqual(updatedAlbum.Status, HttpStatusCode.OK); }
public async Task TestUploadImageFromBinary() { var filePath = VariousFunctions.GetTestsAssetDirectory() + @"\upload-image-example.jpg"; var imageBinary = File.ReadAllBytes(filePath); var imgurClient = AuthenticationHelpers.CreateClientAuthenticatedImgurClient(); var imageEndpoint = new ImageEndpoint(imgurClient); try { var response = await imageEndpoint.UploadImageFromBinaryAsync(imageBinary, title: "yolo", description: "Keep Calm, because yolo #420"); // Assert the Reponse Assert.IsNotNull(response.Data); Assert.AreEqual(response.Success, true); Assert.AreEqual(response.Status, HttpStatusCode.OK); } catch (ImgurResponseFailedException exception) { Assert.Fail(exception.ImgurResponse.Data.ErrorDescription); } }