public void VisitEmployeeLeaf(EmployeeLeaf employeeLeaf)
 {
     if (employeeLeaf is null)
     {
         throw new ArgumentNullException(nameof(employeeLeaf));
     }
 }
        public void EmployeeComposite_GetEnumerator_AllSuboridinatesShouldBeReturned()
        {
            // Arrange
            var subordinate1 = new EmployeeLeaf(SubordinatedEmployee1);
            var subordinate2 = new EmployeeLeaf(SubordinatedEmployee2);

            employeeComposite.Add(subordinate1);
            employeeComposite.Add(subordinate2);

            var enumerator = employeeComposite.GetEnumerator();

            enumerator.MoveNext();

            List <EmployeeComponent> expected = new List <EmployeeComponent> {
                subordinate1, subordinate2
            };
            List <EmployeeComponent> result = new List <EmployeeComponent>();

            // Act
            while (enumerator.MoveNext())
            {
                result.Add(enumerator.Current);
            }

            // Assert
            result.Should().BeEquivalentTo(expected);
        }
        public EmployeeEntitiesTests()
        {
            mockVisitor = new Mock <IEmployeeVisitor>();

            employeeLeaf      = new EmployeeLeaf(Employee);
            employeeComposite = new EmployeeComposite(Employee);
            employeeFactory   = new EmployeeComponentFactory();
        }
Exemplo n.º 4
0
        public void EmployeeWithSuperiorVisitor_VisitEmployeeLeaf_NullEmployeeCompositeShouldRaiseException()
        {
            // Arrange
            EmployeeLeaf employeeLeaf = null;

            // Act
            Action act = () => employeeWithSuperiorVisitor.VisitEmployeeLeaf(employeeLeaf);

            // Assert
            ArgumentNullException exception = Assert.Throws <ArgumentNullException>(act);

            Assert.Equal(nameof(employeeLeaf), exception.ParamName);
        }
Exemplo n.º 5
0
        public void EmployeeMaxSalaryVisitor_VisitEmployeeComponent_WhenListEmptyAnyEmployeeShouldAdded()
        {
            // Arrange
            var exposedVisitor = Exposed.From(employeeMaxSalaryVisitor);

            EmployeeComponent employeeComponent = new EmployeeLeaf(SubordinatedEmployee1);

            List <IEmployee> expectedList = new List <IEmployee> {
                SubordinatedEmployee1
            };

            // Act
            exposedVisitor.VisitEmployeeComponent(employeeComponent);
            List <IEmployee> result = exposedVisitor.EmployeesWithMaxSalary;

            // Assert
            result.Should().BeEquivalentTo(expectedList);
        }
Exemplo n.º 6
0
        public void EmployeeMaxSalaryVisitor_VisitEmployeeComponent_WhenListHasElementWithTheSameSalaryAsCurrentShouldAddBoth()
        {
            // Arrange
            var exposedVisitor = Exposed.From(employeeMaxSalaryVisitor);

            EmployeeComponent employeeComponent1 = new EmployeeLeaf(SubordinatedEmployee1);
            EmployeeComponent employeeComponent2 = new EmployeeLeaf(SubordinatedEmployee1);

            List <IEmployee> expectedList = new List <IEmployee> {
                SubordinatedEmployee1, SubordinatedEmployee1
            };

            // Act
            exposedVisitor.VisitEmployeeComponent(employeeComponent1);
            exposedVisitor.VisitEmployeeComponent(employeeComponent2);
            List <IEmployee> result = exposedVisitor.EmployeesWithMaxSalary;

            // Assert
            result.Should().BeEquivalentTo(expectedList);
        }
Exemplo n.º 7
0
        public void EmployeeMaxSalaryVisitor_VisitEmployeeComponent_WhenListHasElementWithTheBiggerSalaryThanCurrentShouldNotAddSmaller()
        {
            // Arrange
            var exposedVisitor = Exposed.From(employeeMaxSalaryVisitor);

            EmployeeComponent biggerEmployeeComponent1  = new EmployeeLeaf(SubordinatedEmployee1);
            EmployeeComponent smallerEmployeeComponent2 = new EmployeeLeaf(SubordinatedEmployee2);

            List <IEmployee> expectedList = new List <IEmployee> {
                SubordinatedEmployee1
            };

            // Act
            exposedVisitor.VisitEmployeeComponent(biggerEmployeeComponent1);
            exposedVisitor.VisitEmployeeComponent(smallerEmployeeComponent2);

            List <IEmployee> result = exposedVisitor.EmployeesWithMaxSalary;

            // Assert
            result.Should().BeEquivalentTo(expectedList);
        }
Exemplo n.º 8
0
 public void VisitEmployeeLeaf(EmployeeLeaf employeeLeaf)
 {
     VisitEmployeeComponent(employeeLeaf);
 }