Exemplo n.º 1
0
        public MarkupsApplyingOrder()
        {
            var allPolicies = _agentPolicies
                              .Union(_counterpartyPolicies)
                              .Union(_globalPolicies)
                              .Union(_agencyPolicies);

            var edoContextMock = MockEdoContextFactory.Create();

            edoContextMock.Setup(c => c.MarkupPolicies)
            .Returns(DbSetMockProvider.GetDbSetMock(allPolicies));

            var currencyRateServiceMock = new Mock <ICurrencyRateService>();

            currencyRateServiceMock
            .Setup(c => c.Get(It.IsAny <Currencies>(), It.IsAny <Currencies>()))
            .Returns(new ValueTask <Result <decimal> >(Result.Success((decimal)1)));

            var agentSettingsMock = new Mock <IAgentSettingsManager>();

            agentSettingsMock
            .Setup(s => s.GetUserSettings(It.IsAny <AgentContext>()))
            .Returns(Task.FromResult(new AgentUserSettings(true, It.IsAny <Currencies>(), It.IsAny <Currencies>(), It.IsAny <int>())));

            var accommodationBookingSettingsServiceMock = new Mock <IAccommodationBookingSettingsService>();

            accommodationBookingSettingsServiceMock
            .Setup(s => s.Get(It.IsAny <AgentContext>()))
            .ReturnsAsync(new AccommodationBookingSettings(default, default, default, false, default));
Exemplo n.º 2
0
        private BookingRecordsUpdater CreateBookingRecordsUpdaterService()
        {
            var context = MockEdoContextFactory.Create();

            context
            .Setup(x => x.Bookings)
            .Returns(DbSetMockProvider.GetDbSetMock(Bookings));

            context
            .Setup(x => x.Agents)
            .Returns(DbSetMockProvider.GetDbSetMock(Agents));

            context
            .Setup(x => x.Agencies)
            .Returns(DbSetMockProvider.GetDbSetMock(Agencies));

            return(new BookingRecordsUpdater(
                       Mock.Of <IDateTimeProvider>(),
                       Mock.Of <IBookingInfoService>(),
                       _notificationServiceMock.Object,
                       _bookingMoneyReturnServiceMock.Object,
                       _documentsMailingServiceMock.Object,
                       _supplierOrderServiceMock.Object,
                       Mock.Of <INotificationService>(),
                       Mock.Of <IBookingChangeLogService>(),
                       Mock.Of <IBookingAnalyticsService>(),
                       context.Object,
                       Mock.Of <ILogger <BookingRecordsUpdater> >()));
        }
Exemplo n.º 3
0
        public CanPayWithAccount()
        {
            var edoContextMock        = MockEdoContextFactory.Create();
            var bookingRecordsManager = new BookingRecordsManager(edoContextMock.Object, Mock.Of <IDateTimeProvider>(), Mock.Of <ITagProcessor>(),
                                                                  Mock.Of <IAccommodationService>(), Mock.Of <IAccommodationBookingSettingsService>());

            var dateTimeProvider = new DefaultDateTimeProvider();

            _accountPaymentService = new AccountPaymentService(Mock.Of <IAccountPaymentProcessingService>(), edoContextMock.Object,
                                                               dateTimeProvider, Mock.Of <IAccountManagementService>(), Mock.Of <IEntityLocker>(), bookingRecordsManager);

            edoContextMock
            .Setup(c => c.AgencyAccounts)
            .Returns(DbSetMockProvider.GetDbSetMock(new List <AgencyAccount>
            {
                new AgencyAccount
                {
                    Id       = 1,
                    Balance  = 0,
                    Currency = Currencies.USD,
                    AgencyId = 1,
                    IsActive = true
                },
                new AgencyAccount
                {
                    Id       = 3,
                    Balance  = 5,
                    Currency = Currencies.USD,
                    AgencyId = 3,
                    IsActive = true
                }
            }));
        }
        private (AgentStatusManagementService, EdoContext) SetupData()
        {
            var relations = new[]
            {
                new AgentAgencyRelation
                {
                    AgencyId = 1,
                    AgentId  = 1,
                    IsActive = true
                },
                new AgentAgencyRelation
                {
                    AgencyId = 1,
                    AgentId  = 2,
                    IsActive = false
                },
                new AgentAgencyRelation
                {
                    AgencyId = 1,
                    AgentId  = 3,
                    IsActive = true
                }
            };

            var edoContextMock = MockEdoContextFactory.Create();

            var service = new AgentStatusManagementService(edoContextMock.Object);

            edoContextMock.Setup(x => x.AgentAgencyRelations).Returns(DbSetMockProvider.GetDbSetMock(relations));

            return(service, edoContextMock.Object);
        }
Exemplo n.º 5
0
        private static BookingDocumentsService CreateBookingDocumentsService(Booking booking)
        {
            // If property is not initialized thrown NullReferenceException
            booking.Rooms = new List <BookedRoom>();

            var edoContext = MockEdoContextFactory.Create();

            edoContext.Setup(c => c.Bookings)
            .Returns(DbSetMockProvider.GetDbSetMock(new List <Booking> {
                booking
            }));

            var bookingRecordManager = new BookingRecordsManager(
                edoContext.Object,
                Mock.Of <IDateTimeProvider>(),
                Mock.Of <ITagProcessor>(),
                Mock.Of <IAccommodationService>(),
                Mock.Of <IAccommodationBookingSettingsService>());

            return(new BookingDocumentsService(
                       edoContext.Object,
                       Mock.Of <IOptions <BankDetails> >(),
                       bookingRecordManager,
                       Mock.Of <IAccommodationService>(),
                       Mock.Of <ICounterpartyService>(),
                       Mock.Of <IInvoiceService>(),
                       Mock.Of <IReceiptService>(),
                       Mock.Of <IImageFileService>()));
        }
Exemplo n.º 6
0
        public CanPayWithAccount()
        {
            var edoContextMock = MockEdoContextFactory.Create();

            var dateTimeProvider = new DefaultDateTimeProvider();

            _accountPaymentService = new AccountPaymentService(Mock.Of <IAccountPaymentProcessingService>(), edoContextMock.Object,
                                                               dateTimeProvider, Mock.Of <IBalanceManagementNotificationsService>());

            edoContextMock
            .Setup(c => c.AgencyAccounts)
            .Returns(DbSetMockProvider.GetDbSetMock(new List <AgencyAccount>
            {
                new AgencyAccount
                {
                    Id       = 1,
                    Balance  = 0,
                    Currency = Currencies.USD,
                    AgencyId = 1,
                    IsActive = true
                },
                new AgencyAccount
                {
                    Id       = 3,
                    Balance  = 5,
                    Currency = Currencies.USD,
                    AgencyId = 3,
                    IsActive = true
                }
            }));
        }
Exemplo n.º 7
0
        public MarkupsApplyingOrder()
        {
            var allPolicies = _agentPolicies
                              .Union(_globalPolicies)
                              .Union(_agencyPolicies)
                              .ToList();

            var edoContextMock = MockEdoContextFactory.Create();

            edoContextMock.Setup(c => c.Agencies)
            .Returns(DbSetMockProvider.GetDbSetMock(_agencies));

            var currencyRateServiceMock = new Mock <ICurrencyRateService>();

            currencyRateServiceMock
            .Setup(c => c.Get(It.IsAny <Currencies>(), It.IsAny <Currencies>()))
            .Returns(new ValueTask <Result <decimal> >(Result.Success((decimal)1)));

            var markupPolicyStorage = new MarkupPolicyStorage(Mock.Of <IOptionsMonitor <MarkupPolicyStorageOptions> >(_ => _.CurrentValue ==
                                                                                                                      new MarkupPolicyStorageOptions {
                Timeout = TimeSpan.FromMilliseconds(1)
            }));

            markupPolicyStorage.Set(allPolicies);

            _markupPolicyService = new MarkupPolicyService(markupPolicyStorage);

            var discountServiceMock = new  Mock <IDiscountFunctionService>();

            discountServiceMock.Setup(service => service.Get(It.IsAny <MarkupPolicy>(), It.IsAny <MarkupSubjectInfo>()))
            .ReturnsAsync((price => new ValueTask <MoneyAmount>(price)));

            _markupService = new MarkupService(_markupPolicyService, discountServiceMock.Object, new MarkupPolicyTemplateService(), currencyRateServiceMock.Object, new FakeMemoryFlow());
        }
Exemplo n.º 8
0
        public AgentPermissionManagementServiceTests()
        {
            var edoContextMock = MockEdoContextFactory.Create();

            edoContextMock.Setup(x => x.AgentAgencyRelations).Returns(DbSetMockProvider.GetDbSetMock(_relations));

            _agentPermissionManagementService = new AgentPermissionManagementService(edoContextMock.Object);
        }
        private static EdoContext CreateContext()
        {
            var context = MockEdoContextFactory.Create();

            context
            .Setup(x => x.Bookings)
            .Returns(DbSetMockProvider.GetDbSetMock(Bookings));
            return(context.Object);
        }
Exemplo n.º 10
0
        public GetBalanceTests()
        {
            var entityLockerMock = new Mock <IEntityLocker>();

            entityLockerMock.Setup(l => l.Acquire <It.IsAnyType>(It.IsAny <string>(), It.IsAny <string>())).Returns(Task.FromResult(Result.Success()));

            var edoContextMock   = MockEdoContextFactory.Create();
            var mockedEdoContext = edoContextMock.Object;

            _agencyAccountService = new AgencyAccountService(mockedEdoContext, entityLockerMock.Object,
                                                             Mock.Of <IManagementAuditService>(), Mock.Of <IAccountBalanceAuditService>());

            var strategy = new ExecutionStrategyMock();

            var dbFacade = new Mock <DatabaseFacade>(mockedEdoContext);

            dbFacade.Setup(d => d.CreateExecutionStrategy()).Returns(strategy);
            edoContextMock.Setup(c => c.Database).Returns(dbFacade.Object);

            edoContextMock
            .Setup(c => c.Agencies)
            .Returns(DbSetMockProvider.GetDbSetMock(new List <Agency>
            {
                new Agency
                {
                    Id = 1
                },
                // Having more than one element for predicates to be tested too
                new Agency
                {
                    Id = 2
                },
            }));

            edoContextMock
            .Setup(c => c.AgencyAccounts)
            .Returns(DbSetMockProvider.GetDbSetMock(new List <AgencyAccount>
            {
                new AgencyAccount
                {
                    Id       = 1,
                    Balance  = 1000,
                    Currency = Currencies.USD,
                    AgencyId = 1,
                    IsActive = true
                },
                new AgencyAccount
                {
                    Id       = 1,
                    Balance  = 0,
                    Currency = Currencies.USD,
                    AgencyId = 1,
                    IsActive = true
                }
            }));
        }
Exemplo n.º 11
0
        private static BookingDocumentsService CreateBookingDocumentsService()
        {
            var edoContext = MockEdoContextFactory.Create();

            edoContext.Setup(c => c.Agents)
            .Returns(DbSetMockProvider.GetDbSetMock(new[]
            {
                new Agent
                {
                    FirstName = "Test",
                    LastName  = "Test",
                    Id        = 1
                }
            }));

            var accommodation = new Accommodation(htId: string.Empty,
                                                  name: string.Empty,
                                                  accommodationAmenities: new List <string>(0),
                                                  additionalInfo: new Dictionary <string, string>(),
                                                  category: string.Empty,
                                                  contacts: new ContactInfo(),
                                                  location: new LocationInfo(countryCode: string.Empty,
                                                                             countryHtId: string.Empty,
                                                                             country: string.Empty,
                                                                             localityHtId: string.Empty,
                                                                             locality: string.Empty,
                                                                             localityZoneHtId: string.Empty,
                                                                             localityZone: string.Empty,
                                                                             coordinates: new GeoPoint(0d, 0d),
                                                                             address: string.Empty,
                                                                             locationDescriptionCode: new LocationDescriptionCodes(),
                                                                             new List <PoiInfo>(0)),
                                                  photos: new List <ImageInfo>(),
                                                  AccommodationRatings.NotRated,
                                                  schedule: new ScheduleInfo(checkInTime: string.Empty,
                                                                             checkOutTime: string.Empty),
                                                  textualDescriptions: new List <TextualDescription>(0),
                                                  type: PropertyTypes.Hotels,
                                                  suppliers: new List <SupplierInfo>(0),
                                                  modified: DateTime.UtcNow);

            var accommodationMapperClient = new Mock <IAccommodationMapperClient>();

            accommodationMapperClient.Setup(c => c.GetAccommodation(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(accommodation);

            return(new BookingDocumentsService(
                       edoContext.Object,
                       Mock.Of <IOptions <BankDetails> >(),
                       accommodationMapperClient.Object,
                       Mock.Of <IInvoiceService>(),
                       Mock.Of <IReceiptService>(),
                       Mock.Of <IImageFileService>(),
                       Mock.Of <IAdminAgencyManagementService>()));
        }
Exemplo n.º 12
0
        public RefundMoneyTests()
        {
            var entityLockerMock = new Mock <IEntityLocker>();

            entityLockerMock.Setup(l => l.Acquire <It.IsAnyType>(It.IsAny <string>(), It.IsAny <string>())).Returns(Task.FromResult(Result.Success()));

            var edoContextMock   = MockEdoContextFactory.Create();
            var edoContextMock1  = edoContextMock;
            var mockedEdoContext = edoContextMock.Object;

            var accountPaymentProcessingService = new AccountPaymentProcessingService(
                mockedEdoContext, entityLockerMock.Object, Mock.Of <IAccountBalanceAuditService>());

            var dateTimeProviderMock = new Mock <IDateTimeProvider>();

            dateTimeProviderMock.Setup(d => d.UtcNow()).Returns(CancellationDate);

            _accountPaymentService = new AccountPaymentService(accountPaymentProcessingService, mockedEdoContext,
                                                               dateTimeProviderMock.Object, Mock.Of <IBalanceManagementNotificationsService>());

            var strategy = new ExecutionStrategyMock();

            var dbFacade = new Mock <DatabaseFacade>(mockedEdoContext);

            dbFacade.Setup(d => d.CreateExecutionStrategy()).Returns(strategy);
            edoContextMock.Setup(c => c.Database).Returns(dbFacade.Object);

            edoContextMock1
            .Setup(c => c.Agencies)
            .Returns(DbSetMockProvider.GetDbSetMock(new List <Agency>
            {
                new Agency
                {
                    Id       = 1,
                    Name     = "Agency",
                    ParentId = null,
                },
            }));

            edoContextMock1
            .Setup(c => c.AgencyAccounts)
            .Returns(DbSetMockProvider.GetDbSetMock(new List <AgencyAccount>
            {
                _account,
            }));


            edoContextMock1
            .Setup(c => c.Payments)
            .Returns(DbSetMockProvider.GetDbSetMock(new List <Payment>
            {
                _payment,
            }));
        }
Exemplo n.º 13
0
        public PermissionCheckerTests()
        {
            var edoContextMock = MockEdoContextFactory.Create();

            edoContextMock.Setup(x => x.AgentRoles)
            .Returns(DbSetMockProvider.GetDbSetMock(_roles));
            edoContextMock.Setup(x => x.AgentAgencyRelations)
            .Returns(DbSetMockProvider.GetDbSetMock(_relations));

            _permissionChecker = new PermissionChecker(edoContextMock.Object, new FakeDoubleFlow());
        }
Exemplo n.º 14
0
        private static BookingDocumentsService CreateBookingDocumentsService(Booking booking, bool hasInvoices)
        {
            // If property is not initialized thrown NullReferenceException
            booking.Rooms = new List <BookedRoom>();

            var edoContext = MockEdoContextFactory.Create();

            edoContext.Setup(c => c.Bookings)
            .Returns(DbSetMockProvider.GetDbSetMock(new List <Booking> {
                booking
            }));

            var bookingRecordManager = new BookingRecordsManager(
                edoContext.Object,
                Mock.Of <IDateTimeProvider>(),
                Mock.Of <ITagProcessor>(),
                Mock.Of <IAccommodationService>(),
                Mock.Of <IAccommodationBookingSettingsService>());

            var invoices = hasInvoices
                ? new List <(DocumentRegistrationInfo Metadata, BookingInvoiceData Data)>
            {
                (
                    new DocumentRegistrationInfo(It.IsAny <string>(), It.IsAny <DateTime>()),
                    new BookingInvoiceData(
                        new BookingInvoiceData.BuyerInfo(),
                        new BookingInvoiceData.SellerInfo(),
                        It.IsAny <string>(),
                        new List <BookingInvoiceData.InvoiceItemInfo>(),
                        new MoneyAmount(),
                        It.IsAny <DateTime>(),
                        It.IsAny <DateTime>(),
                        It.IsAny <DateTime>(),
                        It.IsAny <BookingPaymentStatuses>(),
                        It.IsAny <DateTime?>())
                )
            }
                : new List <(DocumentRegistrationInfo Metadata, BookingInvoiceData Data)>();

            var invoiceServiceMock = new Mock <IInvoiceService>();

            invoiceServiceMock.Setup(i => i.Get <BookingInvoiceData>(It.IsAny <ServiceTypes>(), It.IsAny <ServiceSource>(), It.IsAny <string>()))
            .ReturnsAsync(invoices);

            return(new BookingDocumentsService(
                       edoContext.Object,
                       Mock.Of <IOptions <BankDetails> >(),
                       bookingRecordManager,
                       Mock.Of <IAccommodationService>(),
                       Mock.Of <ICounterpartyService>(),
                       invoiceServiceMock.Object,
                       Mock.Of <IReceiptService>(),
                       Mock.Of <IImageFileService>()));
        }
Exemplo n.º 15
0
        public AgentServiceTests()
        {
            var edoContextMock = MockEdoContextFactory.Create();

            edoContextMock.Setup(x => x.Counterparties).Returns(DbSetMockProvider.GetDbSetMock(_counterparties));
            edoContextMock.Setup(x => x.Agencies).Returns(DbSetMockProvider.GetDbSetMock(_agencies));
            edoContextMock.Setup(x => x.Agents).Returns(DbSetMockProvider.GetDbSetMock(_agents));
            edoContextMock.Setup(x => x.AgentAgencyRelations).Returns(DbSetMockProvider.GetDbSetMock(_relations));
            edoContextMock.Setup(x => x.MarkupPolicies).Returns(DbSetMockProvider.GetDbSetMock(new List <MarkupPolicy>()));

            _agentService = new AgentService(edoContextMock.Object, new DefaultDateTimeProvider(), new MarkupPolicyTemplateService());
        }
Exemplo n.º 16
0
        public AgentServiceTests()
        {
            var edoContextMock = MockEdoContextFactory.Create();

            edoContextMock.Setup(x => x.Agencies).Returns(DbSetMockProvider.GetDbSetMock(_agencies));
            edoContextMock.Setup(x => x.Agents).Returns(DbSetMockProvider.GetDbSetMock(_agents));
            edoContextMock.Setup(x => x.AgentAgencyRelations).Returns(DbSetMockProvider.GetDbSetMock(_relations));
            edoContextMock.Setup(x => x.MarkupPolicies).Returns(DbSetMockProvider.GetDbSetMock(new List <MarkupPolicy>()));
            edoContextMock.Setup(x => x.DisplayMarkupFormulas).Returns(DbSetMockProvider.GetDbSetMock(new List <DisplayMarkupFormula>()));
            edoContextMock.Setup(x => x.AgentRoles).Returns(DbSetMockProvider.GetDbSetMock(_agentRoles));

            _agentService = new AgentService(edoContextMock.Object, new DefaultDateTimeProvider());
        }
Exemplo n.º 17
0
        private static BookingsProcessingService CreateProcessingService()
        {
            var context = MockEdoContextFactory.Create();

            context
            .Setup(c => c.Bookings)
            .Returns(DbSetMockProvider.GetDbSetMock(Bookings));

            return(new BookingsProcessingService(Mock.Of <IBookingPaymentService>(),
                                                 Mock.Of <IBookingManagementService>(),
                                                 Mock.Of <IBookingMailingService>(),
                                                 context.Object));
        }
Exemplo n.º 18
0
        private EdoContext GetDbContextMock()
        {
            var edoContextMock = new Mock <EdoContext>(new DbContextOptions <EdoContext>());

            var strategy = new ExecutionStrategyMock();

            var dbFacade = new Mock <DatabaseFacade>(edoContextMock.Object);

            dbFacade.Setup(d => d.CreateExecutionStrategy()).Returns(strategy);
            edoContextMock.Setup(c => c.Database).Returns(dbFacade.Object);

            edoContextMock
            .Setup(c => c.Counterparties)
            .Returns(DbSetMockProvider.GetDbSetMock(new List <Counterparty>
            {
                new Counterparty
                {
                    Id = 1
                },
                new Counterparty
                {
                    Id = 2
                },
            }));

            edoContextMock
            .Setup(c => c.CounterpartyAccounts)
            .Returns(DbSetMockProvider.GetDbSetMock(new List <CounterpartyAccount>
            {
                new CounterpartyAccount
                {
                    Id             = 1,
                    Balance        = 1000,
                    Currency       = Currencies.USD,
                    CounterpartyId = 1,
                    IsActive       = true
                },
                new CounterpartyAccount
                {
                    Id             = 2,
                    Balance        = 1000,
                    Currency       = Currencies.USD,
                    CounterpartyId = 2,
                    IsActive       = true
                }
            }));

            edoContextMock.Setup(c => c.AccountBalanceAuditLogs).Returns(DbSetMockProvider.GetDbSetMock(new List <AccountBalanceAuditLogEntry>()));

            return(edoContextMock.Object);
        }
Exemplo n.º 19
0
        private EdoContext GetDbContextMock()
        {
            var edoContextMock = new Mock <EdoContext>(new DbContextOptions <EdoContext>());

            var strategy = new ExecutionStrategyMock();

            var dbFacade = new Mock <DatabaseFacade>(edoContextMock.Object);

            dbFacade.Setup(d => d.CreateExecutionStrategy()).Returns(strategy);
            edoContextMock.Setup(c => c.Database).Returns(dbFacade.Object);

            edoContextMock
            .Setup(c => c.Agencies)
            .Returns(DbSetMockProvider.GetDbSetMock(new List <Agency>
            {
                new Agency
                {
                    Id       = 1,
                    ParentId = null,
                },
                new Agency
                {
                    Id       = 2,
                    ParentId = null,
                }
            }));

            edoContextMock
            .Setup(c => c.AgencyAccounts)
            .Returns(DbSetMockProvider.GetDbSetMock(new List <AgencyAccount>
            {
                new AgencyAccount
                {
                    Id       = 1,
                    Balance  = 120,
                    Currency = Currencies.USD,
                    AgencyId = 2,
                    IsActive = true
                },
                new AgencyAccount
                {
                    Id       = 2,
                    Balance  = 120,
                    Currency = Currencies.USD,
                    AgencyId = 2,
                    IsActive = true
                }
            }));

            return(edoContextMock.Object);
        }
Exemplo n.º 20
0
        private BookingsProcessingService CreateProcessingService(IEnumerable <Booking> bookings)
        {
            var context = MockEdoContextFactory.Create();

            context.Setup(c => c.Bookings)
            .Returns(DbSetMockProvider.GetDbSetMock(bookings));

            var service = new BookingsProcessingService(Mock.Of <IBookingPaymentService>(),
                                                        Mock.Of <IBookingManagementService>(),
                                                        Mock.Of <IBookingMailingService>(),
                                                        context.Object);

            return(service);
        }
Exemplo n.º 21
0
        public UserSettings()
        {
            var edoContextMock = MockEdoContextFactory.Create();

            _settingsManager = new AgentSettingsManager(edoContextMock.Object, new NewtonsoftJsonSerializer());
            edoContextMock
            .Setup(c => c.Agents)
            .Returns(DbSetMockProvider.GetDbSetMock(new List <Agent>
            {
                new Agent
                {
                    Id = 1,
                }
            }));
        }
Exemplo n.º 22
0
        public HasPermissionTests()
        {
            var edoContextMock = MockEdoContextFactory.Create();

            edoContextMock.Setup(x => x.Administrators)
            .Returns(DbSetMockProvider.GetDbSetMock(_administrators));
            edoContextMock.Setup(x => x.AdministratorRoles)
            .Returns(DbSetMockProvider.GetDbSetMock(_administratorRoles));

            var tokenInfoAccessorMock = new Mock <ITokenInfoAccessor>();

            tokenInfoAccessorMock.Setup(x => x.GetIdentity())
            .Returns("hash");

            _administratorContext = new HttpBasedAdministratorContext(edoContextMock.Object, tokenInfoAccessorMock.Object);
        }
Exemplo n.º 23
0
        private BookingsProcessingService CreateProcessingService(IBookingMailingService mailingService)
        {
            var context = MockEdoContextFactory.Create();

            context.Setup(c => c.Bookings)
            .Returns(DbSetMockProvider.GetDbSetMock(Bookings));

            context.Setup(c => c.Agents)
            .Returns(DbSetMockProvider.GetDbSetMock(new[] { Agent }));

            var service = new BookingsProcessingService(Mock.Of <IBookingPaymentService>(),
                                                        Mock.Of <IBookingManagementService>(),
                                                        mailingService,
                                                        context.Object);

            return(service);
        }
Exemplo n.º 24
0
        private static BookingsProcessingService CreateProcessingService()
        {
            var context = MockEdoContextFactory.Create();

            context
            .Setup(c => c.Bookings)
            .Returns(DbSetMockProvider.GetDbSetMock(Bookings));

            return(new BookingsProcessingService(Mock.Of <IBookingAccountPaymentService>(),
                                                 Mock.Of <IBookingCreditCardPaymentService>(),
                                                 Mock.Of <ISupplierBookingManagementService>(),
                                                 Mock.Of <IBookingNotificationService>(),
                                                 Mock.Of <IBookingReportsService>(),
                                                 context.Object,
                                                 Mock.Of <IBookingRecordsUpdater>(),
                                                 Mock.Of <IDateTimeProvider>()));
        }
Exemplo n.º 25
0
        private BookingsProcessingService CreateProcessingService(IBookingPaymentService bookingPaymentService       = null,
                                                                  IBookingManagementService bookingManagementService = null)
        {
            bookingPaymentService ??= Mock.Of <IBookingPaymentService>();
            bookingManagementService ??= Mock.Of <IBookingManagementService>();

            var context = MockEdoContextFactory.Create();

            context.Setup(c => c.Bookings)
            .Returns(DbSetMockProvider.GetDbSetMock(Bookings));

            var service = new BookingsProcessingService(bookingPaymentService,
                                                        bookingManagementService,
                                                        Mock.Of <IBookingMailingService>(),
                                                        context.Object);

            return(service);
        }
        public AccommodationManagementServiceTests()
        {
            var dbContextMock = DirectContractsDbContextMockFactory.Create();

            dbContextMock.Setup(x => x.ServiceSuppliers).Returns(DbSetMockProvider.GetDbSetMock(_serviceSuppliers));
            dbContextMock.Setup(x => x.Managers).Returns(DbSetMockProvider.GetDbSetMock(_managers));
            dbContextMock.Setup(x => x.ManagerServiceSupplierRelations).Returns(DbSetMockProvider.GetDbSetMock(_relations));
            dbContextMock.Setup(x => x.Accommodations).Returns(DbSetMockProvider.GetDbSetMock(_accommodations));
            dbContextMock.Setup(x => x.Rooms).Returns(DbSetMockProvider.GetDbSetMock(_rooms));

            _accommodationManagementService = new AccommodationManagementService(
                new ManagerContextService(dbContextMock.Object, new TokenInfoAccessorMock(), new Sha256HashGenerator()),
                new ServiceSupplierContextService(dbContextMock.Object),
                new ImageManagementServiceMock(),
                new AmenityService(dbContextMock.Object),
                dbContextMock.Object,
                new GeometryFactory(),
                _dateTimeProvider);
        }
Exemplo n.º 27
0
        public GettingLinkData()
        {
            var edoContextMock = MockEdoContextFactory.Create();

            edoContextMock.Setup(c => c.PaymentLinks)
            .Returns(DbSetMockProvider.GetDbSetMock(Links));

            var emptyOptions       = Options.Create(new PaymentLinkOptions());
            var companyServiceMock = new Mock <ICompanyService>();

            companyServiceMock.Setup(c => c.Get())
            .Returns(Task.FromResult(Result.Success(new CompanyInfo())));

            var dateTimeProvider = new DefaultDateTimeProvider();

            _linkStorage = new PaymentLinksStorage(edoContextMock.Object,
                                                   dateTimeProvider,
                                                   emptyOptions,
                                                   Mock.Of <ITagProcessor>());
        }
Exemplo n.º 28
0
        private void SetupInitialData()
        {
            _edoContextMock
            .Setup(c => c.Agencies)
            .Returns(DbSetMockProvider.GetDbSetMock(new List <Agency>
            {
                new Agency
                {
                    Id       = 1,
                    ParentId = null,
                },
                new Agency
                {
                    Id       = 2,
                    ParentId = null,
                }
            }));

            _edoContextMock
            .Setup(c => c.AgencyAccounts)
            .Returns(DbSetMockProvider.GetDbSetMock(new List <AgencyAccount>
            {
                new AgencyAccount
                {
                    Id       = 1,
                    Balance  = 1000,
                    Currency = Currencies.USD,
                    AgencyId = 2,
                    IsActive = true
                },
                new AgencyAccount
                {
                    Id       = 2,
                    Balance  = 1000,
                    Currency = Currencies.USD,
                    AgencyId = 2,
                    IsActive = true
                }
            }));
        }
Exemplo n.º 29
0
#pragma warning disable CS8602 // Dereference of a possibly null reference.
        public BalanceNotificationsTests()
        {
            var entityLockerMock = new Mock <IEntityLocker>();

            entityLockerMock.Setup(l => l.Acquire <It.IsAnyType>(It.IsAny <string>(), It.IsAny <string>())).Returns(Task.FromResult(Result.Success()));

            var edoContextMock = MockEdoContextFactory.Create();

            _mockedEdoContext = edoContextMock.Object;

            var strategy = new ExecutionStrategyMock();
            var dbFacade = new Mock <DatabaseFacade>(_mockedEdoContext);

            dbFacade.Setup(d => d.CreateExecutionStrategy()).Returns(strategy);
            edoContextMock.Setup(c => c.Database).Returns(dbFacade.Object);

            edoContextMock
            .Setup(c => c.BalanceNotificationSettings)
            .Returns(DbSetMockProvider.GetDbSetMock(new List <BalanceNotificationSetting>
            {
                new BalanceNotificationSetting
                {
                    AgencyAccountId = 1,
                    Thresholds      = new[] { 100, 200, 500 }
                },
                new BalanceNotificationSetting
                {
                    AgencyAccountId = 2,
                    Thresholds      = new int[0]
                }
            }));

            edoContextMock
            .Setup(c => c.Agencies)
            .Returns(DbSetMockProvider.GetDbSetMock(new List <Agency>
            {
                new Agency
                {
                    Id          = 1,
                    Name        = "AgencyName1",
                    CountryCode = "en"
                },
                new Agency
                {
                    Id          = 2,
                    Name        = "AgencyName2",
                    CountryCode = "en"
                }
            }));

            edoContextMock
            .Setup(c => c.Countries)
            .Returns(DbSetMockProvider.GetDbSetMock(new List <Country>
            {
                new Country
                {
                    Code     = "en",
                    Names    = JsonDocument.Parse("{\"en\": \"Russian Federation\"}"),
                    RegionId = 1
                }
            }));

            edoContextMock
            .Setup(c => c.AgencyAccounts)
            .Returns(DbSetMockProvider.GetDbSetMock(new List <AgencyAccount>
            {
                new AgencyAccount
                {
                    Id       = 1,
                    AgencyId = 1,
                    Currency = Currencies.USD
                },
                new AgencyAccount
                {
                    Id       = 2,
                    AgencyId = 2,
                    Currency = Currencies.AED
                }
            }));

            edoContextMock
            .Setup(c => c.DisplayMarkupFormulas)
            .Returns(DbSetMockProvider.GetDbSetMock(new List <DisplayMarkupFormula>()));
        }
Exemplo n.º 30
0
        public RefundMoneyTests()
        {
            var entityLockerMock = new Mock <IEntityLocker>();

            entityLockerMock.Setup(l => l.Acquire <It.IsAnyType>(It.IsAny <string>(), It.IsAny <string>())).Returns(Task.FromResult(Result.Success()));

            var edoContextMock = MockEdoContextFactory.Create();

            _edoContextMock   = edoContextMock;
            _mockedEdoContext = edoContextMock.Object;

            var accountPaymentProcessingService = new AccountPaymentProcessingService(
                _mockedEdoContext, entityLockerMock.Object, Mock.Of <IAccountBalanceAuditService>());

            _dateTimeProviderMock = new Mock <IDateTimeProvider>();
            _dateTimeProviderMock.Setup(d => d.UtcNow()).Returns(new DateTime(2020, 1, 1));

            var accountManagementService = new AccountManagementService(_mockedEdoContext, _dateTimeProviderMock.Object,
                                                                        Mock.Of <ILogger <AccountManagementService> >(), Mock.Of <IAdministratorContext>(), Mock.Of <IManagementAuditService>(),
                                                                        entityLockerMock.Object);

            var bookingRecordsManager = new BookingRecordsManager(edoContextMock.Object, _dateTimeProviderMock.Object, Mock.Of <ITagProcessor>(),
                                                                  Mock.Of <IAccommodationService>(), Mock.Of <IAccommodationBookingSettingsService>());

            _accountPaymentService = new AccountPaymentService(accountPaymentProcessingService, _mockedEdoContext,
                                                               _dateTimeProviderMock.Object, accountManagementService, entityLockerMock.Object, bookingRecordsManager);

            var strategy = new ExecutionStrategyMock();

            var dbFacade = new Mock <DatabaseFacade>(_mockedEdoContext);

            dbFacade.Setup(d => d.CreateExecutionStrategy()).Returns(strategy);
            edoContextMock.Setup(c => c.Database).Returns(dbFacade.Object);

            _edoContextMock
            .Setup(c => c.Agencies)
            .Returns(DbSetMockProvider.GetDbSetMock(new List <Agency>
            {
                new Agency
                {
                    Id       = 1,
                    Name     = "Agency",
                    ParentId = null,
                },
            }));

            _edoContextMock
            .Setup(c => c.AgencyAccounts)
            .Returns(DbSetMockProvider.GetDbSetMock(new List <AgencyAccount>
            {
                _account,
            }));

            _edoContextMock
            .Setup(c => c.Bookings)
            .Returns(DbSetMockProvider.GetDbSetMock(new List <Booking>
            {
                _booking,
            }));

            _edoContextMock
            .Setup(c => c.Payments)
            .Returns(DbSetMockProvider.GetDbSetMock(new List <Payment>
            {
                _payment,
            }));
        }