示例#1
0
            public void RunTaskExecutesSuccessfullyFirstTime()
            {
                using (new TestDataHelper(TestQueryEcom.POPULATE_BUSINESSES, TestQueryEcom.CLEANUP_TEST_DATA, DbHelper.ECOM_CONNECTION_STRING_NAME))
                {
                    // Arrange
                    IBusinessManager businessManager = new BusinessManager();
                    DateTime fromDate = new DateTime(2012, 01, 1, 0, 0, 0, DateTimeKind.Utc);
                    SyncBusinessesToEagle.FromDate = fromDate;
                    SyncBusinessesToEagle.Identity = new GenericIdentity(WindowsServiceUserGuid.ToString());
                    //UserHelper.SetupUser(WindowsUserName, UserHelper.VALIDUSERPASS, WindowsUserName, WindowsServiceUserGuid);
                    List<EcomBusinessAccount> expectedBusinessAccountList = new EcomDataProvider().GetLastModifiedBusinesses(fromDate, DateTime.UtcNow);

                    // Act
                    SyncBusinessesToEagle.Run();

                    // Assert
                    //verify if the latest timestamp in Eccom.BusinessAccount is later than the one obtained before
                    DateTime lastModifiedDateTime = businessManager.GetTimestampOfLastBusinessSyncedFromEcom();

                    // Add 10 seconds to date time now so it doesn't fail in the build server
                    var now = DateTime.UtcNow.AddSeconds(10);

                    TimeSpan currentDateDiff = now - lastModifiedDateTime;
                    TimeSpan lastDateDiff = lastModifiedDateTime - fromDate;
                    bool result = (currentDateDiff.TotalHours >= 0 && lastDateDiff.TotalHours >= 0);
                    Assert.IsTrue(result, string.Format("The last modified date is not correct: lastModifiedDateTime - {0} ; fromDate - {1}. Now: {2}", lastModifiedDateTime, fromDate, now));

                    //verify if all the expected businesses were inserted/updated
                    Assert.AreEqual(expectedBusinessAccountList.Count, businessManager.GetBusinessAccountsSyncedByLastModifiedDate(lastModifiedDateTime).Count, "The expected businesses were not returned.");
                }
            }
示例#2
0
 public SyncPaymentHelper()
 {
     Logger = LogFactory.GetLogger(typeof(SyncPaymentHelper));
     serviceTaskProviderConfiguration = (ServiceTaskProviderConfigurationSection)ConfigurationManager.GetSection(ConfigurationConstants.CONFIG_KEY_DATA_PROVIDER_SECTION);
     businessDao = new BusinessDao();
     businessManager = new BusinessManager();
     serviceClient = new PaymentServiceServiceClient();
     SetMerchantAccountsConfigurationList();
 }
示例#3
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");
 }
示例#4
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);
            }
示例#5
0
            public void RunTaskExecutesSuccessfullyTwoConsecutiveTimes()
            {
                // Arrange
                IBusinessManager businessManager = new BusinessManager();
                DateTime fromDate = new DateTime(2012, 01, 1, 0, 0, 0, DateTimeKind.Utc);
                SyncBusinessesToEagle.FromDate = fromDate;
                SyncBusinessesToEagle.Identity = new GenericIdentity(WindowsServiceUserGuid.ToString());
                //UserHelper.SetupUser(WindowsUserName, UserHelper.VALIDUSERPASS, WindowsUserName, WindowsServiceUserGuid);
                SyncBusinessesToEagle.Run();
                
                fromDate = DateTime.UtcNow;
                DateTime expectedLastModifiedDateTime = businessManager.GetTimestampOfLastBusinessSyncedFromEcom();
                SyncBusinessesToEagle.FromDate = fromDate;
                SyncBusinessesToEagle.Identity = new GenericIdentity(WindowsServiceUserGuid.ToString());
                List<EcomBusinessAccount> expectedBusinessAccountList = new EcomDataProvider().GetLastModifiedBusinesses(fromDate, DateTime.UtcNow);

                // Act
                SyncBusinessesToEagle.Run();

                // Assert
                //verify if the latest timestamp in Eccom.BusinessAccount is the same as obtain before
                DateTime lastModifiedDateTime = businessManager.GetTimestampOfLastBusinessSyncedFromEcom();

                TimeSpan lastDateDiff = lastModifiedDateTime - expectedLastModifiedDateTime;
                Assert.IsTrue(lastDateDiff.TotalHours == 0, string.Format("The last modified date is not bigger than the one we had before running the task: lastModifiedDateTime - {0} ; expectedLastModifiedDateTime - {1}", lastModifiedDateTime, expectedLastModifiedDateTime));

                //verify that no business was changed in the meanwhile
                Assert.AreEqual(0, expectedBusinessAccountList.Count, "The list is expected to be null");
            }
        /// <summary>
        ///  Convert Booking Dto to Booking business domain
        /// </summary>
        /// <param name="order">OrderRequestDto</param>
        /// <param name="booking">BookingRequestDto</param>
        /// <returns>Booking</returns>
        public static Booking ConvertBookingOnlineDtoToBooking(OrderRequestDto order, BookingRequestDto booking)
        {
            var businessManager = new BusinessManager();
            Model.Business.Business business = businessManager.GetLimitedBusinessByShortname(order.BusinessShortName);

            if (business != null)
            {
                var book = new Booking
                {
                    BusinessId = business.Id,
                    BookingReferenceNumber = order.BookingReferenceNumber,
                    StartDate = booking.StartDate,
                    EndDate = booking.EndDate,
                    NumberOfAdults = booking.NumberOfAdults,
                    NumberOfChildren = booking.NumberOfChildren,
                    Cost = booking.Cost,
                    RoomTypeId = booking.RoomTypeId,
                    RoomId = booking.RoomId,
                    RatePlanId = booking.RatePlanId,
                    CheckinStatus = ConvertCodeAndNameToEnumEntity(booking.CheckinStatusCode),
                    BookingScenarioType = (BookingScenarioTypeEnum)order.BookingScenarioType,
                    Notes = booking.Notes,
                    BookingStatus = ConvertCodeAndNameToEnumEntity(booking.BookingStatusCode),
                    CreatedByUserId = order.CreatedByUserId,
                    CreatedDateTime = order.CreatedDateTime,
                    RateType = ConvertCodeAndNameToEnumEntity(RateType.BEST_AVAILABLE_RATE),
                    ChannelCommissionOverride = booking.ChannelCommissionOverride,
                    Extras = booking.Extras == null ? null : booking.Extras.ConvertAll(MapToOnlineBookingExtra)
                };
                order.Guest.BusinessId = business.Id;
                return book;
            }

            return null;
        }