Test for invalid id
This commit is contained in:
parent
7e79bbee3e
commit
1837f126a3
2 changed files with 10 additions and 6 deletions
|
@ -46,7 +46,17 @@ namespace Robware.Api.Blog.Tests {
|
||||||
|
|
||||||
var controller = new BlogController(logger, repo);
|
var controller = new BlogController(logger, repo);
|
||||||
(await controller.Get("url")).Result.Should().BeOfType<NotFoundObjectResult>();
|
(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>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,9 +33,6 @@ namespace Robware.Api.Blog.Controllers {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//[HttpGet]
|
|
||||||
//Task<BlogPost> GetPostByUrl();
|
|
||||||
|
|
||||||
//[HttpGet]
|
//[HttpGet]
|
||||||
//Task<IEnumerable<BlogPost>> GetLatestPosts(int limit, int offset = 0);
|
//Task<IEnumerable<BlogPost>> GetLatestPosts(int limit, int offset = 0);
|
||||||
|
|
||||||
|
@ -45,9 +42,6 @@ namespace Robware.Api.Blog.Controllers {
|
||||||
//[HttpGet]
|
//[HttpGet]
|
||||||
//Task<int> GetCount();
|
//Task<int> GetCount();
|
||||||
|
|
||||||
//[HttpGet]
|
|
||||||
//Task<BlogPost> GetPostById(int id);
|
|
||||||
|
|
||||||
//[HttpPost]
|
//[HttpPost]
|
||||||
//Task<BlogPost> SavePost(BlogPost post);
|
//Task<BlogPost> SavePost(BlogPost post);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue