public void EditTestOK() { //Arrange var context = new Mock<ControllerContext>(); var session = new Mock<HttpSessionStateBase>(); context.Setup(m => m.HttpContext.Session).Returns(session.Object); var controller = new AdminCustomerController(new CustomerBLL(new CustomerDALStub()), new LoggingBLL(new LoggingDALStub())); controller.ControllerContext = context.Object; var customerModel = new CustomerModel(); customerModel.customerID = 1; customerModel.firstName = "Ola"; customerModel.lastName = "Nordmann"; customerModel.payAdress = "Osloveien 1"; customerModel.payProvince = "Oslo"; customerModel.payZipcode = "1234"; customerModel.phone = "12345678"; customerModel.province = "Oslo"; customerModel.sameAdresses = true; customerModel.zipCode = "1234"; customerModel.adress = "Osloveien 1"; //Act var result = (ViewResult)controller.Edit(1); var resultModel = (CustomerModel)result.Model; //Assert Assert.AreEqual(result.ViewName, ""); Assert.AreEqual(resultModel.adress, customerModel.adress); Assert.AreEqual(resultModel.customerID, customerModel.customerID); Assert.AreEqual(resultModel.email, customerModel.email); Assert.AreEqual(resultModel.firstName, customerModel.firstName); Assert.AreEqual(resultModel.lastName, customerModel.lastName); Assert.AreEqual(resultModel.password, customerModel.password); Assert.AreEqual(resultModel.payAdress, customerModel.payAdress); Assert.AreEqual(resultModel.payProvince, customerModel.payProvince); Assert.AreEqual(resultModel.payZipcode, customerModel.payZipcode); Assert.AreEqual(resultModel.phone, customerModel.phone); Assert.AreEqual(resultModel.sameAdresses, customerModel.sameAdresses); Assert.AreEqual(resultModel.zipCode, customerModel.zipCode); Assert.AreEqual(resultModel.province, customerModel.province); }
public void EditTestFalse() { //Arrange var controller = new AdminCustomerController(new CustomerBLL(new CustomerDALStub()), new LoggingBLL(new LoggingDALStub())); //Act var result = (ViewResult)controller.Edit(-1); //Assert Assert.AreEqual(result.ViewName, ""); }