Example #1
0
        public void InitializeAnonymous()
        {
            var mock = new Mock <ISmugMugAPI>();

            SmugMugUri defaultNodeUri = new SmugMugUri()
            {
                Uri = "/api/v2/node/ABCDE"
            };

            User nullUser  = null;
            User validUser = new User()
            {
                Name = "Valid User", NickName = "ValidUser", Uris = new UserUris {
                    Node = defaultNodeUri
                }
            };
            User updatedUser = new User()
            {
                Name = "Valid User", NickName = "NickName"
            };

            mock.Setup(api => api.GetUser("ValidUser")).ReturnsAsync(validUser);
            mock.Setup(api => api.GetUser("InvalidUser")).ReturnsAsync(nullUser);

            mock.Setup(api => api.GetDefaultNodeID(validUser)).Returns("ABCDE");

            List <Album> validAlbums = new List <Album>()
            {
                new Album()
                {
                    Name = "ValidAlbum", ImageCount = 5
                }, new Album()
                {
                    Name = "AnotherValidAlbum", ImageCount = 10
                }, new Album()
                {
                    Name = "ThirdValidAlbum", ImageCount = 15
                }
            };
            List <Album> invalidAlbums = null;

            mock.Setup(api => api.GetAlbums(validUser, It.IsInRange <int>(0, int.MaxValue, Range.Inclusive))).ReturnsAsync(validAlbums);
            mock.Setup(api => api.GetAlbums(validUser, It.IsInRange <int>(int.MinValue, 0, Range.Inclusive))).ReturnsAsync(invalidAlbums);
            mock.Setup(api => api.GetAlbums(nullUser, It.IsInRange <int>(0, int.MaxValue, Range.Inclusive))).ReturnsAsync(invalidAlbums);
            mock.Setup(api => api.GetAlbums(nullUser, It.IsInRange <int>(int.MinValue, 0, Range.Inclusive))).ReturnsAsync(invalidAlbums);

            mock.Setup(api => api.GetFeaturedAlbums(validUser, It.IsInRange <int>(0, int.MaxValue, Range.Inclusive))).ReturnsAsync(validAlbums);
            mock.Setup(api => api.GetFeaturedAlbums(validUser, It.IsInRange <int>(int.MinValue, 0, Range.Inclusive))).ReturnsAsync(invalidAlbums);
            mock.Setup(api => api.GetFeaturedAlbums(nullUser, It.IsInRange <int>(0, int.MaxValue, Range.Inclusive))).ReturnsAsync(invalidAlbums);
            mock.Setup(api => api.GetFeaturedAlbums(nullUser, It.IsInRange <int>(int.MinValue, 0, Range.Inclusive))).ReturnsAsync(invalidAlbums);

            api = mock.Object;
        }