示例#1
0
        public AddPostResponseDto AddPost(AddPostRequestDto post)
        {
            IBlogPost blogPost = blogPostMapper.MapFrom(post);
            blogPostRepository.Save(blogPost);

            return new AddPostResponseDto(true);
        }
        public void AddPost_ShouldUseMapperForPost()
        {
            AddPostRequestDto requestDto = new AddPostRequestDto();

            using(mockery.Record())
            {
                Expect.Call(blogPostMapper.MapFrom(requestDto)).Return(post);
            }

            using(mockery.Playback())
            {
                service.AddPost(requestDto);
            }
        }
        public void Save_ShouldSavePost_AndDisplayResponse()
        {
            AddPostRequestDto post = new AddPostRequestDto();
            post.Title = "Title";
            post.Description = "Description";
            post.Content = "Content";

            using(mockery.Record())
            {
                Expect.Call(blogPostService.AddPost(post)).Return(new AddPostResponseDto(true));
            }

            using(mockery.Playback())
            {
                controller.Save(post);
            }

            Assert.AreEqual(controller.PropertyBag["responseMessage"],
                @"The post titled: 'Title' was created!", "Incorrect response message displayed");
            Assert.AreEqual(controller.SelectedViewName, @"post\postcreated",
                "Expected view wasn't rendered");
        }
示例#4
0
 public IBlogPost MapFrom(AddPostRequestDto dto)
 {
     IBlogPost blogPost = new BlogPost(dto.Title, dto.Description, dto.Content);
     return blogPost;
 }