public void Remove_NotExistObject_ReturnsNotFoundResponse() { // Arrange CoachController controller = new CoachController(_teamServicMock.Object, _coachService.Object, _mapperMock, _configuration.Object, _cityServicMock.Object); // Act var badResponse = controller.Delete(6).Result; // Assert Assert.IsType <NotFoundResult>(badResponse); }
public void Remove_ExistObject_RemoveMethodVerified() { //Arrange CoachController controller = new CoachController(_teamServicMock.Object, _coachService.Object, _mapperMock, _configuration.Object, _cityServicMock.Object); // Act var result = controller.Delete(1).Result; var resViewName = (RedirectToActionResult)result; // Assert _coachService.Verify(m => m.Delete(It.IsAny <CoachDTO>(), false), Times.Once); Assert.Equal("Index", resViewName?.ActionName); }
public void CoachController_Verify_Delete() { // arrange int id = 1; var serviceMock = new Mock <ICoachService>(); CoachController controller = new CoachController(serviceMock.Object); // act IActionResult result = controller.Delete(id) as IActionResult; // assert serviceMock.Verify(a => a.DeleteCoach(id)); }
public void Remove_NullIdPassed_ReturnsNotFoundResponse() { var httpContext = new DefaultHttpContext(); var tempData = new TempDataDictionary(httpContext, Mock.Of <ITempDataProvider>()); tempData["Error"] = @Resources.Exceptions.notCorrectRequest; //Arrange CoachController controller = new CoachController(_teamServicMock.Object, _coachService.Object, _mapperMock, _configuration.Object, _cityServicMock.Object) { TempData = tempData }; //Act var result = controller.Delete(null); //Assert var resViewName = (RedirectToActionResult)result.Result; //Assert Assert.Equal("Error", resViewName.ActionName); Assert.Equal("Home", resViewName.ControllerName); }