public void PutAsync_ShouldReturnBadRequest_IfModelStateHasIssues() { //arrange var controller = new CoordinateListController(_cooServiceMock.Object); controller.ModelState.AddModelError("id", "could not parse value"); //act var result = controller.PutAsync(10, new CoordinateList(10, "test", null)).Result; //verify Assert.IsType <BadRequestObjectResult>(result); }
public void PutAsync_ShouldReturNotFound_IfListDoesNotExist() { //arrange const int id = 852; _cooServiceMock.Setup(s => s.GetList(id)).Returns(Task.FromResult <Entities.CoordinateList>(null)); var controller = new CoordinateListController(_cooServiceMock.Object); //act var result = controller.PutAsync(10, new CoordinateList(10, "test", null)).Result; //verify Assert.IsType <NotFoundResult>(result); }
public void PutAsync_ShouldReturnBadRequest_IfModelIsInvalid() { //arrange const int id = 10; _cooServiceMock.Setup(s => s.GetList(id)).ReturnsAsync(new Entities.CoordinateList(id, "test")); var controller = new CoordinateListController(_cooServiceMock.Object); //act var result = controller.PutAsync( 10, new CoordinateList( 10, "test", new List <Coordinate>() { new Coordinate(999999999, 52) }) ).Result; //verify Assert.IsType <BadRequestObjectResult>(result); }