Beispiel #1
0
        public async Task DeletePhotoShouldWorkCorrectly()
        {
            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 = "123",
            };

            photos.Add(photo);
            await service.DeletePhoto("123");

            Assert.Equal(true, photo.IsDeleted);
        }