public IfPassedANewPostWithATitle() { _newPost = AddPostHandlerTests.CreateValidPostForAdding(); _newPost.Title = Title; AddPostHandler handler = AddPostHandlerTests.CreateHandler(); _response = handler.Handle(new AddPostRequest(_newPost)); }
public IfPassedAValidNewPost() { _mockPersistance = new Mock <IRepository>(); _mockPersistance .Setup(m => m.StorePost(It.IsAny <Post>())) .Returns <Post>(p => { var storedPost = Post.Clone(p); storedPost.Id = NewId; _storedPost = storedPost; return(_storedPost.Id); }); _mockPersistance .Setup(m => m.GetPost(NewId)) .Returns(() => _storedPost); AddPostHandler handler = AddPostHandlerTests.CreateHandler(_mockPersistance.Object); Post newPost = AddPostHandlerTests.CreateValidPostForAdding(); _response = handler.Handle(new AddPostRequest(newPost)); }
public void ThrowsArgumentNullException() { Assert.Throws <ArgumentNullException>(() => _handler.Handle(null)); }
public void ThenReturnsAPostThatHasTheSameTitle() { Assert.Throws <ValidationException>(() => _handler.Handle(new AddPostRequest(_newPost))); }
public void ThenThrowsAValidationException() { Assert.Throws <ValidationException>(() => _handler.Handle(new AddPostRequest(_newPost))); }