Example #1
0
        public void SetUp()
        {
            DateTime testStart       = new DateTime(2018, 7, 6, 14, 0, 0);
            DateTime testEnd         = new DateTime(2018, 7, 6, 20, 0, 0);
            int      testCostPerHour = 10;

            var paymentBoundary = new PaymentBoundary(testStart, testEnd, testCostPerHour);

            DateTime testStart2       = new DateTime(2018, 7, 6, 20, 0, 0);
            DateTime testEnd2         = new DateTime(2018, 7, 6, 22, 0, 0);
            int      testCostPerHour2 = 20;

            var paymentBoundary2 = new PaymentBoundary(testStart2, testEnd2, testCostPerHour2);

            DateTime testStart3       = new DateTime(2018, 7, 6, 22, 0, 0);
            DateTime testEnd3         = new DateTime(2018, 7, 7, 4, 0, 0);
            int      testCostPerHour3 = 30;

            var paymentBoundary3 = new PaymentBoundary(testStart3, testEnd3, testCostPerHour3);

            boundaries = new List <PaymentBoundary>
            {
                { paymentBoundary },
                { paymentBoundary2 },
                { paymentBoundary3 }
            };

            sut = new PaymentCalculator(boundaries);
        }
Example #2
0
        private IWorkers CreateBabysitter()
        {
            DateTime testStart       = new DateTime(2018, 7, 6, 14, 0, 0);
            DateTime testEnd         = new DateTime(2018, 7, 6, 20, 0, 0);
            int      testCostPerHour = 10;

            var paymentBoundary = new PaymentBoundary(testStart, testEnd, testCostPerHour);

            DateTime testStart2       = new DateTime(2018, 7, 6, 20, 0, 0);
            DateTime testEnd2         = new DateTime(2018, 7, 6, 22, 0, 0);
            int      testCostPerHour2 = 20;

            var paymentBoundary2 = new PaymentBoundary(testStart2, testEnd2, testCostPerHour2);

            DateTime testStart3       = new DateTime(2018, 7, 6, 22, 0, 0);
            DateTime testEnd3         = new DateTime(2018, 7, 7, 4, 0, 0);
            int      testCostPerHour3 = 30;

            var paymentBoundary3 = new PaymentBoundary(testStart3, testEnd3, testCostPerHour3);

            var boundaries = new List <PaymentBoundary>
            {
                { paymentBoundary },
                { paymentBoundary2 },
                { paymentBoundary3 }
            };

            var calculator = new PaymentCalculator.PaymentCalculator(boundaries);

            return(new Babysitter(calculator));
        }
Example #3
0
        public void BoundaryCreation()
        {
            PaymentBoundary sut = new PaymentBoundary(testStartTime, testEndTime, testCost);

            Assert.AreEqual(sut.GetCostPerHour(), testCost);
            Assert.AreEqual(sut.GetEndBoundary(), testEndTime);
            Assert.AreEqual(sut.GetStartBoundary(), testStartTime);
        }
Example #4
0
        public void ModifyBoundary()
        {
            var newStartTime = new DateTime(2018, 7, 6, 14, 0, 0);
            var newEndTime   = new DateTime(2018, 7, 7, 14, 30, 0);
            var newCost      = 10;

            PaymentBoundary sut = new PaymentBoundary(testStartTime, testEndTime, testCost);

            sut.SetCostPerHour(newCost);
            sut.SetEndBoundary(newEndTime);
            sut.SetStartBoundary(newStartTime);

            Assert.AreEqual(sut.GetCostPerHour(), newCost);
            Assert.AreEqual(sut.GetEndBoundary(), newEndTime);
            Assert.AreEqual(sut.GetStartBoundary(), newStartTime);
        }
Example #5
0
        public void CanGetTheTotalPaymentOfWorkedHoursInFourBoundaries()
        {
            DateTime testStart       = new DateTime(2018, 7, 6, 15, 0, 0);
            DateTime testEnd         = new DateTime(2018, 7, 6, 20, 0, 0);
            int      testCostPerHour = 10;

            var paymentBoundary = new PaymentBoundary(testStart, testEnd, testCostPerHour);

            DateTime testStart2       = new DateTime(2018, 7, 6, 20, 0, 0);
            DateTime testEnd2         = new DateTime(2018, 7, 7, 0, 0, 0);
            int      testCostPerHour2 = 10;

            var paymentBoundary2 = new PaymentBoundary(testStart2, testEnd2, testCostPerHour2);

            DateTime testStart3       = new DateTime(2018, 7, 7, 0, 0, 0);
            DateTime testEnd3         = new DateTime(2018, 7, 7, 2, 0, 0);
            int      testCostPerHour3 = 10;

            var paymentBoundary3 = new PaymentBoundary(testStart3, testEnd3, testCostPerHour3);

            DateTime testStart4       = new DateTime(2018, 7, 7, 2, 0, 0);
            DateTime testEnd4         = new DateTime(2018, 7, 7, 4, 0, 0);
            int      testCostPerHour4 = 10;

            var paymentBoundary4 = new PaymentBoundary(testStart4, testEnd4, testCostPerHour4);

            boundaries = new List <PaymentBoundary>
            {
                { paymentBoundary },
                { paymentBoundary2 },
                { paymentBoundary3 },
                { paymentBoundary4 }
            };

            sut = new PaymentCalculator(boundaries);

            var startTime = new DateTime(2018, 7, 6, 15, 0, 0);
            var endTime   = new DateTime(2018, 7, 7, 4, 0, 0);

            var expectedPayment = 130;

            var payment = sut.GetPayment(startTime, endTime);

            Assert.AreEqual(expectedPayment, payment);
        }
Example #6
0
        private IWorkers CreateLawnCare()
        {
            DateTime testStart       = new DateTime(2018, 7, 6, 12, 0, 0);
            DateTime testEnd         = new DateTime(2018, 7, 6, 16, 0, 0);
            int      testCostPerHour = 1;

            var paymentBoundary = new PaymentBoundary(testStart, testEnd, testCostPerHour);

            DateTime testStart2       = new DateTime(2018, 7, 6, 16, 0, 0);
            DateTime testEnd2         = new DateTime(2018, 7, 6, 20, 0, 0);
            int      testCostPerHour2 = 2;

            var paymentBoundary2 = new PaymentBoundary(testStart2, testEnd2, testCostPerHour2);

            DateTime testStart3       = new DateTime(2018, 7, 6, 20, 0, 0);
            DateTime testEnd3         = new DateTime(2018, 7, 7, 0, 0, 0);
            int      testCostPerHour3 = 3;

            var paymentBoundary3 = new PaymentBoundary(testStart3, testEnd3, testCostPerHour3);

            DateTime testStart4       = new DateTime(2018, 7, 6, 0, 0, 0);
            DateTime testEnd4         = new DateTime(2018, 7, 7, 4, 0, 0);
            int      testCostPerHour4 = 4;

            var paymentBoundary4 = new PaymentBoundary(testStart4, testEnd4, testCostPerHour4);

            var boundaries = new List <PaymentBoundary>
            {
                { paymentBoundary },
                { paymentBoundary2 },
                { paymentBoundary3 },
                { paymentBoundary4 }
            };

            var calculator = new PaymentCalculator.PaymentCalculator(boundaries);

            return(new LawnCare(calculator));
        }