コード例 #1
0
        public void ValidateEmployees_ThrowsException_WhenSomeManagersAreNotListed()
        {
            List <Employee> employees = new List <Employee>
            {
                Employee.Create("Employee1", "Employee2", 100),
                Employee.Create("Employee2", "Employee3", 100)
            };
            EmployeesServices services = new EmployeesServices(employees);

            services.ValidateEmployees();
            Assert.False(services.IsValid);
            Assert.Contains(services.ValidationErrors, m => m.Message == "Some Managers not listed");
        }
コード例 #2
0
        public void ValidateEmployees_ThrowsException_WhenTheresMoreThanOneCeo()
        {
            List <Employee> employees = new List <Employee>
            {
                Employee.Create("Employee1", null, 100),
                Employee.Create("Employee2", "", 100)
            };
            EmployeesServices services = new EmployeesServices(employees);

            services.ValidateEmployees();
            Assert.False(services.IsValid);
            Assert.Contains(services.ValidationErrors, m => m.Message == "More than one CEO listed");
        }
コード例 #3
0
        public void ValidateEmployees_ThrowsException_WhenEmployeesHaveCyclicReference()
        {
            List <Employee> employees = new List <Employee>
            {
                Employee.Create("Employee0", "", 100),
                Employee.Create("Employee2", "Employee1", 100),
                Employee.Create("Employee1", "Employee2", 100)
            };
            EmployeesServices services = new EmployeesServices(employees);

            services.ValidateEmployees();
            Assert.False(services.IsValid);
            Assert.Contains(services.ValidationErrors, m => m.Message == "Cyclic Reference detected");
        }
コード例 #4
0
        public void ValidateEmployees_ThrowsException_WhenEmployeeHasMoreThanOneManager()
        {
            List <Employee> employees = new List <Employee>
            {
                Employee.Create("Employee1", "", 100),
                Employee.Create("Employee2", "Employee1", 100),
                Employee.Create("Employee3", "Employee1", 100),
                Employee.Create("Employee3", "Employee2", 100)
            };
            EmployeesServices services = new EmployeesServices(employees);

            services.ValidateEmployees();
            Assert.False(services.IsValid);
            Assert.Contains(services.ValidationErrors, m => m.Message == "Employee Employee3 has more than one manager");
        }