コード例 #1
0
        public IfPassedANewPostWithATitle()
        {
            _newPost       = AddPostHandlerTests.CreateValidPostForAdding();
            _newPost.Title = Title;

            AddPostHandler handler = AddPostHandlerTests.CreateHandler();

            _response = handler.Handle(new AddPostRequest(_newPost));
        }
コード例 #2
0
        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));
        }
コード例 #3
0
 public IfPassedAnEmptyRequest()
 {
     _handler = AddPostHandlerTests.CreateHandler();
 }
コード例 #4
0
 public IfPassedANewPostWithAnId()
 {
     _handler    = AddPostHandlerTests.CreateHandler();
     _newPost    = AddPostHandlerTests.CreateValidPostForAdding();
     _newPost.Id = "ShouldNotHaveOne";
 }
コード例 #5
0
 public IfPassedANewPostWithANullTitle()
 {
     _handler       = AddPostHandlerTests.CreateHandler();
     _newPost       = AddPostHandlerTests.CreateValidPostForAdding();
     _newPost.Title = null;
 }
コード例 #6
0
 public void ThrowsArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() => AddPostHandlerTests.CreateHandler(null));
 }