示例#1
0
        public void WhenSalaryNotSpecified_ThrowException()
        {
            // Arrange
            var   employeeId = new EmployeeId("foo");
            var   name       = new Name("f", "m", "l", "s", "t");
            var   address    = new FakeAddress();
            Money salary     = null;

            // Act
            Action action = () => SalaryEmployee.CreateNew(employeeId, name, address, salary);

            // Assert
            action.Should().Throw <EmployeeDomainException>().WithMessage("Employee salary must not be null.");
        }
示例#2
0
        public void CreateNew_CreatesSalaryEmployee()
        {
            // Arrange
            var employeeId = new EmployeeId("foo");
            var name       = new Name("bar", null, "bee", null, null);
            var address    = new FakeAddress();
            var salary     = new Money(new FakeCurrency(), new MoneyValue(100000m));

            // Act
            var employee = SalaryEmployee.CreateNew(employeeId, name, address, salary);

            // Assert
            employee.EmployeeId.Should().Be(employeeId);
            employee.Name.Should().Be(name);
            employee.Address.Should().Be(address);
            employee.Salary.Should().Be(salary);
        }
示例#3
0
        public void SalaryEmployees_WhenNotEqual_HaveDifferentHashCodes()
        {
            // Arrange
            var employee1 = SalaryEmployee.CreateNew(
                new EmployeeId("foo"),
                new Name("bar", null, "bee", null, null),
                new FakeAddress(),
                new Money(new FakeCurrency(), new MoneyValue(100000m)));

            var employee2 = SalaryEmployee.CreateNew(
                new EmployeeId("foo"),
                new Name("bar", null, "bee", null, null),
                new FakeAddress(),
                new Money(new FakeCurrency(), new MoneyValue(200000m)));

            // Act
            var hashCodesEqual = employee1.GetHashCode() == employee2.GetHashCode();

            // Assert
            hashCodesEqual.Should().BeFalse();
        }
示例#4
0
        public void SalaryEmployees_AreNotEqual()
        {
            // Arrange
            var employee1 = SalaryEmployee.CreateNew(
                new EmployeeId("foo"),
                new Name("bar", null, "bee", null, null),
                new FakeAddress(),
                new Money(new FakeCurrency(), new MoneyValue(100000m)));

            var employee2 = SalaryEmployee.CreateNew(
                new EmployeeId("foo"),
                new Name("bar", null, "bee", null, null),
                new FakeAddress(),
                new Money(new FakeCurrency(), new MoneyValue(200000m)));

            // Act
            var areEqual = employee1 == employee2;

            // Assert
            areEqual.Should().BeFalse();
        }