コード例 #1
0
        public void WhenHorlyRateNotSpecified_ThrowException()
        {
            // Arrange
            var    employeeId = new EmployeeId("foo");
            var    name       = new Name("bar", null, "hee", null, null);
            var    address    = new FakeAddress();
            Action action     = () => HourlyEmployee.CreateNew(employeeId, name, address, null);

            // Act & Assert
            action.Should().Throw <EmployeeDomainException>().WithMessage("Hourly rate must not be null.");
        }
コード例 #2
0
        public void CreateNew_CreatesHourlyEmployee()
        {
            // Arrange
            var employeeId = new EmployeeId("foo");
            var name       = new Name("bar", null, "hee", null, null);
            var address    = new FakeAddress();
            var rate       = new HourlyRate(new HourlyRateValue(110m));

            // Act
            var employee = HourlyEmployee.CreateNew(employeeId, name, address, rate);

            // Assert
            employee.EmployeeId.Should().Be(employeeId);
            employee.Name.Should().Be(name);
            employee.Address.Should().Be(address);
            employee.Rate.Should().Be(rate);
        }
コード例 #3
0
        public void HourlyEmployees_WhenNotEqual_HaveDifferentHashCodes()
        {
            // Arrange
            var employeeId = new EmployeeId("foo");
            var name       = new Name("bar", null, "hee", null, null);
            var address    = new FakeAddress();
            var rate1      = new HourlyRate(new HourlyRateValue(100m));
            var rate2      = new HourlyRate(new HourlyRateValue(110m));

            var employee1 = HourlyEmployee.CreateNew(employeeId, name, address, rate1);
            var employee2 = HourlyEmployee.CreateNew(employeeId, name, address, rate2);

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

            // Assert
            hashCodesEqual.Should().BeFalse();
        }
コード例 #4
0
        public void HourlyEmployees_AreNotEqual()
        {
            // Arrange
            var employeeId = new EmployeeId("foo");
            var name       = new Name("bar", null, "hee", null, null);
            var address    = new FakeAddress();
            var rate1      = new HourlyRate(new HourlyRateValue(100m));
            var rate2      = new HourlyRate(new HourlyRateValue(110m));

            var employee1 = HourlyEmployee.CreateNew(employeeId, name, address, rate1);
            var employee2 = HourlyEmployee.CreateNew(employeeId, name, address, rate2);

            // Act
            var areEqual = employee1 == employee2;

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