예제 #1
0
        /// <summary>
        /// Map the basic fields for the Channel table to the Channel model object
        /// </summary>
        /// <param name="record">The SqlDataReader with the executed query result</param>
        /// <param name="mapOptin">if true, maps the opt-in as well</param>
        /// <param name="prefix">a prefix used to identify fields for the Channel model  in the resultset if required</param>        
        /// <returns>An instance of Model.Distribution.Channel</returns>
        internal static Channel MapRecord(IDataRecord record, bool mapOptin, string prefix = "")
        {
            Channel channel = new Channel
            {
                Id = DbHelper.ConvertValue<int>(record[prefix + Parameters.Id]),
                ChannelType = DbHelper.ConvertEnumValue<ChannelTypeEnum>(record[prefix + Parameters.ChannelTypeCode]),
                CommissionType = DbHelper.ConvertEnumValue<CommissionTypeEnum>(record[prefix + Parameters.CommissionTypeCode]),
                IntegrationType = DbHelper.ConvertEnumValue<IntegrationTypeEnum>(record[prefix + Parameters.IntegrationTypeCode]),
                NumberOfGroupChannels = DbHelper.ConvertValue<int>(record[prefix + Parameters.NumberOfGroupChannels]),
                DistributorId = DbHelper.ConvertValue<long?>(record[prefix + Parameters.DistributorId]),
                Name = DbHelper.ConvertValue<string>(record[prefix + Parameters.Name]),
                DistributorSelectionRule = DbHelper.ConvertValue<string>(record[prefix + Parameters.DistributorSelectionRule]),
                DistributorRoomSelectionRule = DbHelper.ConvertValueNull<int>(record[prefix + Parameters.DistributorRoomSelectionRule]),
                EcomBusinessAccountId = DbHelper.ConvertValue<Guid?>(record[prefix + Parameters.BABA_ID]),
                ShortName = DbHelper.ConvertValue<string>(record[prefix + Parameters.ShortName]),
                Commission = DbHelper.ConvertValue<decimal>(record[prefix + Parameters.Commission]),
                CommissionDisplay = DbHelper.ConvertValue<string>(record[prefix + Parameters.CommissionDisplay]),
                DistributorCommission = DbHelper.ConvertValue<decimal>(record[prefix + Parameters.DistributorCommission]),
                EviivoCommission = DbHelper.ConvertValue<decimal>(record[prefix + Parameters.EviivoCommission]),
                TermsSummary = DbHelper.ConvertValue<string>(record[prefix + Parameters.TermsSummary]),
                ChannelImage = ImageMapper.MapRecord(record, Parameters.ChannelImage.ToString()),
                AllowProviderOptOut = DbHelper.ConvertValue<bool>(record[prefix + Parameters.AllowProviderOptOut]),
                OptOutMessage = DbHelper.ConvertValue<string>(record[prefix + Parameters.OptOutMessage]),
                DisplaySequence = DbHelper.ConvertValue<int>(record[prefix + Parameters.DisplaySequence]),
                DistributorDisplaySequence = DbHelper.ConvertValue<int>(record[prefix + Parameters.DistributorDisplaySequence]),
                DistributorTypeDisplaySequence = DbHelper.ConvertValue<int>(record[prefix + Parameters.DistributorTypeDisplaySequence]),
                RequiresMembership = DbHelper.ConvertValue<bool>(record[prefix + Parameters.RequiresMembership]),
                CancellationValues = new CancellationValues
                {
                    CancellationType = CancellationTypeMapper.MapRecord(record, Parameters.CancellationType.ToString()),
                    CancellationChargeType = CancellationChargeTypeMapper.MapRecord(record, Parameters.CancellationChargeType.ToString()),
                    CancellationChargeValue = DbHelper.ConvertValue<decimal?>(record[prefix + Parameters.CancellationChargeValue]),
                    CancellationWindowHours = DbHelper.ConvertValue<int?>(record[prefix + Parameters.CancellationWindowHours]),
                },
                SupportsCustomCancPolicy = DbHelper.ConvertValue<bool>(record[prefix + Parameters.SupportsCustomCancPolicy]),
                CurrencyCode = DbHelper.ConvertValue<string>(record[prefix + Parameters.CurrencyCode]),
                ChannelSynchronizationTypeCode = DbHelper.ConvertValue<string>(record[prefix + Parameters.ChannelSynchronizationTypeCode]),
                DistributorTypeCode = DbHelper.ConvertValue<string>(record[prefix + Parameters.DistributorTypeCode]),
                ChannelStatus = DbHelper.ConvertEnumValue<ChannelStatusEnum>(record[prefix + Parameters.ChannelStatusCode]),
                ChannelTermsId = DbHelper.ConvertValue<int?>(record[prefix + Parameters.ChannelTermsId]),
                UpdatedByUserId = DbHelper.ConvertValue<Guid>(record[prefix + Parameters.UpdatedByUserId]),
                UpdatedDateTime = DbHelper.ConvertValue<DateTime>(record[prefix + Parameters.UpdatedDatetime]),
                DefaultPrePayValue = DbHelper.ConvertValue<decimal?>(record[prefix + Parameters.PrePayRuleValue]),
                DefaultPrePayType = DbHelper.ConvertEnumValue<PrePayRuleTypeEnum>(record[prefix + Parameters.PrePayRuleTypeCode]),
                DefaultPrePayMethodDescription = DbHelper.ConvertValue<string>(record[prefix + Parameters.DctPrePayMethodDesc]),
                DefaultPrePaidDescription = DbHelper.ConvertValue<string>(record[prefix + Parameters.DctPrePayDesc])
            };

            if (mapOptin)
            {
                // map opt-in and tell it to not map the channel info
                channel.BusinessChannelOptIn =
                    BusinessChannelOptInMapper.MapRecord(record, false, false, true, Parameters.BusinessChannelOptIn.ToString());
            }

            return channel;
        }
예제 #2
0
        /// <summary>
        /// for a given new opt in, update cancel / prepay info for it based on logical group info
        /// </summary>
        /// <param name="businessChannelOptIn">opt in info for channel being opted in</param>
        /// <param name="cultureCode">culture info</param>
        /// <param name="logicalGroup">channel of the group</param>
        public virtual void UpdateGroupChannelsWithCancelPrepaySettings(Channel logicalGroup, BusinessChannelOptIn businessChannelOptIn, string cultureCode)
        {
            if (logicalGroup != null)
            {
                BusinessChannelOptIn optInToModify =
                    businessChannelOptInDao.GetOptInByBusinessAndChannel(businessChannelOptIn.BusinessId.Value,
                                                                         logicalGroup.Id, cultureCode);

                // get cancel info based on group
                var channelTermsList = channelCancellationTermsDao.GetByBusiness(businessChannelOptIn.BusinessId.Value);
                var channelTerms = channelTermsList.FirstOrDefault(ct => ct.ChannelId == logicalGroup.Id);

                // get prepay info based on group
                var prePaySettings = prePayDao.GetPermittedChannelSettings(businessChannelOptIn.BusinessId.Value, logicalGroup.Id);
                optInToModify.ChannelId = businessChannelOptIn.ChannelId;
                optInToModify.ChannelTermsId = businessChannelOptIn.ChannelTermsId;

                // cancellation update
                UpdateCancellationForOptedInChannel(optInToModify, channelTerms);

                // prepay update
                UpdatePrePayForOptedInChannel(optInToModify, prePaySettings);
            }
        }
예제 #3
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();
            }
예제 #4
0
            public void OptInToChannelInGroupOptsIntoGroupAsWell()
            {
                // Arrange
                const string CULTURE_CODE = "en-GB";

                var businessChannelOptInDao = new Mock<IBusinessChannelOptInDao>();
                var eventTrackingManagerMock = new Mock<IEventTrackingManager>();
                var channelDaoMock = new Mock<IChannelDao>();
                var distributionManagerMock = new Mock<DistributionManager>();
                var businessDaoMock = new Mock<IBusinessDao>();
                var prePayDaoMock = new Mock<IPrePayDao>();

                distributionManagerMock.Object.BusinessChannelOptInDao = businessChannelOptInDao.Object;
                distributionManagerMock.Object.EventTrackingManager = eventTrackingManagerMock.Object;
                distributionManagerMock.Object.ChannelDao = channelDaoMock.Object;
                distributionManagerMock.Object.BusinessDao = businessDaoMock.Object;
                distributionManagerMock.Object.PrePayDao = prePayDaoMock.Object;
                distributionManagerMock.CallBase = true;

                var businessChannelOptIn = new BusinessChannelOptIn
                {
                    BusinessId = 1,
                    ChannelId = 1,
                    ChannelTermsId = 1
                };
                var logicalGroupChannelOptIn = new BusinessChannelOptIn
                {
                    BusinessId = 1,
                    ChannelId = 2,
                    ChannelTermsId = 2
                };
                
                Channel nullLogical = null;
                Channel logicalGroupChannel = new Channel
                    {
                        Id = 2,
                        ChannelType = ChannelTypeEnum.LogicalGroup,
                        ChannelTermsId = 2
                    };

                prePayDaoMock.Setup(p => p.GetPermittedChannelSettings(businessChannelOptIn.BusinessId.Value, logicalGroupChannelOptIn.ChannelId.Value)).Returns(new List<ChannelPrePayPermittedSetting>
                                                                                                                                                                 {
                                                                                                                                                                     new ChannelPrePayPermittedSetting
                                                                                                                                                                         {
                                                                                                                                                                             Type = PrePayRuleTypeEnum.Nights,
                                                                                                                                                                             Min = 1,
                                                                                                                                                                             Max = 5
                                                                                                                                                                         }
                                                                                                                                                                 });

                businessDaoMock.Setup(b => b.GetByKey(businessChannelOptIn.BusinessId.Value, It.IsAny<string>())).Returns(new Model.Business.Business
                {
                    Id = logicalGroupChannelOptIn.BusinessId.Value,
                    PrePayRuleValue = 5,
                    PrePayRuleType = PrePayRuleTypeEnum.Nights
                });
                businessChannelOptInDao.Setup(dao => dao.Create(It.Is<BusinessChannelOptIn>(bco => bco.BusinessId == businessChannelOptIn.BusinessId && bco.ChannelId == businessChannelOptIn.ChannelId && bco.ChannelTermsId == businessChannelOptIn.ChannelTermsId))).Callback(delegate { businessChannelOptIn.Id = 1; });
                businessChannelOptInDao.Setup(dao => dao.Create(It.Is<BusinessChannelOptIn>(bco => bco.BusinessId == logicalGroupChannelOptIn.BusinessId && bco.ChannelId == logicalGroupChannelOptIn.ChannelId && bco.ChannelTermsId == logicalGroupChannelOptIn.ChannelTermsId))).Callback(delegate { logicalGroupChannelOptIn.Id = 2; });
                
                channelDaoMock.Setup(ch => ch.GetFirstLogicalGroupChannelByChannelId(businessChannelOptIn.ChannelId.Value))
                              .Returns(logicalGroupChannel);

                // logical group isn't in a group
                channelDaoMock.Setup(ch => ch.GetById(logicalGroupChannelOptIn.ChannelId.Value)).Returns(new Channel
                {
                    Id = logicalGroupChannel.Id,
                    SupportsCustomCancPolicy = false
                });
                channelDaoMock.Setup(ch => ch.GetFirstLogicalGroupChannelByChannelId(logicalGroupChannel.Id))
                              .Returns(nullLogical);
                
                // show it isn't opted in to group
                businessChannelOptInDao.Setup(
                    bc => bc.IsChannelOptedInForBusiness(businessChannelOptIn.BusinessId.Value, logicalGroupChannel.Id))
                                       .Returns(false);
                businessChannelOptInDao.Setup(dao => dao.UpdatePrePaySettings(It.IsAny<BusinessChannelOptIn>()));
                
                eventTrackingManagerMock.Expect(be => be.CreateBusinessEventAsync(It.Is<long>(l => l == businessChannelOptIn.BusinessId),
                                                It.Is<BusinessEventTypesEnum>(ev => ev == BusinessEventTypesEnum.ChannelOptIn),
                                                It.IsAny<string>(), It.IsAny<string>()));

                distributionManagerMock.Setup(dmm => dmm.UpdateGroupChannelsWithCancelPrepaySettings(logicalGroupChannel, businessChannelOptIn, It.IsAny<string>()));

                // Act
                distributionManagerMock.Object.OptInToChannel(businessChannelOptIn, CULTURE_CODE);

                // Assert
                Assert.AreEqual(ChannelOptInStatusEnum.Live.GetCode(), businessChannelOptIn.ChannelOptInStatus.Code, "The channel opt in status code is incorrect.");
                Assert.AreEqual(1, businessChannelOptIn.Id, "The id returned is incorrect.");
                Assert.AreEqual(2, logicalGroupChannelOptIn.Id, "logical group was not opted in.");

                channelDaoMock.VerifyAll();
                businessChannelOptInDao.VerifyAll();
                eventTrackingManagerMock.Verify(be => be.CreateBusinessEventAsync(It.Is<long>(l => l == businessChannelOptIn.BusinessId),
                                                It.Is<BusinessEventTypesEnum>(ev => ev == BusinessEventTypesEnum.ChannelOptIn),
                                                It.IsAny<string>(), It.IsAny<string>()), Times.Exactly(2));
                distributionManagerMock.VerifyAll();
                prePayDaoMock.VerifyAll();
                businessDaoMock.VerifyAll();

                // Reset the Daos
                distributionManager.BusinessChannelOptInDao = new BusinessChannelOptInDao();
            }
예제 #5
0
            public void OptOutOfLastChannelInGroupOptsOutGroupAsWell()
            {
                // Arrange
                var businessChannelOptInDao = new Mock<IBusinessChannelOptInDao>();
                var eventTrackingManagerMock = new Mock<IEventTrackingManager>();
                var channelDaoMock = new Mock<IChannelDao>();
                
                distributionManager.BusinessChannelOptInDao = businessChannelOptInDao.Object;
                distributionManager.EventTrackingManager = eventTrackingManagerMock.Object;
                distributionManager.ChannelDao = channelDaoMock.Object;
                
                var businessChannelOptIn = new BusinessChannelOptIn
                {
                    BusinessId = 1,
                    ChannelId = 1,
                    ChannelTermsId = 1
                };
                var logicalGroupChannelOptIn = new BusinessChannelOptIn
                {
                    BusinessId = 1,
                    ChannelId = 2,
                    ChannelTermsId = 2
                };

                Channel nullLogical = null;
                Channel logicalGroupChannel = new Channel
                {
                    Id = 2,
                    ChannelType = ChannelTypeEnum.LogicalGroup,
                    ChannelTermsId = 2
                };

                businessChannelOptInDao.Setup(
                    dao => dao.Remove(businessChannelOptIn.BusinessId.Value, businessChannelOptIn.ChannelId.Value));

                businessChannelOptInDao.Setup(
                    dao => dao.Remove(logicalGroupChannelOptIn.BusinessId.Value, logicalGroupChannelOptIn.ChannelId.Value));

                channelDaoMock.Setup(ch => ch.GetFirstLogicalGroupChannelByChannelId(businessChannelOptIn.ChannelId.Value))
                              .Returns(logicalGroupChannel);

                businessChannelOptInDao.Setup(
                    bc =>
                    bc.GetOptedInChannelsRelatedToGroup(businessChannelOptIn.BusinessId.Value, logicalGroupChannel.Id))
                                       .Returns
                    (new List<int>
                        {
                            businessChannelOptIn.ChannelId.Value
                        });

                // logical group isn't in a group
                channelDaoMock.Setup(ch => ch.GetFirstLogicalGroupChannelByChannelId(logicalGroupChannel.Id))
                              .Returns(nullLogical);

                
                eventTrackingManagerMock.Expect(be => be.CreateBusinessEventAsync(It.Is<long>(l => l == businessChannelOptIn.BusinessId),
                                                It.Is<BusinessEventTypesEnum>(ev => ev == BusinessEventTypesEnum.ChannelOptOut),
                                                It.IsAny<string>(), It.IsAny<string>()));

                // Act
                distributionManager.OptOutOfChannel(businessChannelOptIn);

                // Assert
                channelDaoMock.VerifyAll();
                businessChannelOptInDao.VerifyAll();
                eventTrackingManagerMock.Verify(be => be.CreateBusinessEventAsync(It.Is<long>(l => l == businessChannelOptIn.BusinessId),
                                                It.Is<BusinessEventTypesEnum>(ev => ev == BusinessEventTypesEnum.ChannelOptOut),
                                                It.IsAny<string>(), It.IsAny<string>()), Times.Exactly(2));
                
                // Reset the Daos
                distributionManager.BusinessChannelOptInDao = new BusinessChannelOptInDao();
            }
예제 #6
0
        /// <summary>
        /// Set provider and distributor information on settlement TransactionModel 
        /// </summary>
        /// <param name="transactionModel">TransactionModel</param>
        /// <param name="business">Business</param>
        /// <param name="distributorBusiness">Distributor business</param>
        /// <param name="channel">Channel</param>
        public virtual void SetProviderDistributorInformationOnTransactionModel(TransactionModel transactionModel, Model.Business.Business business, Model.Business.Business distributorBusiness, Channel channel)
        {
            Helper.ArgumentNotNull(transactionModel, "transactionModel");
            Helper.ArgumentNotNull(business, "business");
            Helper.ArgumentNotNull(distributorBusiness, "distributorBusiness");
            Helper.ArgumentNotNull(channel, "channel");

            transactionModel.ProviderReferenceCode = business.ReferenceCode;
            transactionModel.ProviderShortname = business.ShortName;
            transactionModel.SupplyPartnerReferenceCode = 0.ToString(CultureInfo.InvariantCulture);
            transactionModel.DistributorShortName = channel.ShortName;
            transactionModel.DistributorReferenceCode = distributorBusiness.ReferenceCode;                
            transactionModel.BusinessAccountType = distributorBusiness.BusinessType.ToString();

            logger.LogInfo("SetProviderDistributorInformationOnTransactionModel completed");
        }