public void CalculateIncome_CalculatesCorrectIncome(int awakeHours, int asleepHours, int postMidnightHours)
        {
            // Arrange
            var service = new PaymentCalculationService();

            // Act
            var expectedCalculatedIncome = (awakeHours * 12) + (asleepHours * 8) + (postMidnightHours * 16);
            var calculatedIncome         = service.CalculateIncome(awakeHours, asleepHours, postMidnightHours);

            // Assert
            Assert.Equal(expectedCalculatedIncome, calculatedIncome);
        }
        public void FixStartTime_HourBeforeFive_MakeStartTimeFive(string startTime)
        {
            // Arrange
            var originalStartTime = DateTime.Parse(startTime);
            var service           = new PaymentCalculationService();

            // Act
            var fixedStartTime = service.FixStartTime(originalStartTime);

            // Assert
            Assert.True(fixedStartTime.Hour == 17);
        }
        public void FixStartTime_HourAfterFive_DoesNotChangeStartTime(string startTime)
        {
            // Arrange
            var originalStartTime = DateTime.Parse(startTime);
            var service           = new PaymentCalculationService();


            // Act
            var fixedStartTime = service.FixStartTime(originalStartTime);

            // Assert
            Assert.True(fixedStartTime == originalStartTime);
        }
        public async Task <IActionResult> myControllerAction(ShiftInformation shiftInformation)
        {
            var paymentCalculationService = new PaymentCalculationService();
            var income = paymentCalculationService.CalculateAsync(shiftInformation);
            await Task.WhenAll(income);

            var data = new
            {
                income
            };

            return(Ok(data));
        }
        public void CalculateAwakeHours_BedTimeBeforeStartTime_DoesNotReturnNegativeHours(string startTime, string bedTime)
        {
            // Arrange
            var shiftInformation = new ShiftInformation();

            shiftInformation.StartTime = DateTime.Parse(startTime);
            shiftInformation.BedTime   = DateTime.Parse(bedTime);
            var service = new PaymentCalculationService();

            // Act
            var actualAwakeHours   = service.CalculateAwakeHours(shiftInformation);
            var expectedAwakeHours = (int)(shiftInformation.BedTime - shiftInformation.StartTime).TotalHours;

            if (expectedAwakeHours < 0)
            {
                expectedAwakeHours = 0;
            }

            Assert.Equal(expectedAwakeHours, actualAwakeHours);
        }
        public void CalculateAsleepHours_FractionalHours_OnlyCountsFullHours(string startTime, string bedTime)
        {
            // Arrange
            var shiftInformation = new ShiftInformation();

            shiftInformation.StartTime = DateTime.Parse(startTime);
            shiftInformation.BedTime   = DateTime.Parse(bedTime);
            var service = new PaymentCalculationService();

            // Act
            var actualAsleepHours   = service.CalculateAsleepHours(shiftInformation);
            var expectedAsleepHours = (int)(shiftInformation.StartTime.Date.AddDays(1) - shiftInformation.BedTime).TotalHours;

            if (expectedAsleepHours < 0)
            {
                expectedAsleepHours = 0;
            }

            Assert.Equal(expectedAsleepHours, actualAsleepHours);
        }