예제 #1
0
        public void IsReturnExpectedList_ShowStructure_Directsubordination()
        {
            // Arrange
            IOrganizationService   testService = new OrganizationService();
            EmployeeModel          root        = new EmployeeModel("root", "root", 100000, "root");
            EmployeeModel          employee1   = new EmployeeModel("employee1", "employee1", 90000, "employee1");
            WorkerModel            worker1     = new WorkerModel("worker1", "worker1", 20000, "worker1");
            WorkerModel            worker      = new WorkerModel("worker", "worker", 10000, "worker");
            List <PersonComponent> expected    = new List <PersonComponent>()
            {
            };

            expected.Add(root);
            expected.Add(employee1);
            expected.Add(worker1);
            expected.Add(worker);
            // Act
            testService.AddRoot(root);
            testService.AddWorker(worker);
            testService.AddEmployee(employee1);
            testService.AddWorker(worker1);

            // Assert
            List <PersonComponent> actual = testService.ShowStructure(StrategyOption.Directsubordination);

            CollectionAssert.AreEqual(expected, actual);
        }
예제 #2
0
        public void IsAddingNeededElement_IsWorkerAdded()
        {
            // Arrange
            IOrganizationService testService = new OrganizationService();

            testService.AddRoot(new EmployeeModel("root", "root", 1, "root"));
            WorkerModel expected = new WorkerModel("testsurname", "testname", 1000, "testposition");

            // Act
            testService.AddWorker(new WorkerModel("testsurname", "testname", 1000, "testposition"));

            // Assert
            WorkerModel actual = (WorkerModel)testService.CurrentEmployee.Subordinates.Find(x => x.Surname == "testsurname" && x.Name == "testname" && x.Salary == 1000 && x.Position == "testposition");

            Assert.AreEqual(expected, actual);
        }
예제 #3
0
        public void IsReturnExpectedList_PositionEmployees()
        {
            // Arrange
            IOrganizationService   testService = new OrganizationService();
            EmployeeModel          root        = new EmployeeModel("root", "root", 100000, "root");
            EmployeeModel          employee1   = new EmployeeModel("employee1", "employee1", 90000, "employee1");
            WorkerModel            worker1     = new WorkerModel("worker1", "worker1", 20000, "worker1");
            List <PersonComponent> expected    = new List <PersonComponent>();

            expected.Add(employee1);
            // Act
            testService.AddRoot(root);
            testService.AddEmployee(employee1);
            testService.AddWorker(worker1);

            // Assert
            List <PersonComponent> actual = testService.PositionEmployees("employee1");

            CollectionAssert.AreEqual(expected, actual);
        }