public void DeleteGet_InvalidEmployeeID() { // Arrange - create the controller PermitController target = new PermitController(mock.Object, messengerMock.Object); // Act - call the action method var result = (HttpNotFoundResult)target.Delete(15); Permit permit = mock.Object.Permits.Where(m => m.EmployeeID == 15).FirstOrDefault(); // Assert - check the result mock.Verify(m => m.DeletePermit(It.IsAny <int>()), Times.Never); Assert.IsInstanceOf(typeof(HttpNotFoundResult), result); Assert.AreEqual(404, result.StatusCode); Assert.IsNull(permit); }
public void DeleteGet_SearchStringDValidEmployeeID() { // Arrange - create the controller PermitController target = new PermitController(mock.Object, messengerMock.Object); // Act - call the action method var result = target.Delete(2, "D") as ViewResult; Permit permit = (Permit)result.ViewData.Model; // Assert - check the result Assert.AreEqual("", result.ViewName); Assert.AreEqual("D", result.ViewBag.SearchString); Assert.IsInstanceOf(typeof(Permit), result.ViewData.Model); Assert.IsInstanceOf(typeof(ViewResult), result); Assert.IsNotNull(result.ViewData.Model); Assert.AreEqual(2, permit.EmployeeID); }