public async Task PostVideoGame_WithException_ReturnsInternalServerError() { //Arrange videoGameStub.Setup(service => service.PostVideogame(It.IsAny <Videogame>())).Throws(new Exception()); videogameController = new VideogameController(videoGameStub.Object); //Act var actionResult = await videogameController.PostVideogame(null); //Assert Assert.Equal("500", ((StatusCodeResult)actionResult.Result).StatusCode.ToString()); }
public async Task PostVideoGame_WithNewVideogame_ReturnNewlyCreatedVideogame() { //Arrange videoGameStub.Setup(service => service.PostVideogame(It.IsAny <Videogame>())).ReturnsAsync(sampleVideogame); videogameController = new VideogameController(videoGameStub.Object); //Act var actionResult = await videogameController.PostVideogame(toBePostedVideogame); //Assert Assert.Equal("201", ((CreatedAtActionResult)actionResult.Result).StatusCode.ToString()); }