コード例 #1
0
        public async Task Should_Throw_Exception_Given_TimeEntry_Greater_Than_TimeExit()
        {
            var service   = new ParkingFeeCalculator(new InMemoryRepository(new InMemoryStore()));
            var timeEntry = DateTime.Now;
            var timeExit  = timeEntry.AddHours(-2);

            Func <Task> act = async() => await service.GetFeeAmount(timeEntry, timeExit);

            await act.Should()
            .ThrowAsync <ProcessException>()
            .WithMessage("Exit time is greater than entry time.");
        }
コード例 #2
0
        public async Task Should_Return_ExpectedFeeAmount_Given_TimeEntry_And_TimeExit(TestData testData)
        {
            var service   = new ParkingFeeCalculator(new InMemoryRepository(new InMemoryStore()));
            var timeEntry = DateTime.Now.DayOfTheWeek(testData.DayOfWeek)
                            .AddHours((double)testData.Duration.Min);
            var timeExit = DateTime.Now.DayOfTheWeek(testData.DayOfWeek)
                           .AddHours((double)testData.Duration.Max);

            var feeAmount = await service.GetFeeAmount(timeEntry, timeExit);

            feeAmount.Should().Be(testData.ExpectedPrice);
        }
コード例 #3
0
        public async Task Should_Throw_Exception_Given_No_DefaultFlatRate()
        {
            var store = new InMemoryStore();

            store.DefaultFlatRates.Clear();
            var repository = new InMemoryRepository(store);
            var service    = new ParkingFeeCalculator(repository);
            var timeEntry  = DateTime.Parse("2020-07-07").AddHours(10);
            var timeExit   = timeEntry.AddHours(4);

            Func <Task> act = async() => await service.GetFeeAmount(timeEntry, timeExit);

            await act.Should().ThrowAsync <ProcessException>().WithMessage("Internal data error.");
        }