public void Controller_FactoryInventory_Delete_IDIsNull_Should_Pass() { // Arrange FactoryInventoryController controller = new FactoryInventoryController(); var context = CreateMoqSetupForCookie(); controller.ControllerContext = new ControllerContext(context, new RouteData(), controller); // Act ViewResult result = controller.Delete() as ViewResult; // Reset FactoryInventoryBackend DataSourceBackend.Instance.Reset(); // Assert Assert.AreEqual(null, result.Model, TestContext.TestName); }
public void Controller_FactoryInventory_Delete_Post_Valid_Should_Return_IndexPage() { // Arrange FactoryInventoryController controller = new FactoryInventoryController(); FactoryInventoryModel data = new FactoryInventoryModel(); var context = CreateMoqSetupForCookie(); controller.ControllerContext = new ControllerContext(context, new RouteData(), controller); // Act var result = (RedirectToRouteResult)controller.Delete(data); var resultFactoryInventoryModel = FactoryInventoryBackend.Instance.Create(data); // Reset FactoryInventoryBackend DataSourceBackend.Instance.Reset(); // Assert Assert.AreEqual("Index", result.RouteValues["action"], TestContext.TestName); Assert.AreEqual(data.Description, resultFactoryInventoryModel.Description, TestContext.TestName); }
public void Controller_FactoryInventory_Delete_IDValid_Should_Pass() { // Arrange FactoryInventoryController controller = new FactoryInventoryController(); FactoryInventoryModel data = new FactoryInventoryModel(); string id = Backend.FactoryInventoryBackend.Instance.Create(data).Id; var context = CreateMoqSetupForCookie(); controller.ControllerContext = new ControllerContext(context, new RouteData(), controller); // Act ViewResult result = controller.Delete(id) as ViewResult; var resultFactoryInventoryModel = result.Model as FactoryInventoryModel; // Reset FactoryInventoryBackend DataSourceBackend.Instance.Reset(); // Assert Assert.IsNotNull(resultFactoryInventoryModel, TestContext.TestName); }
public void Controller_FactoryInventory_Delete_Post_ModelIsInvalid_Should_Pass() { // Arrange FactoryInventoryController controller = new FactoryInventoryController(); FactoryInventoryModel data = new FactoryInventoryModel(); // Make ModelState Invalid controller.ModelState.AddModelError("test", "test"); var context = CreateMoqSetupForCookie(); controller.ControllerContext = new ControllerContext(context, new RouteData(), controller); // Act ViewResult result = controller.Delete(data) as ViewResult; // Reset FactoryInventoryBackend DataSourceBackend.Instance.Reset(); // Assert Assert.IsNotNull(result, TestContext.TestName); }
public void Controller_FactoryInventory_Delete_Post_Invalid_IDIsNull_Should_Return_Model() { // Arrange FactoryInventoryController controller = new FactoryInventoryController(); FactoryInventoryModel data = new FactoryInventoryModel { Id = null }; var context = CreateMoqSetupForCookie(); controller.ControllerContext = new ControllerContext(context, new RouteData(), controller); // Act ViewResult result = controller.Delete(data) as ViewResult; var resultFactoryInventoryModel = result.Model as FactoryInventoryModel; // Reset FactoryInventoryBackend DataSourceBackend.Instance.Reset(); // Assert Assert.AreEqual(data.Description, resultFactoryInventoryModel.Description, TestContext.TestName); }