public void Controller_Shop_Edit_Data_Valid_Position_Wheels_Should_Pass() { // Arrange ShopController controller = new ShopController(); var data = new ShopTruckInputModel { StudentId = DataSourceBackend.Instance.StudentBackend.GetDefault().Id, ItemId = DataSourceBackend.Instance.FactoryInventoryBackend.GetDefaultTruckFullItem(FactoryInventoryCategoryEnum.Wheels).Id, Position = FactoryInventoryCategoryEnum.Wheels }; // Get the Student Record var myStudent = DataSourceBackend.Instance.StudentBackend.Read(data.StudentId); var expect = myStudent.Truck.Wheels; // select item var mySelect = (RedirectToRouteResult)controller.Edit(data); // Act ViewResult result = controller.Edit(data) as ViewResult; var myStudent2 = DataSourceBackend.Instance.StudentBackend.Read(data.StudentId); DataSourceBackend.Instance.Reset(); // Assert Assert.AreEqual(expect, myStudent2.Truck.Wheels, TestContext.TestName); }
public void Controller_Shop_Edit_Valid_StudentID_Should_Fail() { // Arrange ShopController controller = new ShopController(); var data = DataSourceBackend.Instance.StudentBackend.GetDefault(); // Act var result = controller.Edit(data.Id) as ViewResult; // Assert Assert.IsNotNull(result, TestContext.TestName); }
public void Controller_Shop_Edit_Invalid_StudentID_Should_Fail() { // Arrange ShopController controller = new ShopController(); // Act var result = controller.Edit("bogus") as RedirectToRouteResult; // Assert Assert.AreEqual("Error", result.RouteValues["action"], TestContext.TestName); Assert.AreEqual("Home", result.RouteValues["controller"], TestContext.TestName); }
public void Controller_Shop_Edit_Data_Invalid_Should_Fail() { // Arrange ShopController controller = new ShopController(); ShopTruckInputModel data = new ShopTruckInputModel(); data = null; // Act var result = (RedirectToRouteResult)controller.Edit(data); // Assert Assert.AreEqual("Error", result.RouteValues["action"], TestContext.TestName); }
public void Controller_Shop_Edit_Post_ModelIsInvalid_Should_Pass() { // Arrange ShopController controller = new ShopController(); ShopTruckInputModel data = new ShopTruckInputModel(); // Make ModelState Invalid controller.ModelState.AddModelError("test", "test"); // Act ViewResult result = controller.Edit(data) as ViewResult; // Assert Assert.AreEqual(controller.ModelState.IsValid, false, TestContext.TestName); }
public void Controller_Shop_Edit_Data_Invalid_ItemId_Bogus_Should_Fail() { // Arrange ShopController controller = new ShopController(); var data = new ShopTruckInputModel { StudentId = DataSourceBackend.Instance.StudentBackend.GetDefault().Id, ItemId = "bogus" }; // Act var result = (RedirectToRouteResult)controller.Edit(data); // Assert Assert.AreEqual("Index", result.RouteValues["action"], TestContext.TestName); }
public void Controller_Shop_Edit_Valid_Truck_Null_Should_Fail() { // Arrange ShopController controller = new ShopController(); var data = DataSourceBackend.Instance.StudentBackend.GetDefault(); data.Truck = null; // Act var result = controller.Edit(data.Id) as RedirectToRouteResult; //reset DataSourceBackend.Instance.Reset(); // Assert Assert.AreEqual("Error", result.RouteValues["action"], TestContext.TestName); Assert.AreEqual("Home", result.RouteValues["controller"], TestContext.TestName); }