/// <summary>
        /// Displays the gallery index view.
        /// </summary>
        /// <returns>The gallery index view.</returns>
        public ActionResult Index()
        {
            ViewBag.Gallery = new List <PhotoAlbum>();
            PhotoAlbumCollection albumCollection = KkisData.GetAlbumList(ConfigurationManager.AppSettings["KKISGoogleUser"]);

            return(this.View(albumCollection));
        }
示例#2
0
        public void GetAlbumListTest()
        {
            // Arrange
            const string TestAlbumKey          = "Test Album Key";
            const string TestAlbumTitle        = "Test Album";
            Dictionary <string, string> albums = new Dictionary <string, string>
            {
                { TestAlbumKey, TestAlbumTitle }
            };
            const string           TestPhotoThumbnail           = "Test Photo Thumbnail";
            const string           TestPhotoTitle               = "Test Photo";
            const string           TestPhotoKey                 = "Test Photo Key";
            Tuple <string, string> testPhoto                    = new Tuple <string, string>(TestPhotoThumbnail, TestPhotoTitle);
            Dictionary <string, Tuple <string, string> > photos = new Dictionary <string, Tuple <string, string> >
            {
                { TestPhotoKey, testPhoto }
            };
            const string TestUser = "******";
            Mock <IGoogleDataService> mockGoogleService = new Mock <IGoogleDataService>();

            mockGoogleService.Setup(x => x.GetAlbumList(TestUser)).Returns(albums);
            mockGoogleService.Setup(x => x.GetPhotoList(TestAlbumKey)).Returns(photos);
            IKkisDataService dataService = new KkisDataService(mockGoogleService.Object);

            // Act
            PhotoAlbumCollection result = dataService.GetAlbumList(TestUser);

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.Count);
            Assert.AreEqual(TestAlbumTitle, result.First().Title);
            Assert.AreEqual(1, result.First().Photos.Count);
            Assert.AreEqual(TestPhotoTitle, result.First().Photos.First().Title);
        }
        /// <summary>
        /// Gets the album list.
        /// </summary>
        /// <param name="user">The user.</param>
        /// <returns>The list of albums.</returns>
        public PhotoAlbumCollection GetAlbumList(string user)
        {
            Dictionary <string, string> albums = this.googleData.GetAlbumList(user);

            PhotoAlbumCollection albumCollection = new PhotoAlbumCollection();

            albumCollection.AddRange(albums.Select(x =>
            {
                PhotoAlbum album = new PhotoAlbum
                {
                    Id    = x.Value.ToLower().Replace(' ', '_'),
                    Title = x.Value
                };
                Dictionary <string, Tuple <string, string> > photos = this.googleData.GetPhotoList(x.Key);
                album.Photos = photos.Select(y => new Photo
                {
                    Title     = y.Value.Item2,
                    Url       = y.Key,
                    Thumbnail = y.Value.Item1
                }).ToList();
                return(album);
            }).ToArray());

            return(albumCollection);
        }
示例#4
0
        public void PhotoAlbumCollectionTest()
        {
            // Arrange
            string[]             testTitles           = new string[] { "Test1", "Test2" };
            PhotoAlbumCollection photoAlbumCollection = new PhotoAlbumCollection();

            photoAlbumCollection.AddRange(testTitles.Select(x => new PhotoAlbum
            {
                Title = x
            }));

            // Act
            string actualResult   = photoAlbumCollection.ToString();
            string expectedResult = string.Join(", ", testTitles);

            // Assert
            Assert.AreEqual(expectedResult, actualResult);
        }
        /// <summary>
        /// Gets the album list.
        /// </summary>
        /// <param name="user">The user.</param>
        /// <returns>The list of albums.</returns>
        public PhotoAlbumCollection GetAlbumList(string user)
        {
            Dictionary<string, string> albums = this.googleData.GetAlbumList(user);

            PhotoAlbumCollection albumCollection = new PhotoAlbumCollection();
            albumCollection.AddRange(albums.Select(x =>
            {
                PhotoAlbum album = new PhotoAlbum
                {
                    Id = x.Value.ToLower().Replace(' ', '_'),
                    Title = x.Value
                };
                Dictionary<string, Tuple<string, string>> photos = this.googleData.GetPhotoList(x.Key);
                album.Photos = photos.Select(y => new Photo
                {
                    Title = y.Value.Item2,
                    Url = y.Key,
                    Thumbnail = y.Value.Item1
                }).ToList();
                return album;
            }).ToArray());

            return albumCollection;
        }
        /// <summary>
        /// Retrieves navigation data for the gallery.
        /// </summary>
        /// <returns>The gallery navigation data in JSON format.</returns>
        public JsonResult Navigation()
        {
            PhotoAlbumCollection albumCollection = KkisData.GetAlbumList(ConfigurationManager.AppSettings["KKISGoogleUser"]);

            return(this.Json(albumCollection));
        }