Exemplo n.º 1
0
            public void GetStateProvinceByCountryExpectSuccess()
            {
                const int countryId = 1;
                var country = new Country() {Id = countryId};
                var stateProvinceDao = MockRepository.GenerateStub<IStateProvinceDao>();
                var guestManager = new GuestManager(){StateProvinceDao = stateProvinceDao};
                stateProvinceDao.Expect(x => x.GetAll()).Return(new List<StateProvince>() { new StateProvince(){Country = country}});
                
                var results = guestManager.GetStateProvinceByCountry(countryId);

                Assert.IsNotNull(results);
                Assert.IsTrue(results.Count() == 1);

            }
            public void GetBusinessInformationWithExpectedResult()
            {
                // Arrange
                const long BUSINESS_TO_GET = 1;
                var stubBusinessManager = MockRepository.GenerateStub<IBusinessManager>();

                const string SERIALIZED_TIME_ZONE =
                    "Azores Standard Time;-60;(UTC-01:00) Azores;Azores Standard Time;Azores Daylight Time;[01:01:0001;12:31:9999;60;[0;02:00:00;3;5;0;];[0;03:00:00;10;5;0;];];";
                TimeZoneInfo timeZone = TimeZoneInfo.FromSerializedString(SERIALIZED_TIME_ZONE);
                Country stubCountry = new Country {Id = 1, Name = "United Kingdom"};
                var business = new Model.Business.Business
                {
                    Id = BUSINESS_TO_GET, 
                    BusinessStatus = new EnumEntity {Code = BusinessStatus.ACTIVE, Name = "Active"}, 
                    BusinessType = BusinessTypeEnum.Provider, 
                    Name = "FullName", 
                    ShortName = "ShortName", 
                    ReferenceCode = "ABC", 
                    IsTaxRegistered = true, 
                    TaxRegistrationNumber = "1234", 
                    BusinessRegistrationNumber = "4567", 
                    AddressLine1 = "123 Test Street", 
                    AddressLine2 = "45 Test Ave", 
                    AddressLine3 = "82 Test Street", 
                    PostCode = "W6 8JA", 
                    BusinessTelephoneNumber = "123 456 787", 
                    FaxNumber = "123 456 777", 
                    Email = "*****@*****.**", 
                    StateProvinceId = 1, 
                    StateProvince = new StateProvince{ Id = 1, Name = "London", Country = new Country { Id = 1, Name = "United Kingdom" }},
                    RegionId = 1, 
                    Region = new Region { Id = 1, Name = "UK"},
                    DefaultCultureCode = "en-GB", 
                    DefaultCulture = new Culture { Code = "en-GB", Name = "English (United Kingdom)", ParentCode = "en" },
                    TimeZone = timeZone,
                    WorkingCurrencyCode = "GBP", 
                    ContractCurrencyCode = "GBP", 
                    CountryId = 1, 
                    Country = stubCountry,
                    Longitude = new decimal(100.5), 
                    Latitude = new decimal(90.6), 
                    IsMerchant = true, 
                    MerchantDetailsId = 1, 
                    IsSMS = true, 
                    IsTermsAndConditions = true,
                    WorkingCurrency = new Currency("USD", "$", "US Dollars", 2),
                    Provider = new Provider { RoomCount = 20 }
                };
                stubBusinessManager.Stub(x => x.GetBusiness(BUSINESS_TO_GET)).Return(business);
                stubBusinessManager.Stub(x => x.GetCountryByBusiness(BUSINESS_TO_GET)).Return(stubCountry);

                PropertyManagementSystemService.BusinessManager = stubBusinessManager;

                // Act
                BusinessDto businessDto = PropertyManagementSystemService.GetBusinessInformation(BUSINESS_TO_GET);

                // Assert
                Assert.IsNotNull(businessDto, "Business information retrieved is null.");
                Assert.IsTrue(businessDto.Id != default(long), "Id attribute is not present on Business object.");
                Assert.AreEqual(business.BusinessStatus.Code, businessDto.BusinessStatusCode, "BusinessStatusCode attribute doesn't match on Business object.");
                Assert.AreEqual(business.BusinessStatus.Name, businessDto.BusinessStatusName, "BusinessStatusName attribute doesn't match on Business object.");
                Assert.AreEqual(business.BusinessType.GetCode(), businessDto.BusinessTypeCode, "BusinessTypeCode attribute doesn't match on Business object.");
                Assert.AreEqual(business.Name, businessDto.Name, "Name attribute doesn't match on Business object.");
                Assert.AreEqual(business.ShortName, businessDto.ShortName, "ShortName attribute doesn't match on Business object.");
                Assert.AreEqual(business.ReferenceCode, businessDto.ReferenceCode, "ReferenceCode attribute doesn't match on Business object.");
                Assert.AreEqual(business.IsTaxRegistered, businessDto.IsTaxRegistered, "IsTaxRegistered attribute doesn't match on Business object.");
                Assert.AreEqual(business.TaxRegistrationNumber, businessDto.TaxRegistrationNumber, "TaxRegistrationNumber attribute doesn't match on Business object.");
                Assert.AreEqual(business.BusinessRegistrationNumber, businessDto.BusinessRegistrationNumber, "BusinessRegistrationNumber attribute doesn't match on Business object.");
                Assert.AreEqual(business.AddressLine1, businessDto.AddressLine1, "AddressLine1 attribute doesn't match on Business object.");
                Assert.AreEqual(business.AddressLine2, businessDto.AddressLine2, "AddressLine2 attribute doesn't match on Business object.");
                Assert.AreEqual(business.AddressLine3,businessDto.AddressLine3, "AddressLine3 attribute doesn't match on Business object.");
                Assert.AreEqual(business.BusinessTelephoneNumber, businessDto.BusinessTelephoneNumber, "BusinessTelephoneNumber attribute doesn't match on Business object.");
                Assert.AreEqual(business.FaxNumber, businessDto.FaxNumber, "FaxNumber attribute doesn't match on Business object.");
                Assert.AreEqual(business.Email, businessDto.Email, "Email attribute doesn't match on Business object.");
                Assert.AreEqual(business.StateProvinceId, businessDto.StateProvinceId, "StateProvinceId attribute doesn't match on Business object.");
                Assert.AreEqual(business.PostCode, businessDto.PostCode, "PostCode attribute doesn't match on Business object.");
                Assert.AreEqual(business.RegionId, businessDto.RegionId, "RegionId attribute doesn't match on Business object.");
                Assert.AreEqual(business.DefaultCultureCode, businessDto.DefaultCultureCode, "DefaultCultureCode attribute doesn't match on Business object.");
                Assert.AreEqual(business.TimeZone.ToSerializedString(), businessDto.TimeZone, "TimeZone attribute doesn't match on Business object.");
                Assert.AreEqual(business.WorkingCurrencyCode, businessDto.WorkingCurrencyCode, "Working Currency code doesn't match on Business object.");
                Assert.AreEqual(business.ContractCurrencyCode, businessDto.ContractCurrencyCode, "Contract Currency code doesn't match on Business object.");
                Assert.AreEqual(business.Longitude, businessDto.Longitude, "Longitude attribute doesn't match on Business object.");
                Assert.AreEqual(business.Latitude, businessDto.Latitude, "Latitude attribute doesn't match on Business object.");
                Assert.AreEqual(business.IsMerchant, businessDto.IsMerchant, "IsMerchant attribute doesn't match on Business object.");
                Assert.AreEqual(business.MerchantDetailsId, businessDto.MerchantDetailsId, "MerchantDetailsId attribute doesn't match on Business object.");
                Assert.AreEqual(business.IsSMS, businessDto.IsSMS, "IsSMS attribute doesn't match on Business object.");
                Assert.AreEqual(business.IsTermsAndConditions, businessDto.IsTermsAndConditions, "IsTermsAndConditions attribute doesn't match on Business object.");
                Assert.AreEqual(business.Provider.RoomCount, businessDto.RoomCount, "RoomCount attribute doesn't match on Business object.");
                Assert.AreEqual(business.Provider.ProviderTypeName, businessDto.ProviderType, "ProviderType attribute doesn't match on Business object.");

                // Check attributes related to region.
                Assert.IsNotNull(businessDto.Region, "Region object is not populated.");
                Assert.AreEqual(business.Region.Id, businessDto.Region.Id, "Id attribute doesn't match on Region object.");
                Assert.AreEqual(business.Region.Name, businessDto.Region.Name, "Name attribute doesn't match on Region object.");

                // Check attributes related to the state province.
                Assert.IsNotNull(business.StateProvince, "StateProvince object is not populated.");
                Assert.AreEqual(business.StateProvince.Id, businessDto.StateProvince.Id, "Id attribute doesn't match on StateProvince object.");
                Assert.AreEqual(business.StateProvince.Name, businessDto.StateProvince.Name, "Name attribute doesn't match on StateProvince object.");

                // Check attributes related to country.
                Assert.IsNotNull(businessDto.Country, "Country object is not populated.");
                Assert.AreEqual(business.Country.Id, businessDto.Country.Id, "Id attribute doesn't match on Country object.");
               Assert.AreEqual(business.Country.Name, businessDto.Country.Name, "Name attribute doesn't match on Country object.");

               // Check attributes related to the currency.
               Assert.IsNotNull(business.WorkingCurrency, "Currency object is not populated.");
               Assert.AreEqual(business.WorkingCurrency.ISOCode, businessDto.WorkingCurrency.ISOCode, "Code attribute doesn't match on Currency object.");
               Assert.AreEqual(business.WorkingCurrency.Name, businessDto.WorkingCurrency.Name, "Name attribute doesn't match on Currency object.");

                // Check attributes related to the default culture.
                Assert.IsNotNull(businessDto.DefaultCulture, "DefaultCulture object is not populated.");
                Assert.AreEqual(business.DefaultCulture.Code,businessDto.DefaultCulture.Code, "Code attribute doesn't match on the DefaultCulture object.");
                Assert.AreEqual(business.DefaultCulture.Name,businessDto.DefaultCulture.Name, "Name attribute doesn't match on the DefaultCulture object.");
                Assert.AreEqual(business.DefaultCulture.ParentCode, businessDto.DefaultCulture.ParentCode, "ParentCode attribute doesn't match on the DefaultCulture object.");
            }
Exemplo n.º 3
0
            public void CreateGuestWithoutCountryIdAssignsCountryIdOfTheBusiness()
            {
                // Arrange
                IGuestDao guestDao = MockRepository.GenerateStub<IGuestDao>();
                IGuestEventDao guestEventDao = MockRepository.GenerateStub<IGuestEventDao>();
                ICountryDao countryDao = MockRepository.GenerateStub<ICountryDao>();
                GuestManager GuestManager = new GuestManager();
                GuestManager.GuestDao = guestDao;
                GuestManager.CountryDao = countryDao;
                GuestManager.GuestEventDao = guestEventDao;

                Guest guest = new Guest { BusinessId = 1, Surname = "Surname" };
                Country country = new Country { Id = 1, Name = "United Kingdom", IsoCode = 826 };
                guestDao.Stub(x => x.Create(guest)).WhenCalled(x => guest.Id = 1);
                guestEventDao.Stub(ev => ev.Create(new GuestEvent { GuestId = 1, GuestEventType = Model.Customer.GuestEventType.Created }));
                
                countryDao.Stub(c => c.GetByBusiness(1)).Return(country);

                // Act
                GuestManager.Create(guest);

                // Assert
                Assert.AreEqual(1, guest.Id, "Check that Guest was successfully created with only basic data.");
                Assert.AreEqual(country.Id, guest.CountryId, "Country id was updated incorrectly.");
            }
Exemplo n.º 4
0
            public void ModifyLimitedGuestWithoutCountryIdAssignsCountryIdOfTheBusiness()
            {
                // Arrange
                IGuestDao guestDao = MockRepository.GenerateStub<IGuestDao>();
                IGuestEventDao guestEventDao = MockRepository.GenerateStub<IGuestEventDao>();
                ICountryDao countryDao = MockRepository.GenerateStub<ICountryDao>();
                GuestManager GuestManager = new GuestManager();
                GuestManager.GuestDao = guestDao;
                GuestManager.CountryDao = countryDao;
                GuestManager.GuestEventDao = guestEventDao;

                Guest guest = new Guest { Id = 1, BusinessId = 1, Surname = "Surname" };
                Country country = new Country { Id = 1, Name = "United Kingdom", IsoCode = 826 };
                guestDao.Stub(x => x.Modify(guest));
                guestDao.Stub(c => c.IsGuestAssociatedToConfirmedBooking(1, 1)).Return(false);
                guestEventDao.Stub(ev => ev.Create(Arg<GuestEvent>.Matches(ge => ge.GuestId == 1 && ge.GuestEventType == GuestEventType.Modified)));
                countryDao.Stub(c => c.GetByBusiness(1)).Return(country);

                // Act
                GuestManager.Modify(guest);

                // Assert
                Assert.AreEqual(country.Id, guest.CountryId, "Country id was updated incorrectly.");
            }  
Exemplo n.º 5
0
            public void GetInitialDataSetupValidBusinessGetsPopulatedObject()
            {
                // Arrange
                int businessId = 1;
                var stubInitialDataSetupDao = MockRepository.GenerateStub<IInitialDataSetupDao>();

                // Regionalized Information
                RegionalizedInformation regionalizedInformation = new RegionalizedInformation()
                                                                      {
                                                                          CurrentCulture = "en-GB",
                                                                          SupportEmail = "*****@*****.**",
                                                                          SupportNumber = "01122334455",
                                                                          Titles = new List<Title>()
                                                                                       {
                                                                                           new Title() {Id = 1, Name = "Mr"},
                                                                                           new Title() {Id = 2, Name = "Mrs"}
                                                                                       }

                                                                      };

                // MasterDataInformation
                Country country1 = new Country() { Id = 1, Name = "Country1", IsoCode = 1 };
                Country country2 = new Country() { Id = 2, Name = "Country2", IsoCode = 2 };
                MasterDataInformation masterDataInformation = new MasterDataInformation()
                                                                  {
                                                                      Countries = new List<Country>()
                                                                                      {
                                                                                          country1,
                                                                                          country2
                                                                                      },
                                                                      StateProvinces = new List<StateProvince>()
                                                                                      {
                                                                                          new StateProvince() {Id = 1, Name = "StateProvince1", Country = country1},
                                                                                          new StateProvince() {Id = 2, Name = "StateProvince2", Country = country2}
                                                                                      }
                                                                  };
                stubInitialDataSetupDao.Stub(r => r.GetByBusiness(businessId)).Return(new InitialDataSetup()
                                                                                                      { 
                                                                                                          RegionalizedInformation = regionalizedInformation,
                                                                                                          MasterDataInformation = masterDataInformation
                                                                                                      });
                initialDataSetupManager.InitialDataSetupDao = stubInitialDataSetupDao;
                
                // Act
                InitialDataSetup initialDataSetup = initialDataSetupManager.GetInitialDataSetup(businessId);

                // Assert
                Assert.IsNotNull(initialDataSetup, "initialDataSetup retrieved is null.");
                Assert.IsNotNull(initialDataSetup.RegionalizedInformation, "RegionalizedInformation retrieved is null.");
                Assert.IsNotNull(initialDataSetup.MasterDataInformation, "MasterDataInformation retrieved is null.");
                Assert.AreEqual("en-GB", initialDataSetup.RegionalizedInformation.CurrentCulture, "CurrentCulture attribute retrieved is incorrect.");
                Assert.AreEqual("*****@*****.**", initialDataSetup.RegionalizedInformation.SupportEmail, "SupportEmail attribute retrieved is incorrect.");
                Assert.AreEqual("01122334455", initialDataSetup.RegionalizedInformation.SupportNumber, "SupportNumber attribute retrieved is incorrect.");
                
                Assert.IsNotNull(initialDataSetup.RegionalizedInformation.Titles, "Titles are not retrieved.");
                Assert.AreEqual(2, initialDataSetup.RegionalizedInformation.Titles.Count, "Total number of titles retrieved is incorrect.");
                Assert.AreEqual("Mr", initialDataSetup.RegionalizedInformation.Titles.Find(t => t.Id == 1).Name, "Translated Name is not retrieved.");
                Assert.AreEqual("Mrs", initialDataSetup.RegionalizedInformation.Titles.Find(t => t.Id == 2).Name, "Translated Name is not retrieved.");

                Assert.IsNotNull(initialDataSetup.MasterDataInformation.Countries, "Countries are not retrieved.");
                Assert.AreEqual(2, initialDataSetup.MasterDataInformation.Countries.Count, "Total number of Countries retrieved is incorrect.");
                Assert.AreEqual("Country1", initialDataSetup.MasterDataInformation.Countries.Find(c => c.Id == 1).Name, "Translated Name is not retrieved.");
                Assert.AreEqual("Country2", initialDataSetup.MasterDataInformation.Countries.Find(c => c.Id == 2).Name, "Translated Name is not retrieved.");

                Assert.IsNotNull(initialDataSetup.MasterDataInformation.StateProvinces, "StateProvinces are not retrieved.");
                Assert.AreEqual(2, initialDataSetup.MasterDataInformation.StateProvinces.Count, "Total number of StateProvinces retrieved is incorrect.");
                Assert.AreEqual("StateProvince1", initialDataSetup.MasterDataInformation.StateProvinces.Find(s => s.Id == 1).Name, "Translated Name is not retrieved.");
                Assert.AreEqual("StateProvince2", initialDataSetup.MasterDataInformation.StateProvinces.Find(s => s.Id == 2).Name, "Translated Name is not retrieved.");

                Assert.IsNotNull(initialDataSetup.MasterDataInformation.StateProvinces.Find(c => c.Id == 1).Country, "Country for StateProvince id 1 is not retrieved.");
                Assert.IsNotNull(initialDataSetup.MasterDataInformation.StateProvinces.Find(c => c.Id == 2).Country, "Country for StateProvince id 2 is not retrieved.");
                Assert.AreEqual("Country1", initialDataSetup.MasterDataInformation.StateProvinces.Find(c => c.Id == 1).Country.Name, "Translated Description of the Country is not retrieved.");
                Assert.AreEqual("Country2", initialDataSetup.MasterDataInformation.StateProvinces.Find(c => c.Id == 2).Country.Name, "Translated Description of the Country is not retrieved.");
                Assert.AreEqual(1, initialDataSetup.MasterDataInformation.StateProvinces.Find(c => c.Id == 1).Country.IsoCode, "IsoCode of the country is not retrieved.");
                Assert.AreEqual(2, initialDataSetup.MasterDataInformation.StateProvinces.Find(c => c.Id == 2).Country.IsoCode, "IsoCode of the country is not retrieved.");
            }
 /// <summary>
 /// Converts Country to Dto
 /// </summary>
 /// <param name="country">Country to Convert</param>
 /// <returns>Country Dto</returns>
 private static CountryDto ConvertCountryToDto(Country country)
 {
     return new CountryDto
     {
         Id = country.Id.HasValue ? country.Id.Value : default(int),
         Description = country.Name
     };
 }
Exemplo n.º 7
0
            public void CreateTransactionModelForInvoiceRequestReturnsTransactionModelCorrectly()
            {
                #region Arrange

                // Arrange
                IBookingDao bookingDaoMock = MockRepository.GenerateMock<IBookingDao>();
                IBusinessDao businessDaoMock = MockRepository.GenerateMock<IBusinessDao>();
                IOrderDao orderDaoMock = MockRepository.GenerateMock<IOrderDao>();
                IOrderReferenceDao orderReferenceMock = MockRepository.GenerateMock<IOrderReferenceDao>();
                IChannelDao channelDaoMock = MockRepository.GenerateMock<IChannelDao>();
                ICountryDao countryDaoMock = MockRepository.GenerateMock<ICountryDao>();
                IBookingEventDao bookingEventDaoMock = MockRepository.GenerateMock<IBookingEventDao>();
                IBookingEventDataDao bookingEventDataDaoMock = MockRepository.GenerateMock<IBookingEventDataDao>();
                IBookingItemDao bookingItemDaoMock = MockRepository.GenerateMock<IBookingItemDao>();
                IPaymentEventDao paymentEventDaoMock = MockRepository.GenerateMock<IPaymentEventDao>();
                IPaymentDao paymentDaoMock = MockRepository.GenerateMock<IPaymentDao>();
                ISettlementHelper settlementHelperMock = MockRepository.GenerateMock<ISettlementHelper>();

                bool forceProcess = true;

                Booking bookingMock = new Booking
                                          {
                                              Id = GOOD_BOOKING_ID,
                                              OrderId = GOOD_ORDER_ID,
                                              BusinessId = GOOD_BUSINESS_ID,
                                              BookingReferenceNumber = GOOD_BOOKING_REF
                                          };

                Model.Business.Business businessMock = new Model.Business.Business
                                                           {
                                                               Id = GOOD_BUSINESS_ID
                                                           };

                Order orderMock = new Order
                                      {
                                          Id = GOOD_ORDER_ID,
                                          Bookings = new List<Model.Booking.Booking> {bookingMock},
                                          ChannelId = GOOD_CHANNEL_ID
                                      };

                Channel channelMock = new Channel
                                          {
                                              Id = GOOD_CHANNEL_ID,
                                              DistributorId = GOOD_CHANNEL_BUSINESS_ID
                                          };

                Model.Business.Business channelBusinessMock = new Model.Business.Business
                                                                  {
                                                                      Id = GOOD_CHANNEL_BUSINESS_ID
                                                                  };

                Country countryMock = new Country
                                          {
                                              Id = GOOD_COUNTRY_ID,
                                              IsoChar2Code = UK_COUNTRY_CODE
                                          };

                BookingEvent bookingEventMock = new BookingEvent
                                                    {
                                                        Id = GOOD_EVENT_ID,
                                                        BookingId = GOOD_BOOKING_ID
                                                    };
                List<BookingEventData> bookingEventDataMock = new List<BookingEventData>();
                var bookingPaymentMock = new Model.Booking.Payment
                                                 {
                                                     Id = GOOD_PAYMENT_ID
                                                 };

                var paymentListMock = new List<Model.Booking.Payment> { bookingPaymentMock };

                List<BookingItem> bookingItemMock = new List<BookingItem>();
                List<PaymentEvent> paymentEventListMock = new List<PaymentEvent>();
                List<SettlementPaymentDto> settlementPaymentDtosMock = new List<SettlementPaymentDto>();

                bookingDaoMock.Expect(bd => bd.GetByKey(Arg<int>.Is.Equal(GOOD_BOOKING_ID), Arg<string>.Is.Anything)).Return(bookingMock).Repeat.Never();
                businessDaoMock.Expect(bu => bu.GetByKey(Arg<long>.Is.Equal(bookingMock.BusinessId), Arg<string>.Is.Equal(string.Empty))).Return(businessMock).Repeat.Once();
                orderDaoMock.Expect(od => od.GetOrderWithBookingsByKey(Arg<int>.Is.Equal(GOOD_ORDER_ID), Arg<string>.Is.Anything, Arg<string>.Is.Anything, Arg<string>.Is.Anything, Arg<GetOrderWithBookingsByEnum>.Is.Equal(GetOrderWithBookingsByEnum.Id))).Return(orderMock).Repeat.Once();
                orderReferenceMock.Expect(
                    or =>
                    or.GetByOrderIdAndReferenceType(Arg<int>.Is.Equal(GOOD_ORDER_ID),
                                                    Arg<ReferenceTypeEnum>.Is.Equal(ReferenceTypeEnum.EcommerceReservation)))
                                  .Return(null)
                                  .Repeat.Once();
                channelDaoMock.Expect(cd => cd.GetById(Arg<int>.Is.Equal(orderMock.ChannelId.Value)))
                    .Return(channelMock)
                    .Repeat.Once();

                businessDaoMock.Expect(bu => bu.GetByKey(Arg<long>.Is.Equal(channelMock.DistributorId.Value), Arg<string>.Is.Equal(string.Empty)))
                    .Return(channelBusinessMock)
                    .Repeat.Once();
                countryDaoMock.Expect(cod => cod.GetByBusiness(Arg<long>.Is.Equal(bookingMock.BusinessId)))
                    .Return(countryMock)
                    .Repeat.Once();

                bookingEventDaoMock.Expect(bed => bed.GetByKey(GOOD_EVENT_ID)).Return(bookingEventMock).Repeat.Once();
                bookingEventDataDaoMock.Expect(bedd => bedd.GetAllByEventId(Arg<int>.Is.Equal(bookingEventMock.Id)))
                    .Return(bookingEventDataMock)
                    .Repeat.Once();

                paymentDaoMock.Expect(pd => pd.GetPaymentsByOrder(Arg<int>.Is.Equal(GOOD_ORDER_ID)))
                    .Return(paymentListMock)
                    .Repeat.Once();


                // settlement manager mocks of inner methods
                SettlementManager settlementManagerMock = MockRepository.GeneratePartialMock<SettlementManager>();

                settlementManagerMock.Expect(
                    sm =>
                    sm.GetPaymentByTypeAndSource(Arg<IEnumerable<Model.Booking.Payment>>.List.ContainsAll(paymentListMock),
                                                 Arg<PaymentTypeEnum>.Is.Equal(PaymentTypeEnum.Payment),
                                                 Arg<PaymentSourceEnum>.Is.Equal(PaymentSourceEnum.Online)))
                    .Return(bookingPaymentMock).Repeat.Once();

                bookingItemDaoMock.Expect(bid => bid.GetByBooking(Arg<int>.Is.Equal(GOOD_BOOKING_ID)))
                    .Return(bookingItemMock)
                    .Repeat.Once();

                paymentEventDaoMock.Expect(ped => ped.GetByPaymentId(Arg<int>.Is.Equal(bookingPaymentMock.Id)))
                    .Return(paymentEventListMock)
                    .Repeat.Once();

                settlementManagerMock.Expect(
                    smm =>
                    smm.GetSettlementPayment(
                        Arg<PaymentRequest>.Matches(
                            pr => pr.BookingReferenceCode == bookingMock.BookingReferenceNumber &&
                                  pr.IsoCountryCode == countryMock.IsoChar2Code)))
                    .Return(settlementPaymentDtosMock)
                    .Repeat.Once();

                settlementManagerMock.Expect(
                    sem =>
                    sem.SetLineItemsOnTransactionModel(Arg<TransactionModel>.Is.Anything,
                                                       Arg<List<SettlementPaymentDto>>.Is.Anything,
                                                       Arg<Order>.Matches(
                                                           o =>
                                                           o.Id == orderMock.Id && o.ChannelId == orderMock.ChannelId &&
                                                           o.Bookings != null &&
                                                           o.Bookings.Count == orderMock.Bookings.Count),
                                                       Arg<List<Model.Booking.Payment>>.List.ContainsAll(paymentListMock),
                                                       Arg<List<PaymentEvent>>.Is.Anything)).Repeat.Once();
                settlementManagerMock.Expect(
                    sem =>
                    sem.SetGuestInfoOnTransactionModel(Arg<TransactionModel>.Is.Anything,
                                                       Arg<Order>.Matches(
                                                           b =>
                                                           b.Id == orderMock.Id &&
                                                           b.OrderReference == orderMock.OrderReference))).Repeat.Once();
                settlementManagerMock.Expect(
                    sem => sem.SetBookingInfoOnTransactionModel(Arg<TransactionModel>.Is.Anything,
                                                                Arg<Booking>.Matches(b =>
                                                                                     b.Id == bookingMock.Id &&
                                                                                     b.OrderId == bookingMock.OrderId &&
                                                                                     b.BusinessId ==
                                                                                     bookingMock.BusinessId &&
                                                                                     b.BookingReferenceNumber ==
                                                                                     bookingMock.BookingReferenceNumber),
                                                                Arg<Order>.Matches(
                                                                    o =>
                                                                    o.Id == orderMock.Id &&
                                                                    o.ChannelId == orderMock.ChannelId &&
                                                                    o.Bookings != null &&
                                                                    o.Bookings.Count == orderMock.Bookings.Count),
                                                                Arg<BookingEvent>.Matches(
                                                                    be =>
                                                                    be.Id == bookingEventMock.Id &&
                                                                    be.BookingId == bookingEventMock.BookingId),
                                                                Arg<List<BookingEventData>>.Is.Anything,
                                                                Arg<Model.Business.Business>.Matches(
                                                                    bu => bu.Id == businessMock.Id),
                                                                Arg<List<SettlementPaymentDto>>.Is.Anything, 
                                                                Arg<string>.Is.Anything)).Repeat.Once();

                settlementManagerMock.Expect(
                    sem => sem.SetFinancialInfoOnTransactionModel(Arg<TransactionModel>.Is.Anything,
                                                                  Arg<Booking>.Matches(b =>
                                                                                       b.Id == bookingMock.Id &&
                                                                                       b.OrderId == bookingMock.OrderId &&
                                                                                       b.BusinessId ==
                                                                                       bookingMock.BusinessId &&
                                                                                       b.BookingReferenceNumber ==
                                                                                       bookingMock
                                                                                           .BookingReferenceNumber),
                                                                  Arg<Model.Business.Business>.Matches(
                                                                      bu => bu.Id == businessMock.Id),
                                                                  Arg<Order>.Matches(
                                                                      o =>
                                                                      o.Id == orderMock.Id &&
                                                                      o.ChannelId == orderMock.ChannelId &&
                                                                      o.Bookings != null &&
                                                                      o.Bookings.Count == orderMock.Bookings.Count),
                                                                  Arg<List<BookingItem>>.Is.Anything,
                                                                  Arg<decimal>.Is.Anything)).Repeat.Once();

                settlementManagerMock.Expect(
                    sem =>
                    sem.SetPaymentInfoOnTransactionModel(Arg<TransactionModel>.Is.Anything,
                                                         Arg<Model.Booking.Payment>.Matches(p => p.Id == bookingPaymentMock.Id),
                                                         Arg<List<SettlementPaymentDto>>.Is.Anything,
                                                         Arg<Order>.Matches(
                                                                      o =>
                                                                      o.Id == orderMock.Id &&
                                                                      o.ChannelId == orderMock.ChannelId &&
                                                                      o.Bookings != null &&
                                                                      o.Bookings.Count == orderMock.Bookings.Count),
                                                         Arg<bool>.Is.Equal(forceProcess))).Repeat.Once();

                settlementManagerMock.Expect(
                    sem =>
                    sem.SetProviderDistributorInformationOnTransactionModel(Arg<TransactionModel>.Is.Anything,
                                                                            Arg<Model.Business.Business>.Matches(
                                                                                bu => bu.Id == businessMock.Id),
                                                                            Arg<Model.Business.Business>.Matches(
                                                                                chbu => chbu.Id == channelBusinessMock.Id), 
                                                                            Arg<Channel>.Is.Anything)).Repeat.Once();

                settlementManagerMock.Expect(
                    sem =>
                    sem.SetReservedProductOnTransactionModel(Arg<TransactionModel>.Is.Anything,
                                                             Arg<Booking>.Matches(b =>
                                                                                  b.Id == bookingMock.Id &&
                                                                                  b.OrderId == bookingMock.OrderId &&
                                                                                  b.BusinessId ==
                                                                                  bookingMock.BusinessId &&
                                                                                  b.BookingReferenceNumber ==
                                                                                  bookingMock
                                                                                      .BookingReferenceNumber),
                                                             Arg<Order>.Matches(
                                                                 o =>
                                                                 o.Id == orderMock.Id &&
                                                                 o.ChannelId == orderMock.ChannelId &&
                                                                 o.Bookings != null &&
                                                                 o.Bookings.Count == orderMock.Bookings.Count), 
                                                                 Arg<string>.Is.Anything)).Repeat.Once();

                settlementHelperMock.Expect(
                    helper =>
                    helper.SetMerchantInfoOnTransactionModel(Arg<TransactionModel>.Is.Anything,
                                                             Arg<Model.Booking.Booking>.Is.Anything,
                                                             Arg<Model.Business.Business>.Is.Anything,
                                                             Arg<Model.Business.Business>.Is.Anything,
                                                             Arg<List<SettlementPaymentDto>>.Is.Anything));

                settlementManagerMock.BookingDao = bookingDaoMock;
                settlementManagerMock.BookingEventDao = bookingEventDaoMock;
                settlementManagerMock.BookingEventDataDao = bookingEventDataDaoMock;
                settlementManagerMock.BookingItemDao = bookingItemDaoMock;
                settlementManagerMock.BusinessDao = businessDaoMock;
                settlementManagerMock.ChannelDao = channelDaoMock;
                settlementManagerMock.CountryDao = countryDaoMock;
                settlementManagerMock.OrderDao = orderDaoMock;
                settlementManagerMock.OrderReferenceDao = orderReferenceMock;
                settlementManagerMock.PaymentEventDao = paymentEventDaoMock;
                settlementManagerMock.PaymentDao = paymentDaoMock;
                settlementManagerMock.SettlementHelper = settlementHelperMock;

                #endregion

                // Act
                TransactionModel result = settlementManagerMock.CreateTransactionModelForInvoiceRequest(
                    GOOD_BOOKING_ID, GOOD_ORDER_ID, GOOD_EVENT_ID, forceProcess);

                // Assert
                settlementManagerMock.VerifyAllExpectations();
                bookingDaoMock.VerifyAllExpectations();
                bookingEventDaoMock.VerifyAllExpectations();
                bookingEventDataDaoMock.VerifyAllExpectations();
                bookingItemDaoMock.VerifyAllExpectations();
                businessDaoMock.VerifyAllExpectations();
                channelDaoMock.VerifyAllExpectations();
                countryDaoMock.VerifyAllExpectations();
                orderDaoMock.VerifyAllExpectations();
                orderReferenceMock.VerifyAllExpectations();
                paymentEventDaoMock.VerifyAllExpectations();
                paymentDaoMock.VerifyAllExpectations();
                settlementHelperMock.VerifyAllExpectations();
            }
Exemplo n.º 8
0
        /// <summary>
        /// Get settlement Bank Sort Code from eagle settlement bank account
        /// </summary>
        /// <returns></returns>
        private string GetBankAccountNumber(Country countryOfBusiness, BankAccount settlementBankAccount)
        {
            Helper.ArgumentNotNull(countryOfBusiness, "country of business");
            if (settlementBankAccount == null) { return null; }

            string bankAccountNumber = countryOfBusiness.IsoChar2Code == UK_ISO_CHAR2_CODE
                                           ? settlementBankAccount.AccountNumber
                                           : settlementBankAccount.IBAN;

            // handle size difference in fields in settlement
            return bankAccountNumber == null || bankAccountNumber.Length <= MAX_BANK_ACCOUNT_SIZE
                       ? bankAccountNumber
                       : bankAccountNumber.Substring(0, MAX_BANK_ACCOUNT_SIZE);
        }
Exemplo n.º 9
0
 /// <summary>
 /// Get settlement Bank Sort Code from eagle settlement bank account
 /// </summary>
 /// <returns></returns>
 private string GetBankSortCode(Country countryOfBusiness, BankAccount settlementBankAccount)
 {
     Helper.ArgumentNotNull(countryOfBusiness, "country of business");
     if (settlementBankAccount == null) { return null; }
     
     return countryOfBusiness.IsoChar2Code == UK_ISO_CHAR2_CODE ? settlementBankAccount.BankCode : settlementBankAccount.BIC;
 }