public void DeletePost_InvalidEmployeeID() { // Arrange - create the controller VisaRegistrationDateController target = new VisaRegistrationDateController(mock.Object, messengerMock.Object); // Act - call the action method var result = (HttpNotFoundResult)target.DeleteConfirmed(15); VisaRegistrationDate visaRegDate = mock.Object.VisaRegistrationDates.Where(m => m.EmployeeID == 15).FirstOrDefault(); // Assert - check the result mock.Verify(m => m.DeleteVisaRegistrationDate(15), Times.Never); Assert.IsInstanceOf(typeof(HttpNotFoundResult), result); Assert.AreEqual(404, result.StatusCode); Assert.IsNull(visaRegDate); }
public void DeletePost_ValidVisaRegistrationDate() { // Arrange - create the controller VisaRegistrationDateController target = new VisaRegistrationDateController(mock.Object, messengerMock.Object); MvcApplication.JSDatePattern = "dd.mm.yyyy"; // Act - call the action method var result = target.DeleteConfirmed(1, "as"); // Assert - check the result mock.Verify(m => m.DeleteVisaRegistrationDate(1), Times.Once); Assert.AreEqual("TableViewVisasAndPermitsBTM", ((ViewResult)result).ViewName); Assert.IsInstanceOf(typeof(List <Employee>), ((ViewResult)result).Model); Assert.AreEqual("as", ((ViewResult)result).ViewBag.SearchString); Assert.AreEqual("dd.mm.yyyy", ((ViewResult)result).ViewBag.JSDatePattern); }