Ejemplo n.º 1
0
        public void CanUpdateEmployee()
        {
            EmployeeContext context = CreateInMemoryDB();
            int?            intResult;
            Employees       newEmployee = new Employees
            {
                Id        = 2,
                FirstName = "NewTestFName",
                LastName  = "NewTestLName",
                ManagerID = 1,
                LeaveDate = DateTime.Now.AddDays(-1),
                Salary    = 450
            };
            WebAPIUnitTest objWebAPIUnitTest = new WebAPIUnitTest();


            var service = new EmployeeService(context);

            intResult = service.Update(2, newEmployee);
            var empresult = service.Get(2);

            Assert.AreEqual(empresult.FirstName, newEmployee.FirstName);
            Assert.AreEqual(empresult.LastName, newEmployee.LastName);
            Assert.AreEqual(empresult.ManagerID, newEmployee.ManagerID);
            Assert.AreEqual(empresult.LeaveDate, newEmployee.LeaveDate);
            Assert.AreEqual(empresult.Salary, newEmployee.Salary);
            Assert.AreNotEqual(intResult, 0);
        }
        public void CanReturnEmployeebyName()
        {
            WebAPIUnitTest objWebAPIUnitTest = new WebAPIUnitTest();

            var context = objWebAPIUnitTest.CreateInMemoryDB("EmployeesDB");
            var service = new EmployeeService(context);
            var result  = service.GetEmployeesbyName("Testc");

            Assert.AreEqual("Testc", result.FirstName);
        }
        public void CandeleteEmployee()
        {
            WebAPIUnitTest objWebAPIUnitTest = new WebAPIUnitTest();

            var context = objWebAPIUnitTest.CreateInMemoryDB("EmployeesDB");
            var service = new EmployeeService(context);
            var id      = service.Delete(2);
            var result  = service.GetAll();

            Assert.AreEqual(2, result.Count());
        }
        public void CanUpdateSalary()
        {
            int            rowupdated;
            WebAPIUnitTest objWebAPIUnitTest = new WebAPIUnitTest();

            var context = objWebAPIUnitTest.CreateInMemoryDB("EmployeesDB");
            var service = new EmployeeService(context);

            rowupdated = service.UpdateSalary(3, 600);
            var result = service.Get(3);

            Assert.AreEqual(600, result.Salary);
        }
        public void CanUpdateLeaveDate()
        {
            int            rowupdated;
            WebAPIUnitTest objWebAPIUnitTest = new WebAPIUnitTest();

            var context = objWebAPIUnitTest.CreateInMemoryDB("EmployeesDB");
            var service = new EmployeeService(context);

            rowupdated = service.UpdateLeaveDate(3, DateTime.Now.AddDays(-3));
            var result = service.Get(3);

            Assert.AreEqual(DateTime.Now.AddDays(-3).Date, result.LeaveDate.Date);
        }
Ejemplo n.º 6
0
        public void CanInsertEmployee()
        {
            int?            Result;
            EmployeeContext context     = CreateInMemoryDB();
            Employees       newEmployee = new Employees
            {
                Id        = 5,
                FirstName = "Teste",
                LastName  = "TesteLName",
                ManagerID = 1,
                LeaveDate = DateTime.Now,
                Salary    = 900
            };
            WebAPIUnitTest objWebAPIUnitTest = new WebAPIUnitTest();

            var service = new EmployeeService(context);

            Result = service.Add(newEmployee);
            Assert.IsNotNull(newEmployee);
            var result = service.GetAll();

            Assert.AreEqual(5, result.Count());
        }