Esempio n. 1
0
            public void ModifyRoomExpectSuccessUpdate()
            {
                // Arrange
                var updatedRoom = new Room { Name = "TestUserName", IsAvailableOnline = true, RoomStatusCode = "X", BusinessId = VALID_BUSINESS_ID, Id = VALID_ROOM_ID };
                var mockRoomDao = MockRepository.GenerateMock<IRoomDao>();
                mockRoomDao.Expect(
                    rd =>
                    rd.GetByName(Arg<string>.Is.Equal(updatedRoom.Name), Arg<long>.Is.Equal(updatedRoom.BusinessId)))
                           .Return(new Room {Id = updatedRoom.Id});

                var mockBusinessEventDao = MockRepository.GenerateMock<IEventTrackingManager>();
                IBookingManager bookingManager = MockRepository.GenerateMock<IBookingManager>();
                bookingManager.Expect(bm => bm.GetByRoom(Arg<int>.Is.Equal(VALID_ROOM_ID), Arg<string>.Is.Anything))
                              .Return(new List<Booking>
                                          {
                                              // booking in past
                                              new Booking
                                              {
                                                  EndDate = DateTime.UtcNow.AddDays(-5),
                                                  StartDate = DateTime.UtcNow.AddDays(-15)
                                              }
                                          });

                mockRoomDao.Expect(rt => rt.Modify(updatedRoom)).Return(true);
                mockBusinessEventDao.Expect(be => be.CreateBusinessEventAsync(VALID_BUSINESS_ID, BusinessEventTypesEnum.RoomModified, updatedRoom.Id.ToString(CultureInfo.DefaultThreadCurrentCulture)));

                var roomManager = new RoomManager
                {
                    RoomDao = mockRoomDao,
                    EventTrackingManager = mockBusinessEventDao,
                    BookingManager = bookingManager
                };

                // Act
                roomManager.Modify(updatedRoom);

                // Assert
                mockRoomDao.VerifyAllExpectations();
                mockBusinessEventDao.VerifyAllExpectations();
                bookingManager.VerifyAllExpectations();
            }
Esempio n. 2
0
 /// <summary>
 /// Constructor to intiailize required classes and variables
 /// </summary>
 public AigIntegratorService()
 {
     queryTransactionOptions = new TransactionOptions
                               {
                                   Timeout = new TimeSpan(0, 0, 0, 1000),
                                   IsolationLevel = IsolationLevel.ReadCommitted
                               };
     currentTransactionScope = TransactionScopeOption.Required;
     businessManager = new BusinessManager();
     distributorChannelDao = new DistributorChannelDao();
     roomTypeManager = new RoomTypeManager();
     roomManager = new RoomManager();
     rateCacheManager = new RateCacheManager();
     supplyPartnerId = FileConfiguration.ReadAppSetting<Guid>("eviivo.Eagle.EagleESPId");
     supplyPartnerShortName = FileConfiguration.ReadAppSetting<string>("eviivo.Eagle.EagleESPName");
 }
Esempio n. 3
0
            protected override void RunBeforeAllTests()
            {
                base.RunBeforeAllTests();

                var businessManager = new BusinessManager();
                var roomTypeManager = new RoomTypeManager();
                var roomManager = new RoomManager();
                var orderManager = new OrderManager();


                //Create a business
                var paymentMethod = new BusinessPaymentMethod
                    {
                        BusinessId = BUSINESS_ID,
                        CurrencyCode = CURRENCY,
                        PaymentMethodCode = PaymentMethodEnum.Cash.GetCode()
                    };

                var provider = new Provider
                    {
                        RoomCount = ROOM_COUNT,
                        ContentId = BUSINESS_ID.ToString(),
                        ProviderTypeCode = PROVIDER_TYPE,
                    };

                var business = new Model.Business.Business
                    {
                        BusinessStatusCode = "A",
                        BusinessTypeCode = "P",
                        Name = "Test Business",
                        ShortName = "Test",
                        ReferenceCode = "B001",
                        IsTaxRegistered = true,
                        TaxRegistrationNumber = "12345",
                        BusinessRegistrationNumber = "12345",
                        AddressLine1 = "5 Main Road",
                        AddressLine2 = "Twickenham",
                        City = "London",
                        StateProvinceId = 386,
                        PostCode = "TW2 5SE",
                        CountryId = 16,
                        BusinessTelephoneNumber = "07448752114",
                        TimeZoneId = 36,
                        DefaultCultureCode = CULTURE,
                        WorkingCurrencyCode = CURRENCY,
                        UpdatedByUserId = new Guid("11111111-1111-1111-1111-111111111111"),
                        Provider = provider,
                        BusinessPaymentMethods = new List<BusinessPaymentMethod> {paymentMethod}
                    };

                var businessId = businessManager.CreateBusiness(business);


                // Create a room type
                
                var ratePlan = new BaseRatePlan
                    {
                        BusinessId = businessId,
                        CurrencyCode = CURRENCY,
                        MaxAdults = 2,
                        MaxChildren = 2,
                        MaxOccupancy = 3,
                        BoardBasis = new EnumEntity {Code = "BK"},
                        CancellationClass = new EnumEntity {Code = "FR"},
                        RackRate = new decimal(120.0),
                        SellAtRackRate = true,
                        RatePlanType = new RatePlanType {Type = RatePlanTypeEnum.Base},
                        Rates = new RatePlanRate{BusinessId = businessId, MonRate = 120, MonMinStay = 120},
                        UpdatedByUserId = new Guid("11111111-1111-1111-1111-111111111111"),
                    };

                var roomType = new RoomType
                    {
                        BusinessId = businessId,
                        RoomClass = roomTypeManager.GetRoomClasses(CULTURE).FirstOrDefault(),      //new RoomClass { Code = "DBL" },
                        QualityType = roomTypeManager.GetQualityTypes(CULTURE).FirstOrDefault(),   //new QualityType { Code = "APT" },
                        BathroomType = roomTypeManager.GetBathroomTypes(CULTURE).FirstOrDefault(), //new BathroomType { Code = "SP" },
                        Code = "DBL99",
                        ServiceFrequency = new EnumEntity { Code = "B" },
                        UpdatedByUserId = new Guid("11111111-1111-1111-1111-111111111111"),
                        BaseRatePlan = ratePlan,
                        BaseRatePlanId = ratePlan.Id,
                        Aspect = new Aspect { Code = "BAL"},                    
                    };
                
                roomTypeManager.CreateRoomTypeAndBaseRatePlan(roomType);
                roomType = roomTypeManager.GetRoomTypesAndBaseRatePlans(businessId, CULTURE).First();
                ratePlan = roomType.BaseRatePlan;


                //Create a room
                var roomId = roomManager.CreateRoom("TestRoom", roomType.Id, businessId);


                //Create an order
                var booking = new Booking
                {
                    BusinessId = businessId,
                    Guest = new Guest { DefaultCultureCode = CULTURE, Surname = "TestSurname", BusinessId = businessId },
                    StartDate = new DateTime(2014, 2, 10, 0, 0, 0, DateTimeKind.Utc),
                    EndDate = new DateTime(2014, 2, 12, 0, 0, 0, DateTimeKind.Utc),
                    NumberOfAdults = 2,
                    NumberOfChildren = 1,
                    Cost = new decimal(120.5),
                    BookingStatus = new EnumEntity { Code = BookingStatusType.CONFIRMED },
                    RoomTypeId = roomType.Id,
                    RoomId = roomId,
                    RatePlanId = ratePlan.Id,
                    Notes = "Testing note",
                    BookingScenarioType = BookingScenarioTypeEnum.OnAccountBooking,
                    RateType = new EnumEntity { Code = RateType.BEST_AVAILABLE_RATE },
                    CheckinStatus = new EnumEntity { Code = CheckinStatusOptions.NOTCHECKEDIN },
                    IsAvailabilityIgnored = true,
                    BoardBasis = BoardBasisTypeEnum.BreakfastIncluded,
                    CancellationDetails = new CancellationDetail()
                };

                var order = new Order
                {
                    OfflineSourceEnum = OfflineSourceEnum.Web,
                    OrderSourceCode = SourceType.Pms.GetCode(),
                    CustomerCurrencyCode = CURRENCY,
                    Bookings = new List<Booking> { booking },
                    CustomerCultureCode = "en-GB"
                };
                
                // Mock email manager so it doesn't send emails
                var emailManager = new Mock<IEmailManager>();
                orderManager.EmailManager = emailManager.Object;

                emailManager.Setup(x => x.SendConfirmationEmails(order)).Returns(true);

                orderManager.CreateOrder(businessId, order);
            }
Esempio n. 4
0
            public void ModifyRoomWithNullRoomExpectExceptionThrown()
            {
                // Arrange
              var roomManager = new RoomManager();

                try
                {
                    // Act
                    roomManager.Modify(null);

                    // Assert
                    Assert.Fail("An exception SRVEX30068 of type ValidationException should have been thrown");
                }
                catch (ValidationException ex)
                {
                    // Assert
                    Assert.AreEqual(Errors.SRVEX30068.ToString(), ex.Code,
                                    "The Validation exception is not returning the right error code");
                }
            }
Esempio n. 5
0
            public void CreateRoomOfDeletedRoomUpdatesStatusAndRoomType()
            {
                // Arrange
                const string EXISTING_ROOM_NAME = "Room A";
                const int BUSINESS_ID = 1003;
                const int ROOM_TYPE_ID = 234;
                const int UPDATED_ROOM_TYPE_ID = 345;
                const int ROOM_ID = 5;

                var roomManager = new RoomManager();
                var mockRoom = new Model.Room.Room
                                   {
                                       Id = ROOM_ID,
                                       BusinessId = BUSINESS_ID,
                                       RoomTypeId = ROOM_TYPE_ID,
                                       Name = EXISTING_ROOM_NAME,
                                       RoomStatusCode = RoomStatusCodes.DELETED
                                   };

                var roomDao = MockRepository.GenerateStub<IRoomDao>();
                roomDao.Stub(r => r.GetByName(EXISTING_ROOM_NAME, BUSINESS_ID)).Return(mockRoom).Repeat.Twice();
                roomDao.Stub(r => r.Modify(Arg<Model.Room.Room>.Matches(rm => rm.Id == ROOM_ID &&
                                                                              rm.BusinessId == BUSINESS_ID &&
                                                                              rm.RoomTypeId == UPDATED_ROOM_TYPE_ID &&
                                                                              rm.Name == EXISTING_ROOM_NAME))).Return(true).Repeat.Once();
                roomManager.RoomDao = roomDao;
                
                var bookingManagerMock = MockRepository.GenerateMock<IBookingManager>();
                bookingManagerMock.Expect(bm => bm.GetByRoom(Arg<int>.Is.Equal(ROOM_ID), Arg<string>.Is.Anything)).Return(new List<Booking>()).Repeat.Once();
                roomManager.BookingManager = bookingManagerMock;

                var businessEventDao = MockRepository.GenerateStub<IEventTrackingManager>();
                businessEventDao.Expect(b => b.CreateBusinessEventAsync(Arg<long>.Is.Equal(BUSINESS_ID), Arg<BusinessEventTypesEnum>.Is.Equal(BusinessEventTypesEnum.RoomModified), Arg<string>.Is.Anything, Arg<string>.Is.Anything));
                roomManager.EventTrackingManager = businessEventDao;

                // Act
                int createdRoomId = roomManager.CreateRoom(EXISTING_ROOM_NAME, UPDATED_ROOM_TYPE_ID, BUSINESS_ID);

                // Assert
                Assert.AreEqual(ROOM_ID, createdRoomId, "Created room id of deleted room should have been returned");
                businessEventDao.VerifyAllExpectations();
                roomDao.VerifyAllExpectations();
                bookingManagerMock.VerifyAllExpectations();
            }  
Esempio n. 6
0
            public void CreateRoomNameShouldNotbeEmpty()
            {
                // Arrange
                string existingRoomName = string.Empty;
                const int BUSINESS_ID = 1003;
                const int ROOM_TYPE_ID = 234;

                var roomManager = new RoomManager();

                try
                {
                    // Act
                    roomManager.CreateRoom(existingRoomName, ROOM_TYPE_ID, BUSINESS_ID);

                    // Assert
                    Assert.Fail("An exception SRVEX30086 of type ValidationException should have been thrown");
                }
                catch (ValidationException ex)
                {
                    // Assert
                    Assert.AreEqual("SRVEX30086", ex.Code, "The Validation exception is not returning the right error code");
                }
            }
Esempio n. 7
0
            public void CreateRoomWithExistingNameInBusinessThrowException()
            {
                // Arrange
                const string EXISTING_ROOM_NAME = "Room A";
                const int BUSINESS_ID = 1003;
                const int ROOM_TYPE_ID = 234;

                var roomManager = new RoomManager();

                var roomDao = MockRepository.GenerateStub<IRoomDao>();
                roomDao.Stub(r => r.GetByName(EXISTING_ROOM_NAME, BUSINESS_ID)).Return(new Model.Room.Room
                    {
                        Name = EXISTING_ROOM_NAME,
                        RoomStatusCode = RoomStatusCodes.ACTIVE
                    });

                roomManager.RoomDao = roomDao;

                var businessEventDao = MockRepository.GenerateStub<IEventTrackingManager>();
                roomManager.EventTrackingManager = businessEventDao;

                try
                {
                    // Act
                    roomManager.CreateRoom(EXISTING_ROOM_NAME, ROOM_TYPE_ID, BUSINESS_ID);

                    // Assert
                    Assert.Fail("An exception SRVEX30085 of type ValidationException should have been thrown");
                }
                catch (ValidationException ex)
                {
                    // Assert
                    Assert.AreEqual("SRVEX30085", ex.Code, "The Validation exception is not returning the right error code");
                }
            }
Esempio n. 8
0
            public void CreateRoomCreatesBusinessEventTest()
            {
                // Arrange
                const string ROOM_NAME = "Room 1";
                const int BUSINESS_ID = 1003;
                const int ROOM_TYPE_ID = 234;

                var roomManager = new RoomManager();

                var businessEventDao = MockRepository.GenerateMock<IEventTrackingManager>();
                businessEventDao.Expect(b => b.CreateBusinessEventAsync(Arg<long>.Is.Equal(BUSINESS_ID), Arg<BusinessEventTypesEnum>.Is.Equal(BusinessEventTypesEnum.RoomAdded), Arg<string>.Is.Anything, Arg<string>.Is.Anything));
                roomManager.EventTrackingManager = businessEventDao;

                var roomDao = MockRepository.GenerateStub<IRoomDao>();
                roomManager.RoomDao = roomDao;

                // Act
                roomManager.CreateRoom(ROOM_NAME, ROOM_TYPE_ID, BUSINESS_ID);

                // Assert
                businessEventDao.VerifyAllExpectations();
            }
Esempio n. 9
0
            public void CreateRoomCallsDaoWithRoomDataPopulatedAccordinglyTest()
            {
                // Arrange
                const string ROOM_NAME = "Room 1";
                const int BUSINESS_ID = 1003;
                const int ROOM_TYPE_ID = 234;

                var roomManager = new RoomManager();

                var roomDao = MockRepository.GenerateMock<IRoomDao>();
                roomDao.Expect(r => r.Create(Arg<Room>.Matches(ro => ro.BusinessId == BUSINESS_ID 
                    && ro.Name == ROOM_NAME
                    && ro.IsAvailableOnline == true
                    && ro.IsCombined == false
                    && ro.RoomStatusCode == RoomStatusCodes.ACTIVE))); 
                roomManager.RoomDao = roomDao;

                var businessEventDao = MockRepository.GenerateStub<IEventTrackingManager>();
                roomManager.EventTrackingManager = businessEventDao;

                // Act
                roomManager.CreateRoom(ROOM_NAME, ROOM_TYPE_ID, BUSINESS_ID);

                // Assert
                roomDao.VerifyAllExpectations();
            }
Esempio n. 10
0
            public void GetByRoomType()
            {
                // Arrange
                const int ROOM_TYPE_ID = 123;
                const long BUSINESS_ID = 1003;

                var roomManager = new RoomManager();

                var roomDao = MockRepository.GenerateStub<IRoomDao>();
                roomDao.Expect(r => r.GetByRoomTypeId(Arg<int>.Is.Equal(ROOM_TYPE_ID), Arg<long>.Is.Equal(BUSINESS_ID))).Return(new List<Model.Room.Room>());

                roomManager.RoomDao = roomDao;

                // Act
                List<Model.Room.Room> rooms = roomManager.GetRoomsByBusinessRoomType(ROOM_TYPE_ID, BUSINESS_ID);

                // Assert
                Assert.IsNotNull(rooms, "empty list should have been returned");
                roomDao.VerifyAllExpectations();
            }
Esempio n. 11
0
            public void GetByKey()
            {
                // Arrange
                const int ROOM_ID = 123;
                const int BUSINESS_ID = 1003;

                var roomManager = new RoomManager();

                var roomDao = MockRepository.GenerateStub<IRoomDao>();
                roomDao.Stub(r => r.GetByKey(ROOM_ID, BUSINESS_ID)).Return(new Room {Id = ROOM_ID, BusinessId = BUSINESS_ID});

                roomManager.RoomDao = roomDao;

                // Act
                var room = roomManager.GetByKey(ROOM_ID, BUSINESS_ID);

                // Assert
                Assert.IsNotNull(room, "Room should not be null");

            }
Esempio n. 12
0
            public void DeleteRoomWithForwardBookingsStartDateThrowsException()
            {
                // Arrange
                Room roomToDelete = new Room
                {
                    Id = VALID_ROOM_ID,
                    BusinessId = VALID_BUSINESS_ID,
                    Name = "Name"
                };

                IBookingManager bookingManager = MockRepository.GenerateMock<IBookingManager>();
                bookingManager.Expect(bm => bm.GetByRoom(Arg<int>.Is.Equal(VALID_ROOM_ID), Arg<string>.Is.Anything))
                              .Return(new List<Booking>
                                          {
                                              new Booking
                                              {
                                                  EndDate = DateTime.UtcNow.AddDays(15),
                                                  StartDate = DateTime.UtcNow.AddDays(5)
                                              }
                                          });

                RoomManager roomManager = new RoomManager
                {
                    BookingManager = bookingManager
                };

                try
                {
                    // Act
                    roomManager.Delete(roomToDelete.Id, roomToDelete.BusinessId);
                    Assert.Fail("Validation exception should have been thrown");
                }
                catch (ValidationException vex)
                {
                    // Assert
                    Assert.AreEqual(Errors.SRVEX30097.ToString(), vex.Code,
                                    "Validation exception SRVEX30097 should have been thrown because of bookings");
                    bookingManager.VerifyAllExpectations();
                }
            }
Esempio n. 13
0
            public void DeleteRoomWithInvalidBusinessdExpectExceptionThrown()
            {
                // Arrange
                const long BUSINESS_ID = 0;
                const int ROOM_ID = 1;
                var roomManager = new RoomManager();

                try
                {
                    // Act
                    roomManager.Delete(ROOM_ID, BUSINESS_ID);

                    // Assert
                    Assert.Fail("An exception SRVEX30075 of type ValidationException should have been thrown");
                }
                catch (ValidationException ex)
                {
                    // Assert
                    Assert.AreEqual(Errors.SRVEX30075.ToString(), ex.Code,
                                    "The Validation exception is not returning the right error code");
                }
            }
Esempio n. 14
0
            public void DeleteRoomExpectSuccess()
            {
                // Arrange
                const long BUSINESS_ID = 1;
                const int ROOM_ID = 1;
                var mockRoomDao = MockRepository.GenerateMock<IRoomDao>();
                var mockBusinessEventDao = MockRepository.GenerateMock<IEventTrackingManager>();
                IBookingManager mockBookingManager = MockRepository.GenerateMock<IBookingManager>();
                mockBookingManager.Expect(bm => bm.GetByRoom(Arg<int>.Is.Equal(ROOM_ID), Arg<string>.Is.Anything))
                              .Return(new List<Booking>
                                          {
                                              // booking in past
                                              new Booking
                                              {
                                                  EndDate = DateTime.UtcNow.AddDays(-5),
                                                  StartDate = DateTime.UtcNow.AddDays(-15)
                                              }
                                          });

                mockRoomDao.Expect(rt => rt.Delete(ROOM_ID)).Return(true);
                mockBusinessEventDao.Expect(be => be.CreateBusinessEventAsync(BUSINESS_ID, BusinessEventTypesEnum.RoomDeleted, ROOM_ID.ToString(CultureInfo.DefaultThreadCurrentCulture)));

                var roomManager = new RoomManager 
                { 
                    RoomDao = mockRoomDao, 
                    EventTrackingManager = mockBusinessEventDao,
                    BookingManager = mockBookingManager
                };
                
                // Act
                roomManager.Delete(ROOM_ID,BUSINESS_ID);

                // Assert
                mockRoomDao.VerifyAllExpectations();
                mockBusinessEventDao.VerifyAllExpectations();
            }
Esempio n. 15
0
            public void ModifyRoomWithExistingNameInBusinessThrowsException()
            {
                // Arrange
                const string EXISTING_ROOM_NAME = "Room A";

                var updatedRoom = new Room { Name = EXISTING_ROOM_NAME, IsAvailableOnline = true, RoomStatusCode = "X", BusinessId = VALID_BUSINESS_ID, Id = VALID_ROOM_ID };
                var mockRoomDao = MockRepository.GenerateMock<IRoomDao>();
                mockRoomDao.Stub(r => r.GetByName(EXISTING_ROOM_NAME, VALID_BUSINESS_ID)).Return(new Model.Room.Room
                    {
                        Id = VALID_ROOM_ID + 1,
                        BusinessId = VALID_BUSINESS_ID,
                        Name = EXISTING_ROOM_NAME,
                        RoomStatusCode = RoomStatusCodes.ACTIVE
                    });
                IBookingManager bookingManager = MockRepository.GenerateMock<IBookingManager>();
                //verify this isn't called
                bookingManager.Expect(bm => bm.GetByRoom(Arg<int>.Is.Equal(VALID_ROOM_ID), Arg<string>.Is.Anything))
                              .Return(new List<Booking>()).Repeat.Never();

                var roomManager = new RoomManager 
                { 
                    RoomDao = mockRoomDao, 
                    BookingManager = bookingManager
                };

                try
                {
                    // Act
                    roomManager.Modify(updatedRoom);

                    // Assert
                    Assert.Fail("An exception SRVEX30085 of type ValidationException should have been thrown");
                }
                catch (ValidationException ex)
                {
                    // Assert
                    Assert.AreEqual("SRVEX30085", ex.Code, "The Validation exception is not returning the right error code");
                    mockRoomDao.VerifyAllExpectations();
                    bookingManager.VerifyAllExpectations();
                }
            }