public void Arrange() { _repository = new Mock <IGlobalRuleRepository>(); _repository.Setup(x => x.FindActive(It.IsAny <DateTime>())) .ReturnsAsync(new List <GlobalRule> { new GlobalRule { ActiveFrom = DateTime.UtcNow.AddDays(-1), Restriction = 1, RuleType = 0, Id = 123 } }); _reservationRepository = new Mock <IAccountReservationService>(); _reservationRepository.Setup(x => x.GetAccountReservations(It.IsAny <long>())) .ReturnsAsync(new List <Reservation>()); options = new ReservationsConfiguration { ResetReservationDate = DateTime.MinValue, ExpiryPeriodInMonths = 1 }; _options = new Mock <IOptions <ReservationsConfiguration> >(); _options.Setup(x => x.Value).Returns(() => options); _accountsService = new Mock <IAccountsService>(); _accountsService.Setup(x => x.GetAccount(It.IsAny <long>())) .ReturnsAsync(new Domain.Account.Account(1, false, "", 4)); _globalRulesService = new GlobalRulesService(_repository.Object, _options.Object, _reservationRepository.Object, _accountsService.Object, Mock.Of <ILogger <GlobalRulesService> >()); }
public ReservationsDataContext(IDbConnection connection, IOptions <ReservationsConfiguration> configuration, DbContextOptions options, AzureServiceTokenProvider azureServiceTokenProvider, bool configurationIsLocalOrDev) : base(options) { _configuration = configuration.Value; _azureServiceTokenProvider = azureServiceTokenProvider; _configurationIsLocalOrDev = configurationIsLocalOrDev; _connection = connection; }
public void Arrange() { _globalRule = new Domain.Entities.GlobalRule { Id = 0, Restriction = (byte)AccountRestriction.Account, RuleType = (byte)GlobalRuleType.ReservationLimit }; _repository = new Mock <IAccountReservationService>(); _repository.Setup(x => x.GetAccountReservations(ExpectedAccountId)).ReturnsAsync(new List <Reservation> { new Reservation( Guid.NewGuid(), ExpectedAccountId, DateTime.UtcNow.Date, 2, "Name") }); _accountService = new Mock <IAccountsService>(); _accountService.Setup(x => x.GetAccount(It.IsAny <long>())) .ReturnsAsync(new Domain.Account.Account(ExpectedAccountId, false, "test", 1)); ReservationsConfiguration options = new ReservationsConfiguration { ResetReservationDate = DateTime.MinValue }; _options = new Mock <IOptions <ReservationsConfiguration> >(); _options.Setup(x => x.Value).Returns(options); _globalRulesService = new GlobalRulesService(Mock.Of <IGlobalRuleRepository>(), _options.Object, _repository.Object, _accountService.Object, Mock.Of <ILogger <GlobalRulesService> >()); }
public GlobalRulesService( IGlobalRuleRepository repository, IOptions <ReservationsConfiguration> options, IAccountReservationService reservationService, IAccountsService accountService, ILogger <GlobalRulesService> logger ) { _repository = repository; _reservationService = reservationService; _accountService = accountService; _options = options.Value; _logger = logger; }
public static void AddElasticSearch(this IServiceCollection collection, ReservationsConfiguration configuration) { var connectionPool = new SingleNodeConnectionPool(new Uri(configuration.ElasticSearchServerUrl)); var settings = new ConnectionConfiguration(connectionPool); if (!string.IsNullOrEmpty(configuration.ElasticSearchUsername) && !string.IsNullOrEmpty(configuration.ElasticSearchPassword)) { settings.BasicAuthentication(configuration.ElasticSearchUsername, configuration.ElasticSearchPassword); } collection.AddTransient <IElasticLowLevelClient>(sp => new ElasticLowLevelClient(settings)); collection.AddSingleton <IElasticSearchQueries, ElasticSearchQueries>(); }
public AccountLegalEntitiesService(IAccountLegalEntitiesRepository repository, IOptions <ReservationsConfiguration> configuration) { _repository = repository; _configuration = configuration.Value; }
public AzureQueueService(IOptions <ReservationsConfiguration> options) { _configuration = options.Value; }
public AvailableDatesService(IOptions <ReservationsConfiguration> options, ICurrentDateTime currentDateTime) { _currentDateTime = currentDateTime; _configuration = options.Value; }