예제 #1
0
        public async Task CompliesWithRuleAsync_ReturnsTrue_WhenValuesAreValid()
        {
            var options = Options.Create(new ClubConfiguration {
                OpenHour = 9, CloseHour = 22
            });
            var sut = new ClubIsOpenRule(options);

            var result = await sut.CompliesWithRuleAsync(new Data.CourtBooking()
            {
                StartDateTime = new DateTime(2019, 01, 01, 10, 00, 00),
                EndDateTime   = new DateTime(2019, 01, 01, 12, 00, 00)
            });

            Assert.True(result);
        }
예제 #2
0
        public async Task CompliesWithRuleAsync_ReturnsFalse_WhenBookingStartsBeforeClubIsOpen()
        {
            var options = Options.Create(new ClubConfiguration {
                OpenHour = 9, CloseHour = 22
            });

            var sut = new ClubIsOpenRule(options);

            var result = await sut.CompliesWithRuleAsync(new Data.CourtBooking()
            {
                StartDateTime = new DateTime(2019, 01, 01, 08, 00, 00), // this is too early
                EndDateTime   = new DateTime(2019, 01, 01, 10, 00, 00)
            });

            Assert.False(result);
        }
        public async Task CompliesWithRuleAsync_ReturnsFalse_WhenValuesAreInvalid()
        {
            var mockOptions = new Mock <IOptions <ClubConfiguration> >();

            mockOptions.Setup(x => x.Value).Returns(new ClubConfiguration {
                OpenHour = 9, CloseHour = 22
            });

            var sut = new ClubIsOpenRule(mockOptions.Object);

            var result = await sut.CompliesWithRuleAsync(new Data.CourtBooking()
            {
                StartDateTime = new DateTime(2019, 01, 01, 10, 00, 00),
                EndDateTime   = new DateTime(2019, 01, 01, 23, 00, 00)
            });

            Assert.False(result);
        }