Test for invalid id

This commit is contained in:
Robert Marshall 2020-04-10 10:11:55 +01:00
parent 7e79bbee3e
commit 1837f126a3
2 changed files with 10 additions and 6 deletions

View file

@ -46,7 +46,17 @@ namespace Robware.Api.Blog.Tests {
var controller = new BlogController(logger, repo);
(await controller.Get("url")).Result.Should().BeOfType<NotFoundObjectResult>();
}
[Fact]
public async Task Get_WithInvalidId_Returns404() {
var logger = Substitute.For<ILogger<BlogController>>();
var repo = Substitute.For<IBlogRepository>();
repo.GetPostByIdAsync(1).Throws(new ItemNotFoundException("", null));
var controller = new BlogController(logger, repo);
(await controller.Get("1")).Result.Should().BeOfType<NotFoundObjectResult>();
}
}
}

View file

@ -33,9 +33,6 @@ namespace Robware.Api.Blog.Controllers {
}
}
//[HttpGet]
//Task<BlogPost> GetPostByUrl();
//[HttpGet]
//Task<IEnumerable<BlogPost>> GetLatestPosts(int limit, int offset = 0);
@ -45,9 +42,6 @@ namespace Robware.Api.Blog.Controllers {
//[HttpGet]
//Task<int> GetCount();
//[HttpGet]
//Task<BlogPost> GetPostById(int id);
//[HttpPost]
//Task<BlogPost> SavePost(BlogPost post);