public void AddPhoto_FailFileService_MediaNull() { Mock<IRepository<Post>> repository = new Mock<IRepository<Post>>(); Mock<ILoggerService> loggerService = new Mock<ILoggerService>(); Mock<IMediaService> mediaService = new Mock<IMediaService>(); Mock<IFileService> fileService = new Mock<IFileService>(); fileService.Setup(o => o.SaveMedia(It.IsAny<string>(), It.IsAny<byte[]>())).Returns(false); PostService service = new PostService(repository.Object, loggerService.Object, mediaService.Object, fileService.Object); byte[] test = new byte[3]; Media stored = service.AddPhoto(Guid.NewGuid(), "test", null); Assert.IsNull(stored); }
public void AddPhoto_ValidPost_MediaStoredAndRetrived() { Mock<IRepository<Post>> repository = new Mock<IRepository<Post>>(); Mock<ILoggerService> loggerService = new Mock<ILoggerService>(); Mock<IMediaService> mediaService = new Mock<IMediaService>(); Mock<IFileService> fileService = new Mock<IFileService>(); mediaService.Setup(o => o.StoreMedia(It.IsAny<Media>())); fileService.Setup(o => o.SaveMedia(It.IsAny<string>(), It.IsAny<byte[]>())).Returns(true); PostService service = new PostService(repository.Object, loggerService.Object, mediaService.Object, fileService.Object); byte[] test = new byte[3]; Media stored = service.AddPhoto(Guid.NewGuid(), "test" ,test); StringAssert.StartsWith("test", stored.MediaData); }