Get latest blog post
This commit is contained in:
parent
c1eff209eb
commit
67c71d4d06
2 changed files with 33 additions and 4 deletions
|
@ -108,5 +108,29 @@ namespace Robware.Api.Blog.Tests {
|
|||
var controller = new BlogController(logger, repo);
|
||||
(await controller.GetLatestPosts(1, 1000)).Result.Should().BeOfType<NotFoundObjectResult>();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetLatestPost_ReturnsBlogPosts() {
|
||||
var logger = Substitute.For<ILogger<BlogController>>();
|
||||
var repo = Substitute.For<IBlogRepository>();
|
||||
|
||||
repo.GetLatestPostAsync().Returns(new BlogPost());
|
||||
|
||||
var expectation = new BlogPost();
|
||||
|
||||
var controller = new BlogController(logger, repo);
|
||||
(await controller.GetLatestPost()).Value.Should().BeEquivalentTo(expectation);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetLatestPost_WhenNoPostExists_Returns404() {
|
||||
var logger = Substitute.For<ILogger<BlogController>>();
|
||||
var repo = Substitute.For<IBlogRepository>();
|
||||
|
||||
repo.GetLatestPostAsync().Throws(new ItemNotFoundException("", null));
|
||||
|
||||
var controller = new BlogController(logger, repo);
|
||||
(await controller.GetLatestPost()).Result.Should().BeOfType<NotFoundObjectResult>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue