Exemple #1
0
        public async Task TestAddImagesToAlbum()
        {
            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();

            await
            albumEndpoint.AddImageToAlbumAsync(createdAlbum.Data.Id,
                                               (await imageEndpoint.UploadImageFromBinaryAsync(imageBinary)).Data.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);

            // Assert the data
            Assert.AreEqual(createdAlbum.Data.ImagesCount + 1, updatedAlbum.Data.ImagesCount);
        }
Exemple #2
0
        public async Task TestGetAllImagesFromAlbum()
        {
            var imgurClient   = AuthenticationHelpers.CreateClientAuthenticatedImgurClient();
            var albumEndpoint = new AlbumEndpoint(imgurClient);
            var albumDetails  = await albumEndpoint.GetAlbumDetailsAsync("IPPAY");

            var albumImages = await albumEndpoint.GetAllImagesFromAlbumAsync(albumDetails.Data.Id);

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

            // Asset the Data
            Assert.AreEqual(albumImages.Data.Length, albumDetails.Data.ImagesCount);
        }
Exemple #3
0
        public async Task TestGetAlbumDetails()
        {
            var imgurClient   = AuthenticationHelpers.CreateClientAuthenticatedImgurClient();
            var albumEndpoint = new AlbumEndpoint(imgurClient);
            var response      = await albumEndpoint.GetAlbumDetailsAsync("IPPAY");

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

            // Asset the Data
            Assert.AreEqual(response.Data.Title, "Grassy Snowbound");
            Assert.AreEqual(response.Data.Layout, "blog");
            Assert.AreEqual(response.Data.Privacy, "public");
        }