public void TestGetEmployeeByName()
        {
            OnSetUp();
            var employeeBuilder = new EmployeeBuilder().SetName(Name);

            _employeeRepository.AddEmployees(new List <Employee> {
                employeeBuilder.CreateEmployee()
            });
            var result = _employeeController.Get(Name);

            var correctEmployee = employeeBuilder.CreateEmployee();

            Assert.IsTrue(EmployeesAreEqual(correctEmployee, result.Employees.First()));
            Assert.IsTrue(result.Success);
        }
Beispiel #2
0
        public void TestDeleteEmployees()
        {
            onSetUp();
            var employeeBuilder = new EmployeeBuilder().setName(NAME);

            employeeRepository.AddEmployees(new List <Employee>()
            {
                employeeBuilder.CreateEmployee()
            });

            var removeEmployeeRequest = new RemoveEmployeeRequest()
            {
                Name = NAME
            };

            employeeController.Delete(removeEmployeeRequest);

            try
            {
                employeeController.Get(NAME);
                Assert.Fail("Expected exception to be thrown.");
            }
            catch (NoSuchEntityException e)
            {
                Assert.IsTrue(e.Message.Contains(NAME));
            }
        }
Beispiel #3
0
        public void TestGetEmployeesByWarehouseId()
        {
            onSetUp();
            var employeeBuilderA = new EmployeeBuilder().setWarehouseId(WAREHOUSE_ID).setName("A");
            var employeeBuilderB = new EmployeeBuilder().setWarehouseId(WAREHOUSE_ID).setName("B");

            employeeRepository.AddEmployees(new List <Employee>()
            {
                employeeBuilderA.CreateEmployee(), employeeBuilderB.CreateEmployee()
            });
            var result = employeeController.Get(WAREHOUSE_ID).Employees.ToList();

            var correctEmployeeA = employeeBuilderA.CreateEmployee();
            var correctEmployeeB = employeeBuilderB.CreateEmployee();

            Assert.IsTrue(result.Count == 2);
            Assert.IsTrue(EmployeesAreEqual(correctEmployeeA, result.First()));
            Assert.IsTrue(EmployeesAreEqual(correctEmployeeB, result.Last()));
        }
Beispiel #4
0
        public void TestAddEmployees()
        {
            onSetUp();
            var employeeBuilder     = new EmployeeBuilder().setName(NAME);
            var addEmployeesRequest = employeeBuilder.CreateAddEmployeesRequest();

            var response               = employeeController.Post(addEmployeesRequest);
            var databaseEmployee       = employeeRepository.GetEmployeeByName(NAME);
            var correctDatabaseEmploye = employeeBuilder.CreateEmployee();

            Assert.IsTrue(response.Success);
            Assert.IsTrue(EmployeesAreEqual(new Employee(databaseEmployee), correctDatabaseEmploye));
        }
        public void TestAddDuplicateEmployee()
        {
            OnSetUp();
            var employeeBuilder = new EmployeeBuilder().SetName(Name);

            _employeeRepository.AddEmployees(new List <Employee> {
                employeeBuilder.CreateEmployee()
            });
            var addEmployeesRequest = employeeBuilder.CreateAddEmployeesRequest();

            try
            {
                _employeeController.Post(addEmployeesRequest);
                Assert.Fail("Expected exception to be thrown.");
            }
            catch (Exception)
            {
                Assert.IsTrue(true);
            }
        }
Beispiel #6
0
        public void TestAddDuplicateEmployee()
        {
            onSetUp();
            var employeeBuilder = new EmployeeBuilder().setName(NAME);

            employeeRepository.AddEmployees(new List <Employee>()
            {
                employeeBuilder.CreateEmployee()
            });
            var addEmployeesRequest = employeeBuilder.CreateAddEmployeesRequest();

            try
            {
                employeeController.Post(addEmployeesRequest);
            }
            catch (Exception)
            {
                Assert.IsTrue(false); //means that we could not add a dup, so fail the test
            }
            Assert.IsTrue(true);
        }