public void ShouldReturn_NewFinancier()
        {
            var financierAgent = new ExternalAgent(Guid.NewGuid(), AgentType.Financier);

            Financier financier = new Financier
                                  (
                financierAgent,
                OrganizationName.Create("First Bank and Trust"),
                PhoneNumber.Create("555-555-5555"),
                IsActive.Create(true),
                new Guid("660bb318-649e-470d-9d2b-693bfb0b2744")
                                  );

            Assert.IsType <Financier>(financier);
        }
        public Financier(ExternalAgent agent, OrganizationName name, PhoneNumber telephone, IsActive isActive, Guid userID)
        {
            ExternalAgent = agent ?? throw new ArgumentNullException("The external agent is required.");

            Id            = agent.Id;
            FinancierName = name ?? throw new ArgumentNullException("The financier name parameter is required.");
            Telephone     = telephone ?? throw new ArgumentNullException("The telephone parameter is required.");
            IsActive      = isActive ?? throw new ArgumentNullException("The is active parameter is required.");

            if (userID == default)
            {
                throw new ArgumentNullException("The user id (employee creating this record) parameter is required.");
            }
            UserId = userID;
        }
        public void ShouldRaiseError_NewFinancier_WithInvalidExternalAgentType()
        {
            var agent = new ExternalAgent(Guid.NewGuid(), AgentType.Employee);

            Assert.Throws <InvalidOperationException>(() =>
            {
                Financier financier = new Financier
                                      (
                    agent,
                    OrganizationName.Create("First Bank and Trust"),
                    PhoneNumber.Create("555-555-5555"),
                    IsActive.Create(true),
                    new Guid("660bb318-649e-470d-9d2b-693bfb0b2744")
                                      );
            });
        }
        /**     Helper methods     **/
        private Employee GetEmployee()
        {
            var employeeAgent = new ExternalAgent(Guid.NewGuid(), AgentType.Employee);

            return(new Employee
                   (
                       employeeAgent,
                       SupervisorId.Create(Guid.NewGuid()),
                       PersonName.Create("George", "Orwell", "Z"),
                       SSN.Create("123789999"),
                       PhoneNumber.Create("817-987-1234"),
                       MaritalStatus.Create("M"),
                       TaxExemption.Create(5),
                       PayRate.Create(40.00M),
                       StartDate.Create(new DateTime(1998, 12, 2)),
                       IsActive.Create(true)
                   ));
        }
        public Employee(ExternalAgent agent, SupervisorId supervisorId, PersonName name, SSN ssn, PhoneNumber telephone,
                        MaritalStatus maritalStatus, TaxExemption exemption, PayRate payRate, StartDate startDate, IsActive isActive)
            : this()
        {
            ExternalAgent = agent ?? throw new ArgumentNullException("The external agent is required.");
            Id            = agent.Id;
            SupervisorId  = supervisorId ?? throw new ArgumentNullException("The supervisor id paramater is required.");
            EmployeeName  = name ?? throw new ArgumentNullException("The employee name parameter is required.");
            SSN           = ssn ?? throw new ArgumentNullException("The SSN parameter is required.");
            Telephone     = telephone ?? throw new ArgumentNullException("The telephone parameter is required.");
            MaritalStatus = maritalStatus ?? throw new ArgumentNullException("The marital status parameter is required.");
            TaxExemption  = exemption ?? throw new ArgumentNullException("The tax exemption parameter is required.");
            PayRate       = payRate ?? throw new ArgumentNullException("The pay rate parameter is required.");
            StartDate     = startDate ?? throw new ArgumentNullException("The start date parameter is required.");
            IsActive      = isActive ?? throw new ArgumentNullException("The is active parameter is required.");

            CheckValidity();
        }
        public void ShouldReturn_NewEmployee()
        {
            var employeeAgent = new ExternalAgent(Guid.NewGuid(), AgentType.Employee);

            Employee employee = new Employee
                                (
                employeeAgent,
                SupervisorId.Create(employeeAgent.Id),
                PersonName.Create("Ken", "Sanchez", "J"),
                SSN.Create("123789999"),
                PhoneNumber.Create("817-987-1234"),
                MaritalStatus.Create("M"),
                TaxExemption.Create(5),
                PayRate.Create(40.00M),
                StartDate.Create(new DateTime(1998, 12, 2)),
                IsActive.Create(true)
                                );

            Assert.IsType <Employee>(employee);
        }
        private DomainUser GetUser()
        {
            var agent = new ExternalAgent(Guid.NewGuid(), AgentType.Employee);

            Employee employee = new Employee
                                (
                agent,
                SupervisorId.Create(agent.Id),
                PersonName.Create("Ken", "Sanchez", "J"),
                SSN.Create("123789999"),
                PhoneNumber.Create("817-987-1234"),
                MaritalStatus.Create("M"),
                TaxExemption.Create(5),
                PayRate.Create(40.00M),
                StartDate.Create(new DateTime(1998, 12, 2)),
                IsActive.Create(true)
                                );

            return(new DomainUser(agent.Id, "Jon", "Doe", ""));
        }
        public void ShouldRaiseError_SupervisorIdParamIsNull()
        {
            var employeeAgent = new ExternalAgent(Guid.NewGuid(), AgentType.Employee);

            Action action = () => new Employee
                            (
                employeeAgent,
                null,
                PersonName.Create("Ken", "Sanchez", "J"),
                SSN.Create("123789999"),
                PhoneNumber.Create("817-987-1234"),
                MaritalStatus.Create("M"),
                TaxExemption.Create(5),
                PayRate.Create(40.00M),
                StartDate.Create(new DateTime(1998, 12, 2)),
                IsActive.Create(true)
                            );

            var caughtException = Assert.Throws <ArgumentNullException>(action);

            Assert.Contains("The supervisor id paramater is required.", caughtException.Message);
        }
        private Employee GetEmployeeWithContactPeople()
        {
            var employeeAgent = new ExternalAgent(Guid.NewGuid(), AgentType.Employee);
            var employee      = new Employee
                                (
                employeeAgent,
                SupervisorId.Create(Guid.NewGuid()),
                PersonName.Create("George", "Orwell", "Z"),
                SSN.Create("123789999"),
                PhoneNumber.Create("817-987-1234"),
                MaritalStatus.Create("M"),
                TaxExemption.Create(5),
                PayRate.Create(40.00M),
                StartDate.Create(new DateTime(1998, 12, 2)),
                IsActive.Create(true)
                                );

            employee.AddContactPerson(1, PersonName.Create("Fidel", "Castro", "C"), PhoneNumber.Create("555-555-1234"), "You are being tested.");
            employee.AddContactPerson(2, PersonName.Create("Fidel", "Raul", "Z"), PhoneNumber.Create("555-555-5678"), "You are not being tested.");

            return(employee);
        }
        private Employee GetEmployeeWithAddresses()
        {
            var employeeAgent = new ExternalAgent(Guid.NewGuid(), AgentType.Employee);
            var employee      = new Employee
                                (
                employeeAgent,
                SupervisorId.Create(Guid.NewGuid()),
                PersonName.Create("George", "Orwell", "Z"),
                SSN.Create("123789999"),
                PhoneNumber.Create("817-987-1234"),
                MaritalStatus.Create("M"),
                TaxExemption.Create(5),
                PayRate.Create(40.00M),
                StartDate.Create(new DateTime(1998, 12, 2)),
                IsActive.Create(true)
                                );

            employee.AddAddress(1, AddressVO.Create("123 Main Terrace", "#4", "Somewhere", "TX", "78885"));
            employee.AddAddress(2, AddressVO.Create("123 Main Plaza", "Apt 13", "nowhere", "TX", "78981"));

            return(employee);
        }
 public void DeleteAddress(int addressId) => ExternalAgent.DeleteAddress(addressId);
 public void UpdateAddress(int addressId, AddressVO address) => ExternalAgent.UpdateAddress(addressId, address);
 public void AddAddress(int addressId, AddressVO address) => ExternalAgent.AddAddress(addressId, address);
 public void DeleteContactPerson(int personId) => ExternalAgent.DeleteContactPerson(personId);
 public void UpdateContactPerson(int personId, PersonName name, PhoneNumber telephone, string notes)
 => ExternalAgent.UpdateContactPerson(personId, name, telephone, notes);
        public void ShouldReturn_ValidExternalAgent()
        {
            var result = new ExternalAgent(Guid.NewGuid(), AgentType.Employee);

            Assert.IsType <ExternalAgent>(result);
        }