public void ShouldReturnFalseWhenDeleteMediaFoundNoRecord() { _mediaRepository = new Mock<IMediaRepository>(); _mediaRepository.Setup(a => a.Find(It.IsAny<Expression<Func<Media, bool>>>(), false)) .Returns(new List<Media>()); _albumRepository = new Mock<IAlbumRepository>(); _imageHelper = new Mock<IImageHelper>(); _configurationHelper = new Mock<IConfigurationHelper>(); _fileHelper = new Mock<IFileHelper>(); _mediaLogic = new MediaLogic(_mediaRepository.Object, _albumRepository.Object, _imageHelper.Object, _configurationHelper.Object, _fileHelper.Object); var result = _mediaLogic.Delete(1); Assert.IsFalse(result); }
public void ShouldThrowExceptionWhenDeleteMediaFailsOnMediaRepository() { _mediaRepository = new Mock<IMediaRepository>(); _mediaRepository.Setup(a => a.Find(It.IsAny<Expression<Func<Media, bool>>>(), false)) .Throws(new Exception()); _albumRepository = new Mock<IAlbumRepository>(); _imageHelper = new Mock<IImageHelper>(); _configurationHelper = new Mock<IConfigurationHelper>(); _fileHelper = new Mock<IFileHelper>(); _mediaLogic = new MediaLogic(_mediaRepository.Object, _albumRepository.Object, _imageHelper.Object, _configurationHelper.Object, _fileHelper.Object); Assert.Throws<BlogException>(() => _mediaLogic.Delete(1)); }
public void ShouldReturnTrueOnDeleteMedia() { var media = _media.Where(a => a.MediaId == 1).ToList(); _mediaRepository = new Mock<IMediaRepository>(); _mediaRepository.Setup(a => a.Find(It.IsAny<Expression<Func<Media, bool>>>(), false)) .Returns(media); _fileHelper = new Mock<IFileHelper>(); _albumRepository = new Mock<IAlbumRepository>(); _imageHelper = new Mock<IImageHelper>(); _configurationHelper = new Mock<IConfigurationHelper>(); _mediaLogic = new MediaLogic(_mediaRepository.Object, _albumRepository.Object, _imageHelper.Object, _configurationHelper.Object, _fileHelper.Object); var result = _mediaLogic.Delete(1); Assert.IsTrue(result); }