public void GetById_WhenExistingBlogFound_ReturnsBlog() { var blogInDatabase = new Blog { Id = 1, Post = null, Url = "http://www.company.com" }; var blogInDatabase2 = new Blog { Id = 2, Post = null, Url = "http://www.other.com" }; var expectedBlogModel = new BlogModel { Id = blogInDatabase.Id, Url = blogInDatabase.Url }; _repository.Setup(library => library.FindAll()) .Returns(new List <Blog> { blogInDatabase, blogInDatabase2 }.AsQueryable()); var actual = _blogProcessor.GetBlog(blogInDatabase.Id); actual.Should().BeEquivalentTo(expectedBlogModel); }
public IActionResult Get(int id) { var blog = _blogProcessor.GetBlog(id); return(new JsonResult(blog)); }