public void GetByRoomWithInValidRoomIdReturnsNull() { // Arrange const int ROOM_ID = 1; var bookingManager = new BookingManager(); var bookingDao = MockRepository.GenerateMock<IBookingDao>(); bookingManager.BookingDao = bookingDao; bookingDao.Stub(b => b.GetByKey(ROOM_ID)).Return(null); // Act var bookingsReturnedByManager = bookingManager.GetByRoom(ROOM_ID); // Assert Assert.IsNull(bookingsReturnedByManager, "Bookings is not null."); }
public void GetByRoomExpectSuccess() { // Arrange const int BUSINESS_ID = 1; const int ROOM_ID = 1; var bookingManager = new BookingManager(); var bookingReturnedByDao = new Booking { Id = 1, BusinessId = BUSINESS_ID, BookingScenarioType = BookingScenarioTypeEnum.OnAccountBooking, BookingStatus = new EnumEntity { Code = BookingStatusType.CONFIRMED }, Guest = new Guest(), RoomId = ROOM_ID, RoomTypeId = 1, RatePlanId = 1, Cost = new decimal(10), StartDate = DateTime.UtcNow, EndDate = DateTime.UtcNow.AddDays(1), NumberOfAdults = 1 }; var bookingDao = MockRepository.GenerateMock<IBookingDao>(); bookingManager.BookingDao = bookingDao; bookingDao.Stub(b => b.GetByRoom(ROOM_ID)).Return(new List<Booking>{bookingReturnedByDao}); // Act var bookingsReturnedByManager = bookingManager.GetByRoom(ROOM_ID); // Assert Assert.IsNotNull(bookingsReturnedByManager, "Booking is null."); Assert.AreEqual(bookingReturnedByDao, bookingsReturnedByManager[0], "Bookings returned is incorrect."); }