public void Arrange()
        {
            _globalRule = new GlobalRule
            {
                Id          = 3,
                Restriction = 0,
                RuleType    = 1,
                ActiveFrom  = new DateTime(2010, 02, 15)
            };

            _repository = new Mock <IGlobalRuleRepository>();
            _repository.Setup(x => x.FindActive(It.IsAny <DateTime>()))
            .ReturnsAsync(new List <GlobalRule> {
                _globalRule
            });

            _repository.Setup(x => x.GetAll())
            .ReturnsAsync(new List <GlobalRule> {
                _globalRule
            });

            _globalRulesService = new GlobalRulesService(_repository.Object,
                                                         Mock.Of <IOptions <ReservationsConfiguration> >(),
                                                         Mock.Of <IAccountReservationService>(),
                                                         Mock.Of <IAccountsService>(),
                                                         Mock.Of <ILogger <GlobalRulesService> >());
        }
Esempio n. 2
0
        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> >());
        }
Esempio n. 3
0
        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> >());
        }