示例#1
0
        private static void CreateDefaultRules(RulesServiceClient sut)
        {
            if (sut.GetRules().None(r => (r.Category == RuleCategory.WarningRule) && (r.Type == RuleType.Default)))
            {
                // Default rate does not exist for this company
                sut.CreateRule(new Rule
                {
                    Type     = RuleType.Default,
                    Category = RuleCategory.WarningRule,
                    AppliesToCurrentBooking = true,
                    AppliesToFutureBooking  = true,
                    Id         = Guid.NewGuid(),
                    IsActive   = false,
                    Message    = "Due to the current volume of calls, please note that pickup may be delayed.",
                    ActiveFrom = DateTime.Now.AddHours(-1),
                    ActiveTo   = DateTime.Now.AddHours(1)
                });
            }

            if (sut.GetRules().None(r => (r.Category == (int)RuleCategory.DisableRule) && (r.Type == (int)RuleType.Default)))
            {
                // Default rate does not exist for this company
                sut.CreateRule(new Rule
                {
                    Type     = RuleType.Default,
                    Category = RuleCategory.DisableRule,
                    AppliesToCurrentBooking = true,
                    AppliesToFutureBooking  = true,
                    Id      = Guid.NewGuid(),
                    Message = "Service is temporarily unavailable. Please call dispatch center for service.",
                });
            }
        }
示例#2
0
        public async void TestWarningRuleIsNotApplied()
        {
            var rules = new RulesServiceClient(BaseUrl, SessionId, new DummyPackageInfo(), null);

            CreateDefaultRules(rules);
            var rule = rules.GetRules().Single(r => r.Category == RuleCategory.WarningRule && r.Type == RuleType.Default);

            rules.DeactivateRule(rule.Id);

            var sut   = new OrderServiceClient(BaseUrl, SessionId, new DummyPackageInfo(), null, null);
            var order = new CreateOrderRequest
            {
                Id             = Guid.NewGuid(),
                PickupAddress  = TestAddresses.GetAddress1(),
                PickupDate     = DateTime.Now,
                DropOffAddress = TestAddresses.GetAddress2(),
                Settings       = new BookingSettings
                {
                    ChargeTypeId  = ChargeTypes.PaymentInCar.Id,
                    VehicleTypeId = 1,
                    ProviderId    = 13,
                    Phone         = "5145551212",
                    Passengers    = 6,
                    NumberOfTaxi  = 1,
                    Name          = "Joe Smith"
                },
            };

            var validation = await sut.ValidateOrder(order);

            Assert.IsFalse(validation.HasWarning);
            Assert.IsNullOrEmpty(validation.Message);
        }
示例#3
0
        private void DeleteAllRules(RulesServiceClient sut)
        {
            var rules = sut.GetRules();

            foreach (var rule in rules)
            {
                sut.DeleteRule(rule.Id);
            }
        }
示例#4
0
        public void ActivateDeactivate()
        {
            var sut = new RulesServiceClient(BaseUrl, SessionId, new DummyPackageInfo(), null);

            sut.ActivateRule(_knownRuleId);

            var rule = sut.GetRules().Single(x => x.Id == _knownRuleId);

            Assert.IsTrue(rule.IsActive);

            sut.DeactivateRule(_knownRuleId);
            rule = sut.GetRules().Single(x => x.Id == _knownRuleId);
            Assert.IsFalse(rule.IsActive);

            sut.ActivateRule(_knownRuleId);
            rule = sut.GetRules().Single(x => x.Id == _knownRuleId);
            Assert.IsTrue(rule.IsActive);
        }
示例#5
0
        public void UpdateRule()
        {
            var sut               = new RulesServiceClient(BaseUrl, SessionId, new DummyPackageInfo(), null);
            var newMessage        = "UpdateRuleTest" + Guid.NewGuid();
            var newName           = "UpdateRuleTest" + Guid.NewGuid();
            var activeFromDateRef = DateTime.Today.AddDays(20);

            var rule = sut.GetRules().Single(r => r.Id == _knownRuleId);

            rule.Message  = newMessage;
            rule.Name     = newName;
            rule.Priority = 99;

            rule.AppliesToCurrentBooking = false;
            rule.AppliesToFutureBooking  = true;
            rule.ZoneList      = "200,201";
            rule.ActiveFrom    = activeFromDateRef;
            rule.ActiveTo      = activeFromDateRef.AddMonths(4);
            rule.DaysOfTheWeek = DayOfTheWeek.Monday | DayOfTheWeek.Wednesday;
            rule.StartTime     = new DateTime(2000, 1, 1, 20, 18, 8);
            rule.EndTime       = new DateTime(2000, 1, 1, 21, 19, 9);
            rule.IsActive      = false;

            sut.UpdateRule(rule);

            rule = sut.GetRules().Single(r => r.Id == _knownRuleId);
            Assert.AreEqual(newMessage, rule.Message);
            Assert.AreEqual(newName, rule.Name);
            Assert.AreEqual(true, rule.AppliesToFutureBooking);
            Assert.AreEqual(false, rule.AppliesToCurrentBooking);
            Assert.AreEqual("200,201", rule.ZoneList);
            Assert.AreEqual(false, rule.IsActive);
            Assert.AreEqual(activeFromDateRef, rule.ActiveFrom);
            Assert.AreEqual(activeFromDateRef.AddMonths(4), rule.ActiveTo);
            Assert.AreEqual(DayOfTheWeek.Monday | DayOfTheWeek.Wednesday, rule.DaysOfTheWeek);
            Assert.AreEqual(new DateTime(2000, 1, 1, 20, 18, 8), rule.StartTime);
            Assert.AreEqual(new DateTime(2000, 1, 1, 21, 19, 9), rule.EndTime);
            Assert.AreEqual(99, rule.Priority);
        }
示例#6
0
        public void AddRule()
        {
            var ruleId            = Guid.NewGuid();
            var activeFromDateRef = DateTime.Today.AddDays(14);
            var name = "AddRuleTest" + Guid.NewGuid();

            var sut = new RulesServiceClient(BaseUrl, SessionId, new DummyPackageInfo(), null);

            sut.CreateRule(new Rule
            {
                Id       = ruleId,
                Name     = name,
                Type     = RuleType.Recurring,
                Category = RuleCategory.WarningRule,
                AppliesToCurrentBooking = true,
                AppliesToFutureBooking  = true,
                ActiveFrom    = activeFromDateRef,
                ActiveTo      = activeFromDateRef.AddMonths(2),
                DaysOfTheWeek = DayOfTheWeek.Saturday | DayOfTheWeek.Sunday,
                StartTime     = new DateTime(2000, 1, 1, 22, 11, 10),
                EndTime       = new DateTime(2000, 1, 1, 23, 22, 11),
                Priority      = 10,
                IsActive      = true,
                Message       = "DisableRuleMessage"
            });

            var rules = sut.GetRules();

            Assert.AreEqual(1, rules.Count(x => x.Id == ruleId));
            var rule = rules.Single(x => x.Id == ruleId);

            Assert.AreEqual(name, rule.Name);
            Assert.AreEqual(RuleCategory.WarningRule, rule.Category);
            Assert.AreEqual(RuleType.Recurring, rule.Type);
            Assert.AreEqual(true, rule.AppliesToFutureBooking);
            Assert.AreEqual(true, rule.AppliesToCurrentBooking);
            Assert.AreEqual(true, rule.IsActive);

            Assert.AreEqual(activeFromDateRef, rule.ActiveFrom);
            Assert.AreEqual(activeFromDateRef.AddMonths(2), rule.ActiveTo);

            Assert.AreEqual(DayOfTheWeek.Saturday | DayOfTheWeek.Sunday, rule.DaysOfTheWeek);
            Assert.AreEqual(new DateTime(2000, 1, 1, 22, 11, 10), rule.StartTime);
            Assert.AreEqual(new DateTime(2000, 1, 1, 23, 22, 11), rule.EndTime);

            Assert.AreEqual(10, rule.Priority);

            Assert.AreEqual("DisableRuleMessage", rule.Message);
        }