Beispiel #1
0
        public void PhotosSearchContactsPhotos()
        {
            var contacts = AuthInstance.ContactsGetList(1, 1000).Select(c => c.UserId).ToList();

            // Test with user id = "me"
            var o = new PhotoSearchOptions
            {
                UserId   = "me",
                Contacts = ContactSearch.AllContacts,
                PerPage  = 50
            };

            var photos = AuthInstance.PhotosSearch(o);

            Assert.IsNotNull(photos, "PhotosSearch should not return a null instance.");
            Assert.IsTrue(photos.Any(), "PhotoSearch should have returned some photos.");
            Assert.IsTrue(photos.All(p => p.UserId != TestData.TestUserId), "None of the photos should be mine.");
            Assert.IsTrue(photos.All(p => contacts.Contains(p.UserId)), "UserID not found in list of contacts.");

            // Retest with user id specified explicitly
            o.UserId = TestData.TestUserId;
            photos   = AuthInstance.PhotosSearch(o);

            Assert.IsNotNull(photos, "PhotosSearch should not return a null instance.");
            Assert.IsTrue(photos.Any(), "PhotoSearch should have returned some photos.");
            Assert.IsTrue(photos.All(p => p.UserId != TestData.TestUserId), "None of the photos should be mine.");
            Assert.IsTrue(photos.All(p => contacts.Contains(p.UserId)), "UserID not found in list of contacts.");
        }
Beispiel #2
0
        public void PhotosGeoPhotosForLocationBasicTest()
        {
            var o = new PhotoSearchOptions
            {
                UserId  = TestData.TestUserId,
                HasGeo  = true,
                PerPage = 1,
                Extras  = PhotoSearchExtras.Geo
            };

            var photos = AuthInstance.PhotosSearch(o);
            var photo  = photos[0];

            var photos2 = AuthInstance.PhotosGeoPhotosForLocation(photo.Latitude, photo.Longitude, photo.Accuracy, PhotoSearchExtras.All, 0, 0);

            Assert.IsNotNull(photos2, "PhotosGeoPhotosForLocation should not return null.");
            Assert.IsTrue(photos2.Count > 0, "Should return one or more photos.");

            foreach (var p in photos2)
            {
                Assert.IsNotNull(p.PhotoId);
                Assert.AreNotEqual(0, p.Longitude);
                Assert.AreNotEqual(0, p.Latitude);
            }
        }
Beispiel #3
0
        public void PhotosGeoSetLocationTest()
        {
            var photo = AuthInstance.PhotosSearch(new PhotoSearchOptions {
                HasGeo = true, UserId = TestData.TestUserId, Extras = PhotoSearchExtras.Geo
            }).First();

            if (photo.GeoContext == null)
            {
                Assert.Fail("GeoContext should not be null");
            }

            var origGeo = new { photo.Latitude, photo.Longitude, photo.Accuracy, Context = photo.GeoContext.Value };
            var newGeo  = new { Latitude = -23.32, Longitude = -34.2, Accuracy = GeoAccuracy.Level10, Context = GeoContext.Indoors };

            try
            {
                AuthInstance.PhotosGeoSetLocation(photo.PhotoId, newGeo.Latitude, newGeo.Longitude, newGeo.Accuracy, newGeo.Context);

                var location = AuthInstance.PhotosGeoGetLocation(photo.PhotoId);
                Assert.AreEqual(newGeo.Latitude, location.Latitude, "New Latitude should be set.");
                Assert.AreEqual(newGeo.Longitude, location.Longitude, "New Longitude should be set.");
                Assert.AreEqual(newGeo.Context, location.Context, "New Context should be set.");
                Assert.AreEqual(newGeo.Accuracy, location.Accuracy, "New Accuracy should be set.");
            }
            finally
            {
                AuthInstance.PhotosGeoSetLocation(photo.PhotoId, origGeo.Latitude, origGeo.Longitude, origGeo.Accuracy, origGeo.Context);
            }
        }
Beispiel #4
0
        public void PhotosGetCorrectLocationTest()
        {
            var photo = AuthInstance.PhotosSearch(new PhotoSearchOptions {
                HasGeo = true, UserId = TestData.TestUserId, Extras = PhotoSearchExtras.Geo
            }).First();

            AuthInstance.PhotosGeoCorrectLocation(photo.PhotoId, photo.PlaceId, null);
        }
Beispiel #5
0
        public void PhotosSearchAuthRussianCharacters()
        {
            var o = new PhotoSearchOptions();

            o.Tags = "снег";

            var photos = AuthInstance.PhotosSearch(o);

            Assert.AreNotEqual(0, photos.Count, "Search should return some results.");
        }
Beispiel #6
0
        public void PhotosSearchFavorites()
        {
            var o = new PhotoSearchOptions {
                UserId = "me", Faves = true, Tags = "cat"
            };

            PhotoCollection p = AuthInstance.PhotosSearch(o);

            Assert.IsTrue(p.Count > 5, "Should have returned more than 5 result returned. Count = " + p.Count);
            Assert.IsTrue(p.Count < 100, "Should be less than 100 results returned. Count = " + p.Count);
        }
Beispiel #7
0
        public void PhotosGetGetLocationNullTest()
        {
            var photos = AuthInstance.PhotosSearch(new PhotoSearchOptions {
                HasGeo = false, UserId = TestData.TestUserId, Extras = PhotoSearchExtras.Geo
            });

            var photo = photos.First();

            var location = AuthInstance.PhotosGeoGetLocation(photo.PhotoId);

            Assert.IsNull(location, "Location should be null.");
        }
Beispiel #8
0
        public void PhotosSearchCameraIphone()
        {
            var o = new PhotoSearchOptions
            {
                Camera        = "iPhone 5S",
                MinUploadDate = DateTime.Now.AddDays(-7),
                MaxUploadDate = DateTime.Now,
                Extras        = PhotoSearchExtras.Tags
            };

            var ps = AuthInstance.PhotosSearch(o);

            Assert.IsNotNull(ps);
            Assert.AreNotEqual(0, ps.Count);
        }
Beispiel #9
0
        public void PhotosGetGetLocationTest()
        {
            var photos = AuthInstance.PhotosSearch(new PhotoSearchOptions {
                HasGeo = true, UserId = TestData.TestUserId, Extras = PhotoSearchExtras.Geo
            });

            var photo = photos.First();

            Console.WriteLine(photo.PhotoId);

            var location = AuthInstance.PhotosGeoGetLocation(photo.PhotoId);

            Assert.AreEqual(photo.Longitude, location.Longitude, "Longitudes should match exactly.");
            Assert.AreEqual(photo.Latitude, location.Latitude, "Latitudes should match exactly.");
        }
Beispiel #10
0
        public void PhotosGeoSetContextTest()
        {
            var photo = AuthInstance.PhotosSearch(new PhotoSearchOptions {
                HasGeo = true, UserId = TestData.TestUserId, Extras = PhotoSearchExtras.Geo
            }).First();

            Assert.IsTrue(photo.GeoContext.HasValue, "GeoContext should be set.");

            var origContext = photo.GeoContext.Value;

            var newContext = origContext == GeoContext.Indoors ? GeoContext.Outdoors : GeoContext.Indoors;

            try
            {
                AuthInstance.PhotosGeoSetContext(photo.PhotoId, newContext);
            }
            finally
            {
                AuthInstance.PhotosGeoSetContext(photo.PhotoId, origContext);
            }
        }