public ProgramContractValidatorBase(
            BankInformationSystemDbContext context,
            ICurrentDateTimeProvider currentDateTimeProvider)
        {
            Context = context;
            CurrentDateTimeProvider = currentDateTimeProvider;

            RuleFor(x => x.ContractNumber)
            .MustAsync(BeUniqueContractNumberAsync)
            .WithMessage("Contract with specified id already exists.");

            RuleFor(x => x.ProgramStartDate)
            .Must(BeTodayDateOrLater)
            .WithMessage("'{PropertyName}' must be a today or a later date.");

            RuleFor(x => x.ProgramEndDate)
            .GreaterThanOrEqualTo(x => x.ProgramStartDate.AddDays(30).Date)
            .WithMessage("Program term must be at least 30 days.");

            RuleFor(x => x.ContractValidUntil)
            .GreaterThanOrEqualTo(x => x.ProgramEndDate.Date)
            .WithMessage("'{PropertyName}' must be a program end date or a later date.");

            RuleFor(x => x.CustomerId)
            .MustAsync(BeIdOfExistingCustomerAsync)
            .WithMessage("Specified customer does not exist.");
        }
Beispiel #2
0
 public EnvironmentController(
     ICurrentDateTimeProvider currentDateTimeProvider,
     IVirtualDateTimeManager virtualDateTimeManager)
 {
     _currentDateTimeProvider = currentDateTimeProvider;
     _virtualDateTimeManager  = virtualDateTimeManager;
 }
Beispiel #3
0
 public CustomerService(
     CompanyRepository companyRepository,
     ICurrentDateTimeProvider currentDateTimeProvider)
 {
     // TODO(Tevin): Setup DI container and parse the instance into customer service
     this.companyRepository       = companyRepository ?? new CompanyRepository();
     this.currentDateTimeProvider = currentDateTimeProvider ?? new CurrentDateTimeProvider();
 }
Beispiel #4
0
        public CustomerTests()
        {
            this.currentDateTimeProvider = new MockCurrentDateTimeProvider(
                new DateTime(2019, 09, 14, 4, 44, 0));
            var companyRepository = new CompanyRepository();

            this.customerService = new CustomerService(companyRepository, this.currentDateTimeProvider);
        }
        public DepositCreateModelValidator(
            BankInformationSystemDbContext context,
            ICurrentDateTimeProvider currentDateTimeProvider)
            : base(context, currentDateTimeProvider)
        {
            RuleFor(x => x.Amount)
            .GreaterThanOrEqualTo(MinimalDepositAmount)
            .WithMessage($"'{{PropertyName}}' must be at least {MinimalDepositAmount} currency units.");

            RuleFor(x => x.Rate)
            .ExclusiveBetween(0, MaximalDepositRate)
            .WithMessage($"'{{PropertyName}}' must be a positive number less than {MaximalDepositRate}.");
        }
 public DepositService(
     BankInformationSystemDbContext context,
     IMapper mapper,
     IAccountService accountService,
     ICurrentDateTimeProvider currentDateTimeProvider,
     IValidator <DepositCreateModel> depositCreateModelValidator)
 {
     _context                     = context;
     _mapper                      = mapper;
     _accountService              = accountService;
     _currentDateTimeProvider     = currentDateTimeProvider;
     _depositCreateModelValidator = depositCreateModelValidator;
 }
 public BankMetaOperationsService(
     BankInformationSystemDbContext context,
     IMapper mapper,
     ICurrentDateTimeProvider currentDateTimeProvider,
     IVirtualDateTimeManager virtualDateTimeManager,
     IConfiguration configuration)
 {
     _context = context;
     _mapper  = mapper;
     _currentDateTimeProvider = currentDateTimeProvider;
     _virtualDateTimeManager  = virtualDateTimeManager;
     _configuration           = configuration;
 }
        public DataProvider(ISessionFactory sessionFactory, INotifier notifier, IRetrieveService retrieveService,
                            ISendService sendService, ICurrentDateTimeProvider currentDateTimeProvider, bool enabled, string accountNumber, int dayOfMonthToSend)
        {
            if (sessionFactory == null)
            {
                throw new ArgumentNullException(nameof(sessionFactory));
            }

            if (notifier == null)
            {
                throw new ArgumentNullException(nameof(notifier));
            }

            if (retrieveService == null)
            {
                throw new ArgumentNullException(nameof(retrieveService));
            }

            if (sendService == null)
            {
                throw new ArgumentNullException(nameof(sendService));
            }

            if (currentDateTimeProvider == null)
            {
                throw new ArgumentNullException(nameof(currentDateTimeProvider));
            }

            if (accountNumber == null)
            {
                throw new ArgumentNullException(nameof(accountNumber));
            }

            _Enabled                 = enabled;
            _AccountNumber           = accountNumber;
            _RetrieveService         = retrieveService;
            _Notifier                = notifier;
            _SendService             = sendService;
            _CurrentDateTimeProvider = currentDateTimeProvider;
            _SessionFactory          = sessionFactory;
            _DayOfMonthToSend        = dayOfMonthToSend;
        }
        public LoanCreateModelValidator(
            BankInformationSystemDbContext context,
            ICurrentDateTimeProvider currentDateTimeProvider,
            IConfiguration configuration)
            : base(context, currentDateTimeProvider)
        {
            _configuration = configuration;

            RuleFor(x => x.Amount)
            .GreaterThanOrEqualTo(MinimalLoanAmount)
            .WithMessage($"'{{PropertyName}}' must be at least {MinimalLoanAmount} currency units.");

            RuleFor(x => x.Rate)
            .GreaterThanOrEqualTo(MinimalLoanRate)
            .WithMessage($"'{{PropertyName}}' must be greater than or equal to {MinimalLoanRate}.");

            RuleFor(x => x.ProgramEndDate)
            .Must(BeNDaysLaterThanProgramStartDateWhereNIsMultipleOfLoanTermDays)
            .WithMessage($"Difference between program end and start dates must be a multiple of {_configuration.GetValue<int>("LoanTermDays")}.");
        }
 public CramMd5MechanismProcessor(IConnection connection, IRandomIntegerGenerator random, ICurrentDateTimeProvider dateTimeProvider)
 {
     Connection = connection;
     _random = random;
     _dateTimeProvider = dateTimeProvider;
 }
Beispiel #11
0
 public CramMd5MechanismProcessor(IConnection connection, IRandomIntegerGenerator random, ICurrentDateTimeProvider dateTimeProvider, string challenge)
     : this(connection, random, dateTimeProvider)
 {
     _challenge = challenge;
 }
Beispiel #12
0
 public CramMd5MechanismProcessor(IConnection connection, IRandomIntegerGenerator random, ICurrentDateTimeProvider dateTimeProvider) : base(connection)
 {
     _random           = random;
     _dateTimeProvider = dateTimeProvider;
 }
 // SUT
 internal static string GetTodaysDate(ICurrentDateTimeProvider currentDateTimeProvider)
 {
     return(currentDateTimeProvider.Value.ToString("yyyy/MM/dd", CultureInfo.InvariantCulture));
 }
Beispiel #14
0
 public PriceZoneListProvider(DalContext dalContext, ICurrentDateTimeProvider currentTimeProvider)
 {
     _dalContext  = dalContext;
     _currentTime = currentTimeProvider;
 }
 public PartnersController(IRepository <Partner> partnersRepository, ICurrentDateTimeProvider currentDateTimeProvider)
 {
     _partnersRepository      = partnersRepository;
     _currentDateTimeProvider = currentDateTimeProvider;
 }
 static CurrentDateTime()
 {
     Provider = new CurrentDateTimeProvider();
 }
Beispiel #17
0
 // This version of the method to determine if it is tea-time has a subtle bug:  the current date time value is retrieved twice,
 // once for each comparison.  It is possible that the first time the current date time is retrieved the value falls within the
 // required range, whereas the second time it is retrieved it falls outside of the range.
 // If the currentDateTimeProvider argument does not provide more than one DateTime then an InvalidOperationException
 // will be thrown.
 internal static bool IsItTeaTime2(ICurrentDateTimeProvider currentDateTimeProvider, DateTime startDateTime, DateTime endDateTime)
 {
     return(currentDateTimeProvider.Value >= startDateTime && currentDateTimeProvider.Value <= endDateTime);
 }
Beispiel #18
0
        // A method to determine if the current date-time falls within a range.
        // The IsItTeaTime1() method stores the current date-time value being provided into a local variable and then
        // uses the stored value for its calculation.
        internal static bool IsItTeaTime1(ICurrentDateTimeProvider currentDateTimeProvider, DateTime startDateTime, DateTime endDateTime)
        {
            DateTime now = currentDateTimeProvider.Value;

            return(now >= startDateTime && now <= endDateTime);
        }
Beispiel #19
0
 public MailFromVerb(ICurrentDateTimeProvider currentDateTimeProvider)
 {
     ParameterProcessorMap    = new ParameterProcessorMap();
     _currentDateTimeProvider = currentDateTimeProvider;
 }
Beispiel #20
0
 private async Task DoTimerLoopsAsync(DateTime stopDateTime, ICurrentDateTimeProvider currentDateTimeProvider, int interval)
 {
Beispiel #21
0
 public MailFromVerb(ICurrentDateTimeProvider currentDateTimeProvider)
 {
     ParameterProcessorMap = new ParameterProcessorMap();
     _currentDateTimeProvider = currentDateTimeProvider;
 }