Delete a post
This commit is contained in:
parent
d2080679fd
commit
0d29e9494a
2 changed files with 15 additions and 2 deletions
|
@ -233,5 +233,15 @@ namespace Robware.Api.Blog.Tests {
|
|||
var controller = new BlogController(logger, repo);
|
||||
(await controller.GetAllPosts()).Value.Should().BeEquivalentTo(new BlogPost[10]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task DeletePost_WithId_Returns200() {
|
||||
var logger = Substitute.For<ILogger<BlogController>>();
|
||||
var repo = Substitute.For<IBlogRepository>();
|
||||
|
||||
var controller = new BlogController(logger, repo);
|
||||
(await controller.DeletePost(1)).Should().BeOfType<OkResult>();
|
||||
await repo.Received(1).DeletePostAsync(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -100,7 +100,10 @@ namespace Robware.Api.Blog.Controllers {
|
|||
[HttpGet(nameof(GetAllPosts))]
|
||||
public async Task<ActionResult<BlogPost[]>> GetAllPosts() => (await _blogRepository.GetAllPostsAsync()).ToArray();
|
||||
|
||||
//[HttpGet]
|
||||
//Task DeletePost(int id);
|
||||
[HttpPost(nameof(DeletePost))]
|
||||
public async Task<ActionResult> DeletePost([FromBody] int id) {
|
||||
await _blogRepository.DeletePostAsync(id);
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue