createEmployee() public method

public createEmployee ( ) : System.Web.Mvc.ActionResult
return System.Web.Mvc.ActionResult
コード例 #1
0
 public void createEmployeeTest()
 {
     //Arrange
     var controller = new AdminEmployeeController(new EmployeeBLL(new EmployeeDALStub()), new UserBLL(new UserDALStub()), new LoggingBLL(new LoggingDALStub()));
     //Act
     var result = (ViewResult)controller.createEmployee();
     //Assert
     Assert.AreEqual(result.ViewName, "");
 }
コード例 #2
0
 public void createEmployeeTestEmployeeAddFail()
 {
     //Arrange
     var context = new Mock<ControllerContext>();
     var session = new Mock<HttpSessionStateBase>();
     context.Setup(m => m.HttpContext.Session).Returns(session.Object);
     var controller = new AdminEmployeeController(new EmployeeBLL(new EmployeeDALStub()), new UserBLL(new UserDALStub()), new LoggingBLL(new LoggingDALStub()));
     controller.ControllerContext = context.Object;
     var employeeModel = new EmployeeModel();
     employeeModel.employeeID = 1;
     employeeModel.firstName = "";
     employeeModel.lastName = "Nordmann";
     employeeModel.phone = "12345678";
     employeeModel.orderAdmin = true;
     employeeModel.customerAdmin = false;
     employeeModel.databaseAdmin = false;
     employeeModel.employeeAdmin = false;
     employeeModel.password = "******";
     employeeModel.productAdmin = false;
     employeeModel.username = "";
     //Act
     var result = (ViewResult)controller.createEmployee(employeeModel);
     var resultModel = (EmployeeModel)result.Model;
     //Assert
     Assert.AreEqual(result.ViewName, "");
     Assert.AreEqual(employeeModel.firstName, resultModel.firstName);
     Assert.AreEqual(employeeModel.customerAdmin, resultModel.customerAdmin);
     Assert.AreEqual(employeeModel.databaseAdmin, resultModel.databaseAdmin);
     Assert.AreEqual(employeeModel.employeeAdmin, resultModel.employeeAdmin);
     Assert.AreEqual(employeeModel.employeeID, resultModel.employeeID);
     Assert.AreEqual(employeeModel.lastName, resultModel.lastName);
     Assert.AreEqual(employeeModel.orderAdmin, resultModel.orderAdmin);
     Assert.AreEqual(employeeModel.password, resultModel.password);
     Assert.AreEqual(employeeModel.phone, resultModel.phone);
     Assert.AreEqual(employeeModel.username, resultModel.username);
 }
コード例 #3
0
 public void createEmployeeTestTrue()
 {
     //Arrange
     var context = new Mock<ControllerContext>();
     var session = new Mock<HttpSessionStateBase>();
     context.Setup(m => m.HttpContext.Session).Returns(session.Object);
     var controller = new AdminEmployeeController(new EmployeeBLL(new EmployeeDALStub()), new UserBLL(new UserDALStub()), new LoggingBLL(new LoggingDALStub()));
     controller.ControllerContext = context.Object;
     var employeeModel = new EmployeeModel();
     employeeModel.employeeID = 1;
     employeeModel.firstName = "Ola";
     employeeModel.lastName = "Nordmann";
     employeeModel.phone = "12345678";
     employeeModel.customerAdmin = false;
     employeeModel.databaseAdmin = false;
     employeeModel.orderAdmin = true;
     employeeModel.employeeAdmin = false;
     employeeModel.password = "******";
     employeeModel.productAdmin = false;
     employeeModel.username = "";
     //Act
     var result = (RedirectToRouteResult)controller.createEmployee(employeeModel);
     //Assert
     Assert.AreEqual(result.RouteName, "");
     Assert.AreEqual(result.RouteValues.Values.First(), "AllEmployees");
 }
コード例 #4
0
 public void createEmployeeTestNotValid()
 {
     //Arrange
     var controller = new AdminEmployeeController(new EmployeeBLL(new EmployeeDALStub()), new UserBLL(new UserDALStub()), new LoggingBLL(new LoggingDALStub()));
     controller.ViewData.ModelState.AddModelError("feil", "testfeil");
     //Act
     var result = (ViewResult)controller.createEmployee(new EmployeeModel());
     //Assert
     Assert.AreEqual(result.ViewName, "");
     Assert.IsTrue(result.ViewData.ModelState.Count == 1);
 }