Esempio n. 1
0
        public static void Main(string[] args)
        {
            CreateHostBuilder(args).Build().Run();

            var employee = new Employee
            {
                Id        = 8001185051083,
                FirstName = "Stuart",
                Surname   = "Green",
                Age       = 40
            };

            var paySlipBuilder = new PaySlipBuilder(employee);

            paySlipBuilder.AddGrossSalary(40000);
            paySlipBuilder.AddMedicalAid(2500);
            paySlipBuilder.AddPension(5000);
            paySlipBuilder.AddParking(150);
            paySlipBuilder.AddVitality(250);

            var paySlip = paySlipBuilder.Build();
        }
        public void GetTotalBenefits_GivenBenefits_ReturnsCorrectTotal()
        {
            // Arrange
            var employee = new Employee
            {
                Age = 30
            };

            var paySlipBuilder = new PaySlipBuilder(employee);

            var expected = 5000m;

            paySlipBuilder.AddMedicalAid(2500m);

            paySlipBuilder.AddPension(5000m);

            // Act
            var paySlip = paySlipBuilder.Build();

            // Assert
            Assert.Equal(expected, paySlip.GetTotalBenefits());
        }
        public void GetCostToCompany_GivenGrossSalaryAndBenefits_ReturnsCorrectTotal()
        {
            // Arrange
            var employee = new Employee
            {
                Age = 30
            };

            var paySlipBuilder = new PaySlipBuilder(employee);

            var expected = 45000m;

            paySlipBuilder.AddGrossSalary(40000m);

            paySlipBuilder.AddMedicalAid(2500m);

            paySlipBuilder.AddPension(5000m);

            // Act
            var paySlip = paySlipBuilder.Build();

            // Assert
            Assert.Equal(expected, paySlip.GetCostToCompany());
        }