public void AddEmployeeTest() { // Arrange. IEmployeeFactory empFactory = new EmployeeFactory(); IDBContext dbContext = new DBContext(); EmployeeModel employee = new EmployeeModel() { EmployeeId = 200, EmployeeName = "B", Department = "IT" }; // Act. dbContext.AddEmployee(empFactory.GetEmployeeFromModel(employee)); // Assert. List <Employee> employees = dbContext.GetEmployees().ToList(); Assert.IsNotNull(employees); Assert.AreEqual(101, employees.Count); }
public void GetEmployeeFromEmployeeModelTest() { // Arrage EmployeeModel empModel = new EmployeeModel() { EmployeeId = 1, EmployeeName = "A", Department = "R&D" }; // Act. EmployeeFactory empFactory = new EmployeeFactory(); var emp = empFactory.GetEmployeeFromModel(empModel); // Assert. Assert.IsNotNull(emp); Assert.IsInstanceOfType(emp, typeof(Employee)); Assert.AreEqual(empModel.EmployeeId, emp.EmployeeId); Assert.AreEqual(empModel.EmployeeName, emp.EmployeeName); Assert.AreEqual(empModel.Department, emp.Department); }