コード例 #1
0
        public void MakeSideBySideBookinForSameSpace()
        {
            // Arrange
            var booking_repository = new InMemoryBookingRepository();
            var response_handler   = new MakeBookingResponseHandler();
            var validator          = new BookingValidator();
            var booking_a          = new Booking {
                Id = 4, Name = "FirstName1 LastName1", Start = new DateTime(2018, 1, 1, 10, 0, 0), End = new DateTime(2018, 1, 1, 11, 0, 0), Space = new Space {
                    Name = "Boardroom"
                }
            };
            var booking_b = new Booking {
                Id = 5, Name = "FirstName1 LastName1", Start = new DateTime(2018, 1, 1, 11, 0, 0), End = new DateTime(2018, 1, 1, 12, 0, 0), Space = new Space {
                    Name = "Boardroom"
                }
            };

            var make_booking_interaction = new MakeBookingInteractor(response_handler, booking_repository, validator);

            make_booking_interaction.Booking = booking_a;

            // Act / Assert
            make_booking_interaction.Execute();

            Assert.IsTrue(response_handler.WasSuccessful);

            make_booking_interaction.Booking = booking_b;

            make_booking_interaction.Execute();

            Assert.IsTrue(response_handler.WasSuccessful);
        }
        public void AddAndRetrieveBooking()
        {
            var bookingRepository = new InMemoryBookingRepository();
            var hotelId           = Guid.NewGuid();
            var booking           = BookingBuilder.aBooking().WithHotelId(hotelId).WithRoomType(Standard).Build();

            bookingRepository.AddBooking(booking);
            Assert.Contains(booking, bookingRepository.GetBookings(hotelId, Standard));
        }
コード例 #3
0
        public void NotAvailableIfMaxExceeded()
        {
            using (var repo = new InMemoryBookingRepository())
            {
                var date      = new DateTime(2019, 3, 13);
                var checker   = new BookingChecker();
                var available = checker.CheckBookingAvailable(date, repo);

                Assert.IsFalse(available);
            }
        }
コード例 #4
0
        public void MakeANullBooking()
        {
            // Arrange
            var booking_repository       = new InMemoryBookingRepository();
            var response_handler         = new MakeBookingResponseHandler();
            var validator                = new BookingValidator();
            var make_booking_interaction = new MakeBookingInteractor(response_handler, booking_repository, validator);

            // Act
            make_booking_interaction.Execute();

            // Assert
            Assert.IsTrue(make_booking_interaction.Booking == null);
            Assert.IsTrue(response_handler.Exception != null);
            Assert.IsTrue(response_handler.Exception.GetType() == typeof(ArgumentException));
        }
コード例 #5
0
        public void MakeABookingWithoutAName()
        {
            // Arrange
            var booking_repository       = new InMemoryBookingRepository();
            var response_handler         = new MakeBookingResponseHandler();
            var validator                = new BookingValidator();
            var make_booking_interaction = new MakeBookingInteractor(response_handler, booking_repository, validator);

            make_booking_interaction.Booking = new Booking {
                Start = new DateTime(2018, 1, 1, 10, 0, 0), End = new DateTime(2018, 1, 1, 11, 0, 0), Space = new Space {
                    Name = "Boardroom"
                }
            };

            // Act
            make_booking_interaction.Execute();

            // Assert
            Assert.IsFalse(response_handler.WasSuccessful);
        }
コード例 #6
0
        public void GetBookingsForTodayWhenThereAreNone()
        {
            // Arrange
            var today              = new DateTime(2018, 1, 1, 10, 0, 0);
            var expected           = bookings.Where(booking => booking.Start.Date == today.Date || booking.End.Date == today.Date).ToList();
            var response_handler   = new GetBookingForDateResponseHandler();
            var booking_repository = new InMemoryBookingRepository();

            booking_repository.Bookings = bookings;
            var get_booking_for_date_interaction = new GetBookingForDateInteractor(response_handler, booking_repository);

            get_booking_for_date_interaction.Date = today;

            // Act
            get_booking_for_date_interaction.Execute();

            // Assert
            Assert.IsTrue(response_handler.Bookings.Count == 0);
            CollectionAssert.AreEqual(expected, response_handler.Bookings.ToList());
        }