Beispiel #1
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");
 }
Beispiel #2
0
            public void GetAspectsIsSuccessful()
            {
                // Arrange
                const string CULTURE_CODE = "en-GB";

                var roomTypeDao = MockRepository.GenerateMock<IRoomTypeDao>();
                var roomTypeManager = new RoomTypeManager { RoomTypeDao = roomTypeDao };

                roomTypeDao.Expect(x => x.GetAspects(CULTURE_CODE)).Return(new List<Aspect>());

                // Act
                roomTypeManager.GetAspects(CULTURE_CODE);

                // Assert
                roomTypeDao.VerifyAllExpectations();
            }
Beispiel #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);
            }
Beispiel #4
0
            public void GetRoomTypesAndBaseRatePlansIsSuccessful()
            {
                // Arrange
                const string CULTURE_CODE = "en-GB";
                const long BUSINESS_ID = 1;

                var roomTypeDao = MockRepository.GenerateMock<IRoomTypeDao>();
                var baseRatePlanDao = MockRepository.GenerateMock<IBaseRatePlanDao>();
                var roomDao = MockRepository.GenerateMock<IRoomDao>();

                var roomTypeManager = new RoomTypeManager
                    {
                        RoomTypeDao = roomTypeDao,
                        BaseRatePlanDao = baseRatePlanDao,
                        RoomDao = roomDao
                    };

                var roomType = new RoomType { Id = 1 };

                roomTypeDao.Expect(x => x.GetAllActiveForBusiness(BUSINESS_ID)).Return(new List<RoomType> { roomType });

                baseRatePlanDao.Expect(x => x.GetByRoomTypeId(roomType.Id, BUSINESS_ID, CULTURE_CODE)).Return(new BaseRatePlan());

                roomDao.Expect(x => x.GetByRoomTypeId(roomType.Id, BUSINESS_ID)).Return(new List<Room>());

                // Act
                roomTypeManager.GetRoomTypesAndBaseRatePlans(BUSINESS_ID, CULTURE_CODE);

                // Assert
                roomTypeDao.VerifyAllExpectations();
                baseRatePlanDao.VerifyAllExpectations();
                roomDao.VerifyAllExpectations();
            }
Beispiel #5
0
            public void GetRoomTypeIsSuccessful()
            {
                // Arrange
                const string CULTURE_CODE = "en-GB";
                const long BUSINESS_ID = 1;

                var roomTypeDao = new Mock<IRoomTypeDao>();
                var baseRatePlanDao = new Mock<IBaseRatePlanDao>();
                var variantRatePlanDao = new Mock<IVariantRatePlanDao>();
                var promotionManager = new Mock<IPromotionManager>();

                var roomTypeManager = new RoomTypeManager
                {
                    RoomTypeDao = roomTypeDao.Object,
                    BaseRatePlanDao = baseRatePlanDao.Object,
                    VariantRatePlanDao = variantRatePlanDao.Object,
                    PromotionManager = promotionManager.Object
                };

                var roomType = new RoomType { Id = 1 };

                roomTypeDao.Setup(x => x.GetByKey(roomType.Id)).Returns(roomType);
                var mockBaseRate = new BaseRatePlan();
                var mockVariants = new List<VariantRatePlan>();
                baseRatePlanDao.Setup(x => x.GetByRoomTypeId(roomType.Id, BUSINESS_ID, CULTURE_CODE)).Returns(mockBaseRate);
                variantRatePlanDao.Setup(x => x.GetByRoomTypeId(roomType.Id, BUSINESS_ID, CULTURE_CODE))
                                  .Returns(mockVariants);
                promotionManager.Setup(x => x.AssignAndGetPromotionsForBaseRatePlan(mockBaseRate, BUSINESS_ID));
                promotionManager.Setup(x => x.AssignAndGetPromotionsForRatePlans(mockVariants, BUSINESS_ID));

                // Act
                roomTypeManager.GetRoomType(roomType.Id, BUSINESS_ID, CULTURE_CODE);

                // Assert
                roomTypeDao.VerifyAll();
                baseRatePlanDao.VerifyAll();
                variantRatePlanDao.VerifyAll();
                promotionManager.VerifyAll();
            }
Beispiel #6
0
            public void CreateRoomTypeAndBaseRatePlanPopulatedRoomTypeIdAndRatePlanId()
            {
                // Arrange
                const long BUSINESS_ID = 1;

                var roomTypeDao = new Mock<IRoomTypeDao>();
                var ratePlanDao = new Mock<IBaseRatePlanDao>();
                var eventTrackingManager = new Mock<IEventTrackingManager>();

                var roomTypeManager = new RoomTypeManager
                {
                    RoomTypeDao = roomTypeDao.Object,
                    BaseRatePlanDao = ratePlanDao.Object,
                    EventTrackingManager = eventTrackingManager.Object
                };

                var ratePlan = new BaseRatePlan
                {
                    RoomTypeId = 1,
                    MaxOccupancy = 4,
                    MaxAdults = 2,
                    MaxChildren = 2,
                    RatePlanType = new RatePlanType { Type = RatePlanTypeEnum.Base },
                    BoardBasis = new BoardBasis { Code = "BK" },
                    CancellationClass = new CancellationClass { Code = "FR" }
                };

                var roomType = new RoomType
                {
                    BusinessId = BUSINESS_ID,
                    RoomClass = new RoomClass { Code = "DBL" },
                    QualityType = new QualityType { Code = "CTG" },
                    BathroomType = new BathroomType { Code = "PB" },
                    Aspect = new Aspect { Code = "CVW" },
                    ServiceFrequency = new EnumEntity { Code = ServiceFrequencyEnum.Daily.GetCode() },
                    BaseRatePlan = ratePlan
                };

                roomTypeDao.Setup(rt => rt.Create(roomType)).Callback(delegate { roomType.Id = 1; });
                ratePlanDao.Setup(rp => rp.Create(roomType.BaseRatePlan)).Callback(delegate { ratePlan.Id = 1; });

                eventTrackingManager.Setup(be => be.CreateBusinessEventAsync(BUSINESS_ID, BusinessEventTypesEnum.RoomTypeAdded, roomType.Id.ToString(CultureInfo.InvariantCulture), null));
                eventTrackingManager.Setup(be => be.CreateBusinessEventAsync(BUSINESS_ID, BusinessEventTypesEnum.RatePlanAdded, ratePlan.Id.ToString(CultureInfo.InvariantCulture), null));

                CacheHelper.StubRatePlanViewCacheWithRatePlanViews(BUSINESS_ID, new List<RatePlanView>());

                // Act
                roomTypeManager.CreateRoomTypeAndBaseRatePlan(roomType);

                // Assert
                Assert.AreNotEqual(default(int), roomType.Id, "The room type id was not attributed.");
                Assert.AreNotEqual(default(int), ratePlan.Id, "The rate plan id was not attributed.");

                roomTypeDao.VerifyAll();
                ratePlanDao.VerifyAll();
                eventTrackingManager.VerifyAll();

                // Make sure these are reset for future tests
                roomTypeManager.RoomTypeDao = new RoomTypeDao();

                CacheHelper.ReAssignRatePlanDaoToRatePlanViewCache();
            }
Beispiel #7
0
            public void ModifyRoomTypeWhereRoomTypeExistsThrowsValidationException()
            {
                // Arrange
                var roomTypeDao = MockRepository.GenerateMock<IRoomTypeDao>();
                var roomTypeManager = new RoomTypeManager { RoomTypeDao = roomTypeDao };

                var roomType = new RoomType();

                roomTypeDao.Expect(x => x.DoesRoomTypeExist(roomType)).Return(true);

                try
                {
                    // Act
                    roomTypeManager.ModifyRoomTypeAndBaseRatePlan(roomType);

                    // Assert
                    Assert.Fail("An exception SRVEX30093 of type ValidationException should have been thrown");
                }
                catch (ValidationException ex)
                {
                    // Assert
                    Assert.AreEqual(Errors.SRVEX30093.ToString(), ex.Code, "The Validation exception is not returning the right error code");
                }
            }
Beispiel #8
0
            public void ModifyRoomTypeAndBaseRatePlanPopulatedRoomTypeIdAndRatePlanId()
            {
                // Arrange
                const long BUSINESS_ID = 1;

                var roomTypeDao = new Mock<IRoomTypeDao>();
                var ratePlanManager = new Mock<IRatePlanManager>();
                var eventTrackingManager = new Mock<IEventTrackingManager>();

                var roomTypeManager = new RoomTypeManager
                {
                    RoomTypeDao = roomTypeDao.Object,
                    RatePlanManager = ratePlanManager.Object,
                    EventTrackingManager = eventTrackingManager.Object
                };

                var ratePlan = new BaseRatePlan
                {
                    MaxOccupancy = 4,
                    MaxAdults = 2,
                    MaxChildren = 2,
                    RatePlanType = new RatePlanType { Type = RatePlanTypeEnum.Base },
                    BoardBasis = new BoardBasis { Code = "BK" },
                    CancellationClass = new CancellationClass { Code = "FR" }
                };

                var roomType = new RoomType
                {
                    Id = 1,
                    BusinessId = BUSINESS_ID,
                    RoomClass = new RoomClass { Code = "DBL" },
                    QualityType = new QualityType { Code = "CTG" },
                    BathroomType = new BathroomType { Code = "PB" },
                    Aspect = new Aspect { Code = "CVW" },
                    BaseRatePlan = ratePlan
                };

                CacheHelper.StubRoomTypeCacheWithRoomType(roomType);

                roomTypeDao.Setup(rt => rt.DoesRoomTypeExist(roomType)).Returns(false);
                roomTypeDao.Setup(rt => rt.Modify(roomType));
                ratePlanManager.Setup(rp => rp.ModifyBaseRatePlan(roomType.BaseRatePlan));

                eventTrackingManager.Setup(be => be.CreateBusinessEventAsync(BUSINESS_ID, BusinessEventTypesEnum.RoomTypeModified, roomType.Id.ToString(CultureInfo.InvariantCulture), null));
                
                // Act
                roomTypeManager.ModifyRoomTypeAndBaseRatePlan(roomType);

                // Assert
                roomTypeDao.VerifyAll();
                ratePlanManager.VerifyAll();
                eventTrackingManager.VerifyAll();

                // Make sure these are reset for future tests
                roomTypeManager.RoomTypeDao = new RoomTypeDao();
                roomTypeManager.RatePlanManager = new RatePlanManager();
                roomTypeManager.EventTrackingManager = new EventTrackingManager();
                CacheHelper.ReAssignRoomTypeDaoToRoomTypeCache();
            }
Beispiel #9
0
            public void CreateRoomTypeWithoutRoomClassThrowsValidationException()
            {
                // Arrange
                const long BUSINESS_ID = 1;

                var roomTypeManager = new RoomTypeManager();

                var ratePlan = new BaseRatePlan
                {
                    RoomTypeId = 1,
                    MaxOccupancy = 4,
                    MaxAdults = 4,
                    MaxChildren = 2,
                };

                var roomType = new RoomType
                {
                    BusinessId = BUSINESS_ID,
                    RoomClass = new RoomClass(),
                    QualityType = new QualityType { Code = "CTG" },
                    BathroomType = new BathroomType { Code = "PB" },
                    Aspect = new Aspect { Code = "CVW" },
                    ServiceFrequency = new EnumEntity { Code = ServiceFrequencyEnum.Daily.GetCode() },
                    BaseRatePlan = ratePlan
                };

                try
                {
                    // Act
                    roomTypeManager.CreateRoomTypeAndBaseRatePlan(roomType);

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

            }
Beispiel #10
0
            public void IsDeleteRoomTypeAllowedCallsCorrectMethodsIsSuccessful()
            {
                // Arrange
                IBookingDao bookingDaoMock = MockRepository.GenerateMock<IBookingDao>();
                const int validRoomTypeId = 1;
                const long validBusinessId = 5;
                bookingDaoMock.Expect(
                    bdao =>
                    bdao.DoBookingsExistForRoomTypeInFuture(Arg<int>.Is.Equal(validRoomTypeId),
                                                            Arg<long>.Is.Equal(validBusinessId))).Return(false).Repeat.Once();
                RoomTypeManager roomTypeManager = new RoomTypeManager
                                                      {
                                                          BookingDao = bookingDaoMock
                                                      };
                // ACT
                bool result = roomTypeManager.IsDeleteRoomTypeAllowed(validRoomTypeId, validBusinessId);

                Assert.IsTrue(result, "True was not returned for check of delete roomtype");
                bookingDaoMock.VerifyAllExpectations();
            }