Пример #1
0
        public void GalleriesEditComplexTest()
        {
            string primaryPhotoId = "486875512";
            string comment        = "You don't get much better than this for the best Entrance to Hell.\n\n" + DateTime.Now.ToString();
            string galleryId      = "78188-72157622589312064";

            // Get photos
            var photos = AuthInstance.GalleriesGetPhotos(galleryId);

            List <string> photoIds = new List <string>();

            foreach (var p in photos)
            {
                photoIds.Add(p.PhotoId);
            }

            // Remove the last one.
            GalleryPhoto photo = photos[photos.Count - 1];

            photoIds.Remove(photo.PhotoId);

            // Update the gallery
            AuthInstance.GalleriesEditPhotos(galleryId, primaryPhotoId, photoIds);

            // Check removed photo no longer returned.
            var photos2 = AuthInstance.GalleriesGetPhotos(galleryId);

            Assert.AreEqual(photos.Count - 1, photos2.Count, "Should be one less photo.");

            bool found = false;

            foreach (var p in photos2)
            {
                if (p.PhotoId == photo.PhotoId)
                {
                    found = true;
                    break;
                }
            }
            Assert.IsFalse(false, "Should not have found the photo in the gallery.");

            // Add photo back in
            AuthInstance.GalleriesAddPhoto(galleryId, photo.PhotoId, photo.Comment);

            var photos3 = AuthInstance.GalleriesGetPhotos(galleryId);

            Assert.AreEqual(photos.Count, photos3.Count, "Count should match now photo added back in.");

            found = false;
            foreach (var p in photos3)
            {
                if (p.PhotoId == photo.PhotoId)
                {
                    Assert.AreEqual(photo.Comment, p.Comment, "Comment should have been updated.");
                    found = true;
                    break;
                }
            }

            Assert.IsTrue(found, "Should have found the photo in the gallery.");
        }