public void PhotosetsCreateAddPhotosTest() { byte[] imageBytes = TestData.TestImageBytes; var s = new MemoryStream(imageBytes); const string title = "Test Title"; const string title2 = "New Test Title"; const string desc = "Test Description\nSecond Line"; const string desc2 = "New Test Description"; const string tags = "testtag1,testtag2"; s.Position = 0; // Upload photo once var photoId1 = AuthInstance.UploadPicture(s, "Test.jpg", title, desc, tags, false, false, false, ContentType.Other, SafetyLevel.Safe, HiddenFromSearch.Visible); Console.WriteLine("Photo 1 created: " + photoId1); s.Position = 0; // Upload photo a second time var photoId2 = AuthInstance.UploadPicture(s, "Test.jpg", title, desc, tags, false, false, false, ContentType.Other, SafetyLevel.Safe, HiddenFromSearch.Visible); Console.WriteLine("Photo 2 created: " + photoId2); // Creat photoset Photoset photoset = AuthInstance.PhotosetsCreate("Test photoset", photoId1); Console.WriteLine("Photoset created: " + photoset.PhotosetId); try { // Add second photo to photoset. AuthInstance.PhotosetsAddPhoto(photoset.PhotosetId, photoId2); // Remove second photo from photoset AuthInstance.PhotosetsRemovePhoto(photoset.PhotosetId, photoId2); AuthInstance.PhotosetsEditMeta(photoset.PhotosetId, title2, desc2); photoset = AuthInstance.PhotosetsGetInfo(photoset.PhotosetId); Assert.AreEqual(title2, photoset.Title, "New Title should be set."); Assert.AreEqual(desc2, photoset.Description, "New description should be set"); AuthInstance.PhotosetsEditPhotos(photoset.PhotosetId, photoId1, new[] { photoId2, photoId1 }); AuthInstance.PhotosetsRemovePhoto(photoset.PhotosetId, photoId2); } finally { // Delete photoset completely AuthInstance.PhotosetsDelete(photoset.PhotosetId); // Delete both photos. AuthInstance.PhotosDelete(photoId1); AuthInstance.PhotosDelete(photoId2); } }
public void PhotosetsCreateAddPhotosTest() { byte[] imageBytes = TestData.TestImageBytes; var s = new MemoryStream(imageBytes); const string initialPhotoTitle = "Test Title"; const string updatedPhotoTitle = "New Test Title"; const string initialPhotoDescription = "Test Description\nSecond Line"; const string updatedPhotoDescription = "New Test Description"; const string initialTags = "testtag1,testtag2"; s.Position = 0; // Upload photo once var photoId1 = AuthInstance.UploadPicture(s, "Test1.jpg", initialPhotoTitle, initialPhotoDescription, initialTags, false, false, false, ContentType.Other, SafetyLevel.Safe, HiddenFromSearch.Visible); s.Position = 0; // Upload photo a second time var photoId2 = AuthInstance.UploadPicture(s, "Test2.jpg", initialPhotoTitle, initialPhotoDescription, initialTags, false, false, false, ContentType.Other, SafetyLevel.Safe, HiddenFromSearch.Visible); // Creat photoset Photoset photoset = AuthInstance.PhotosetsCreate("Test photoset", photoId1); try { var photos = AuthInstance.PhotosetsGetPhotos(photoset.PhotosetId, PhotoSearchExtras.OriginalFormat | PhotoSearchExtras.Media, PrivacyFilter.None, 1, 30, MediaType.None); photos.Count.ShouldBe(1, "Photoset should contain 1 photo"); photos[0].IsPublic.ShouldBe(false, "Photo 1 should be private"); // Add second photo to photoset. AuthInstance.PhotosetsAddPhoto(photoset.PhotosetId, photoId2); // Remove second photo from photoset AuthInstance.PhotosetsRemovePhoto(photoset.PhotosetId, photoId2); AuthInstance.PhotosetsEditMeta(photoset.PhotosetId, updatedPhotoTitle, updatedPhotoDescription); photoset = AuthInstance.PhotosetsGetInfo(photoset.PhotosetId); photoset.Title.ShouldBe(updatedPhotoTitle, "New Title should be set."); photoset.Description.ShouldBe(updatedPhotoDescription, "New description should be set"); AuthInstance.PhotosetsEditPhotos(photoset.PhotosetId, photoId1, new[] { photoId2, photoId1 }); AuthInstance.PhotosetsRemovePhoto(photoset.PhotosetId, photoId2); } finally { // Delete photoset completely AuthInstance.PhotosetsDelete(photoset.PhotosetId); // Delete both photos. AuthInstance.PhotosDelete(photoId1); AuthInstance.PhotosDelete(photoId2); } }
public void ShouldUploadSampleBinaryDataAsImage() { var imageBytes = TestData.TestImageBytes; Stream s = new MemoryStream(imageBytes); s.Position = 0; const string title = "Test Title"; const string desc = "Test Description\nSecond Line"; const string tags = "testtag1,testtag2"; var photoId = AuthInstance.UploadPicture(s, "Test.jpg", title, desc, tags, false, false, false, ContentType.Other, SafetyLevel.Safe, HiddenFromSearch.Visible); try { PhotoInfo info = AuthInstance.PhotosGetInfo(photoId); Assert.AreEqual(title, info.Title); Assert.AreEqual(desc, info.Description); Assert.AreEqual(2, info.Tags.Count); Assert.AreEqual("testtag1", info.Tags[0].Raw); Assert.AreEqual("testtag2", info.Tags[1].Raw); Assert.IsFalse(info.IsPublic); Assert.IsFalse(info.IsFamily); Assert.IsFalse(info.IsFriend); var sizes = AuthInstance.PhotosGetSizes(photoId); var url = sizes[sizes.Count - 1].Source; using (var client = new WebClient()) { var downloadBytes = client.DownloadData(url); var downloadBase64 = Convert.ToBase64String(downloadBytes); Assert.AreEqual(TestData.TestImageBase64, downloadBase64); } } finally { AuthInstance.PhotosDelete(photoId); } }
public void GroupsPoolsAddNotAuthTestTest() { byte[] imageBytes = TestData.TestImageBytes; Stream s = new MemoryStream(imageBytes); s.Position = 0; string title = "Test Title"; string desc = "Test Description\nSecond Line"; string tags = "testtag1,testtag2"; string photoId = AuthInstance.UploadPicture(s, "Test.jpg", title, desc, tags, false, false, false, ContentType.Other, SafetyLevel.Safe, HiddenFromSearch.Visible); try { Instance.GroupsPoolsAdd(photoId, Data.FlickrNetTestGroupId); } finally { AuthInstance.PhotosDelete(photoId); } }
public void DownloadAndUploadImage() { var photos = AuthInstance.PeopleGetPhotos(PhotoSearchExtras.Small320Url); var photo = photos.First(); var url = photo.Small320Url; var client = new WebClient(); var data = client.DownloadData(url); var ms = new MemoryStream(data) { Position = 0 }; var photoId = AuthInstance.UploadPicture(ms, "test.jpg", "Test Photo", "Test Description", "", false, false, false, ContentType.Photo, SafetyLevel.Safe, HiddenFromSearch.Hidden); Assert.IsNotNull(photoId, "PhotoId should not be null"); // Cleanup AuthInstance.PhotosDelete(photoId); }