Esempio n. 1
0
        public void GetCountOfPhotosShouldWorkCorrectly()
        {
            var photos = new List <Photo>();

            var mockPhoto = new Mock <IDeletableEntityRepository <Photo> >();

            mockPhoto.Setup(x => x.All()).Returns(photos.AsQueryable());
            mockPhoto.Setup(x => x.AddAsync(It.IsAny <Photo>())).Callback((Photo ph) => photos.Add(ph));

            var service = new AdminsService(null, null, mockPhoto.Object, null, null);

            var photo = new Photo
            {
                Id        = "1",
                ImagePath = "/images/photos",
            };

            photos.Add(photo);
            var expectedResult = 1;
            var result         = service.GetCountOfPhotos();

            Assert.Equal(expectedResult, result);
        }