public void Deletevalid() { string customerId = "0"; customer customer = new customer(); mockedCustomerRepository.Setup(item => item.FindById(customerId)).Returns(customer); var controller = new CustomerController(mockedRepositoryCustomer.Object, mockedCustomerRepository.Object, mockedRepositorySource.Object); var returnObj = controller.Delete(customerId); Assert.IsNotNull(returnObj); Assert.IsInstanceOfType(returnObj, typeof(ViewResult)); var result = (ViewResult)returnObj; Assert.IsNotNull(result); mockedCustomerRepository.Verify(m => m.FindById(customerId), Times.Once()); }
public void DeleteInvalid() { string customerId = null; var controller = new CustomerController(mockedRepositoryCustomer.Object, mockedCustomerRepository.Object, mockedRepositorySource.Object); var returnObj = controller.Delete(customerId); Assert.IsNotNull(returnObj); Assert.IsInstanceOfType(returnObj, typeof(HttpStatusCodeResult)); var result = (HttpStatusCodeResult)returnObj; Assert.IsNotNull(result); Assert.AreEqual(result.StatusCode, 400); }