Exemple #1
0
            public void CreateBookingWithNoPopulatedFieldsThrowsNullReferenceException()
            {
                // Arrange
                var booking = new Booking();
                var dao = new BookingDao();

                // Act
                dao.Create(booking, new Order());

                // Assert
                Assert.Fail("NullReferenceException was not thrown.");
            }
Exemple #2
0
            public void FillInGuestPhonesCallsDaoOnce()
            {
                var guestPhoneDao = new Mock<IGuestPhoneDao>();
                BookingDao bookingDao = new BookingDao
                    {
                        GuestPhoneDao = guestPhoneDao.Object
                    };
                IEnumerable<Booking> bookings = new List<Booking>()
                    {
                        new Booking
                        {
                            GuestId = 1,
                            Guest = new Guest() { GuestId = 1 }
                        },
                        new Booking
                        {
                            GuestId = 2,
                            Guest = new Guest() { GuestId = 1 }
                        }
                    };

                guestPhoneDao.Setup(gp => gp.GetAllByGuestIdList(It.IsAny<IEnumerable<int>>()))
                             .Returns(new List<GuestPhone>()
                                 {
                                     new GuestPhone {GuestId = 1},
                                     new GuestPhone {GuestId = 2}
                                 });

                bookingDao.FillInGuestPhones(bookings);

                Assert.IsTrue(bookings.ToList().TrueForAll(b => b.Guest.GuestPhones != null),
                              "Not all booking got phone numbers correctly");
                guestPhoneDao.Verify(gp => gp.GetAllByGuestIdList(It.IsAny<IEnumerable<int>>()), Times.Once);
            }
Exemple #3
0
            public void CreateConfirmedBookingPopulatesBookingId()
            {
                // Arrange
                var booking = new Booking
                {
                    BusinessId = 1,
                    Guest = new Guest
                    {
                        Id = 1,
                        Surname = "Test Guest",
                        Email = "*****@*****.**"
                    },
                    StartDate = new DateTime(2012, 2, 1, 0, 0, 0, DateTimeKind.Utc),
                    EndDate = new DateTime(2012, 2, 2, 0, 0, 0, DateTimeKind.Utc),
                    NumberOfAdults = 2,
                    NumberOfChildren = 1,
                    Cost = new decimal(120.5),
                    BookingStatus = new EnumEntity { Code = BookingStatusType.CONFIRMED },
                    RoomTypeId = 1,
                    RoomId = 1,
                    RatePlanId = 1,
                    Notes = "Testing note",
                    BookingScenarioType = BookingScenarioTypeEnum.OnAccountBooking,
                    RateType = new EnumEntity { Code = RateType.BEST_AVAILABLE_RATE },
                    CheckinStatus = new EnumEntity { Code = CheckinStatusOptions.NOTCHECKEDIN }
                };
                var dao = new BookingDao();

                // Act
                dao.Create(booking, new Order());

                // Assert
                Assert.IsNotNull(booking.Id, "The booking id was not attributed.");
            }
Exemple #4
0
            public void GetPropertyOfflineBookingsCountsExpectSuccess()
            {
                //arrange
                var startDate = new DateTime(2014, 2, 1, 0 ,0 ,0, DateTimeKind.Utc);
                var endDate = new DateTime(2014, 3, 1, 0 ,0 ,0, DateTimeKind.Utc);
                var bookingDao = new BookingDao();

                //act
                var counts = bookingDao.GetPropertyOfflineBookingsCounts(startDate, endDate, OfflineSourceEnum.Web);

                //assert
                Assert.IsNotNull(counts, "Counts object is null");
                Assert.AreEqual(1, counts.Count, "Wrong number of property offline booking counts");
                Assert.AreEqual(1, counts.First().OfflineBookingCount, "Wrong value of offline booking count");
                Assert.IsTrue(counts.All(c => c.PeriodDateTime == startDate), "All PeriodDateTime values should be equal to startDate");
            }