Exemplo n.º 1
0
        public void InitializeAnonymous()
        {
            var mock = new Mock <ISmugMugAPI>();

            Album invalidAlbum = null;
            Album validAlbum   = new Album()
            {
                Name = "ValidAlbum", ImageCount = 5
            };

            mock.Setup(api => api.GetAlbum("ValidAlbum")).ReturnsAsync(validAlbum);
            mock.Setup(api => api.GetAlbum("InvalidAlbum")).ReturnsAsync(invalidAlbum);

            AlbumImage nullImage  = null;
            AlbumImage validImage = new AlbumImage()
            {
                FileName = "ValidFileName.jpg", Title = "Valid Image", Format = "JPG"
            };

            mock.Setup(api => api.GetAlbumImage(validAlbum, "ValidImage")).ReturnsAsync(validImage);
            mock.Setup(api => api.GetAlbumImage(validAlbum, "InvalidImage")).ReturnsAsync(nullImage);
            mock.Setup(api => api.GetAlbumImage(invalidAlbum, "ValidImage")).ReturnsAsync(nullImage);
            mock.Setup(api => api.GetAlbumImage(invalidAlbum, "InvalidImage")).ReturnsAsync(nullImage);

            List <AlbumImage> validAlbumImages = new List <AlbumImage>()
            {
                new AlbumImage()
                {
                    FileName = "ValidFileName.jpg", Title = "Valid Image", Format = "JPG"
                }, new AlbumImage()
                {
                    FileName = "AnotherValidFileName.jpg", Title = "Another Valid Image", Format = "JPG"
                }, new AlbumImage()
                {
                    FileName = "ThirdValidFileName.png", Title = "Third Valid Image", Format = "PNG"
                }
            };
            List <AlbumImage> invalidAlbumImages = null;

            mock.Setup(api => api.GetAlbumImages(validAlbum, It.IsInRange <int>(0, int.MaxValue, Range.Inclusive))).ReturnsAsync(validAlbumImages);
            mock.Setup(api => api.GetAlbumImages(validAlbum, It.IsInRange <int>(int.MinValue, 0, Range.Inclusive))).ReturnsAsync(invalidAlbumImages);
            mock.Setup(api => api.GetAlbumImages(invalidAlbum, It.IsInRange <int>(0, int.MaxValue, Range.Inclusive))).ReturnsAsync(invalidAlbumImages);
            mock.Setup(api => api.GetAlbumImages(invalidAlbum, It.IsInRange <int>(int.MinValue, 0, Range.Inclusive))).ReturnsAsync(invalidAlbumImages);
            api = mock.Object;
        }