Пример #1
0
        public void when_creating_order_without_passing_settings()
        {
            var sut   = new OrderServiceClient(BaseUrl, SessionId, new DummyPackageInfo(), null, null);
            var order = new CreateOrderRequest
            {
                Id             = Guid.NewGuid(),
                PickupAddress  = TestAddresses.GetAddress1(),
                DropOffAddress = TestAddresses.GetAddress2(),
                Estimate       = new RideEstimate
                {
                    Price    = 10,
                    Distance = 3
                },
                Settings = new BookingSettings
                {
                    Phone   = "5145551212",
                    Country = new CountryISOCode("CA")
                },
                ClientLanguageCode = SupportedLanguages.fr.ToString()
            };

            var ex = Assert.Throws <WebServiceException>(async() => await sut.CreateOrder(order));

            Assert.AreEqual("CreateOrder_SettingsRequired", ex.ErrorMessage);
        }
Пример #2
0
        public void when_creating_order_with_promotion_but_not_using_card_on_file()
        {
            var sut   = new OrderServiceClient(BaseUrl, SessionId, new DummyPackageInfo(), null, null);
            var order = new CreateOrderRequest
            {
                Id             = Guid.NewGuid(),
                PickupAddress  = TestAddresses.GetAddress1(),
                DropOffAddress = TestAddresses.GetAddress2(),
                Estimate       = new RideEstimate
                {
                    Price    = 10,
                    Distance = 3
                },
                Settings = new BookingSettings
                {
                    ChargeTypeId   = ChargeTypes.PaymentInCar.Id,
                    VehicleTypeId  = 1,
                    ProviderId     = Provider.ApcuriumIbsProviderId,
                    Phone          = "5145551212",
                    Country        = new CountryISOCode("CA"),
                    Passengers     = 6,
                    NumberOfTaxi   = 1,
                    Name           = "Joe Smith",
                    LargeBags      = 1,
                    AccountNumber  = "123",
                    CustomerNumber = "0"
                },
                ClientLanguageCode = SupportedLanguages.fr.ToString(),
                PromoCode          = "123"
            };

            var ex = Assert.Throws <WebServiceException>(async() => await sut.CreateOrder(order));

            Assert.AreEqual("Vous devez sélectionner le Paiement In App pour utiliser une promotion.", ex.ErrorMessage);
        }
Пример #3
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);
        }
Пример #4
0
        private async Task <OrderValidationResult> ValidateOrder(Action <CreateOrderRequest> update, string testZone = null)
        {
            var sut   = new OrderServiceClient(BaseUrl, SessionId, new DummyPackageInfo(), null, null);
            var order = new CreateOrderRequest
            {
                Id             = Guid.NewGuid(),
                PickupAddress  = TestAddresses.GetAddress1(),
                PickupDate     = null,
                DropOffAddress = TestAddresses.GetAddress2(),
                Settings       = new BookingSettings
                {
                    ChargeTypeId  = ChargeTypes.PaymentInCar.Id,
                    VehicleTypeId = 1,
                    ProviderId    = Provider.ApcuriumIbsProviderId,
                    Phone         = "5145551212",
                    Passengers    = 6,
                    NumberOfTaxi  = 1,
                    Name          = "Joe Smith"
                },
                ClientLanguageCode = "en"
            };

            if (update != null)
            {
                update(order);
            }

            return(await sut.ValidateOrder(order, testZone));
        }
Пример #5
0
        public async void TestRecurrencyRuleIsApplied_with_start_and_end_time_on_different_day()
        {
            var ruleId            = Guid.NewGuid();
            var activeFromDateRef = DateTime.Now;
            var name         = "ReccurencyRuleTest" + Guid.NewGuid();
            var mess         = "ReccurencyRuleTestMessage";
            var dayOfTheWeek = 1 << (int)DateTime.Now.DayOfWeek;
            var rules        = new RulesServiceClient(BaseUrl, SessionId, new DummyPackageInfo(), null);

            rules.CreateRule(new Rule
            {
                Id       = ruleId,
                Name     = name,
                Type     = RuleType.Recurring,
                Category = RuleCategory.WarningRule,
                AppliesToCurrentBooking = true,
                AppliesToFutureBooking  = true,
                ActiveFrom    = activeFromDateRef.AddHours(-1),
                ActiveTo      = activeFromDateRef.AddHours(1),
                DaysOfTheWeek = (DayOfTheWeek)dayOfTheWeek,
                StartTime     = activeFromDateRef.AddHours(-1),
                EndTime       = activeFromDateRef.AddHours(22),
                Priority      = 23,
                IsActive      = true,
                Message       = "ReccurencyRuleTestMessage",
                ZoneList      = " "
            });

            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.IsTrue(validation.HasWarning);
            Assert.AreEqual(mess, validation.Message);
        }
Пример #6
0
        public new void TestFixtureSetup()
        {
            base.TestFixtureSetup();
            var container = UnityServiceLocator.Instance;

            _taxiHailNetworkServiceImplementation = container.Registrations
                                                    .FirstOrDefault(x => x.RegisteredType == typeof(ITaxiHailNetworkServiceClient))
                                                    .MappedToType;

            _orderId = Guid.NewGuid();

            var authTask = new AuthServiceClient(BaseUrl, SessionId, new DummyPackageInfo(), null, null).Authenticate(TestAccount.Email, TestAccountPassword);

            authTask.Wait();
            var auth = authTask.Result;

            SessionId = auth.SessionId;

            var sut   = new OrderServiceClient(BaseUrl, SessionId, new DummyPackageInfo(), null, null);
            var order = new CreateOrderRequest
            {
                Id             = _orderId,
                PickupAddress  = TestAddresses.GetAddress1(),
                DropOffAddress = TestAddresses.GetAddress2(),
                Estimate       = new RideEstimate
                {
                    Price    = 10,
                    Distance = 3
                },
                Settings = new BookingSettings
                {
                    ChargeTypeId  = ChargeTypes.PaymentInCar.Id,
                    VehicleTypeId = 1,
                    ProviderId    = Provider.ApcuriumIbsProviderId,
                    Phone         = "5145551212",
                    Country       = new CountryISOCode("CA"),
                    Passengers    = 6,
                    NumberOfTaxi  = 1,
                    Name          = "Joe Smith",
                    LargeBags     = 1
                },
                ClientLanguageCode = SupportedLanguages.fr.ToString()
            };

            sut.CreateOrder(order).Wait();

            // Wait for IBS order Id to be assigned
            Thread.Sleep(10000);
        }
        public async void when_creating_an_order_with_a_new_pickup_address()
        {
            //Arrange
            var newAccount = await CreateAndAuthenticateTestAccount();

            var orderService = new OrderServiceClient(BaseUrl, SessionId, new DummyPackageInfo(), null, null);

            //Act
            var order = new CreateOrderRequest
            {
                Id             = Guid.NewGuid(),
                PickupAddress  = TestAddresses.GetAddress1(),
                PickupDate     = DateTime.Now,
                DropOffAddress = TestAddresses.GetAddress2(),
                Estimate       = new RideEstimate
                {
                    Distance = 3,
                    Price    = 10
                },
                Settings = new BookingSettings
                {
                    ChargeTypeId  = ChargeTypes.PaymentInCar.Id,
                    VehicleTypeId = 7,
                    ProviderId    = Provider.ApcuriumIbsProviderId,
                    Phone         = "5145551212",
                    Country       = new CountryISOCode("CA"),
                    Passengers    = 6,
                    NumberOfTaxi  = 1,
                    Name          = "Joe Smith"
                },
                ClientLanguageCode = "en"
            };
            await orderService.CreateOrder(order);

            //Assert
            var sut       = new AccountServiceClient(BaseUrl, SessionId, new DummyPackageInfo(), null, null);
            var addresses = await sut.GetHistoryAddresses(newAccount.Id);

            Assert.AreEqual(1, addresses.Count());
            var address = addresses.Single();

            Assert.AreEqual(order.PickupAddress.Apartment, address.Apartment);
            Assert.AreEqual(order.PickupAddress.RingCode, address.RingCode);
            Assert.AreEqual(order.PickupAddress.FullAddress, address.FullAddress);
            Assert.AreEqual(order.PickupAddress.BuildingName, address.BuildingName);
            Assert.AreEqual(order.PickupAddress.Latitude, address.Latitude);
            Assert.AreEqual(order.PickupAddress.Longitude, address.Longitude);
        }
Пример #8
0
        private async Task <string> CreateOrder(Action <CreateOrderRequest> update)
        {
            var sut   = new OrderServiceClient(BaseUrl, SessionId, new DummyPackageInfo(), null, null);
            var order = new CreateOrderRequest
            {
                Id             = Guid.NewGuid(),
                PickupAddress  = TestAddresses.GetAddress1(),
                PickupDate     = null,
                DropOffAddress = TestAddresses.GetAddress2(),
                Estimate       = new RideEstimate
                {
                    Price    = 10,
                    Distance = 3
                },
                Settings = new BookingSettings
                {
                    ChargeTypeId  = ChargeTypes.PaymentInCar.Id,
                    VehicleTypeId = 1,
                    ProviderId    = Provider.ApcuriumIbsProviderId,
                    Phone         = "5145551212",
                    Passengers    = 6,
                    NumberOfTaxi  = 1,
                    Name          = "Joe Smith",
                    Country       = new CountryISOCode("CA")
                },
                ClientLanguageCode = SupportedLanguages.en.ToString()
            };

            if (update != null)
            {
                update(order);
            }

            try
            {
                await sut.CreateOrder(order);
            }
            catch (WebServiceException wEx)
            {
                return(wEx.ErrorMessage);
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }

            return(null);
        }
Пример #9
0
        public async void GetOrder()
        {
            var sut = new OrderServiceClient(BaseUrl, SessionId, new DummyPackageInfo(), null, null);

            var order = await sut.GetOrder(_orderId);

            Assert.NotNull(order);

            Assert.AreEqual(TestAddresses.GetAddress1().Apartment, order.PickupAddress.Apartment);
            Assert.AreEqual(TestAddresses.GetAddress1().FullAddress, order.PickupAddress.FullAddress);
            Assert.AreEqual(TestAddresses.GetAddress1().RingCode, order.PickupAddress.RingCode);
            Assert.AreEqual(TestAddresses.GetAddress1().Latitude, order.PickupAddress.Latitude);
            Assert.AreEqual(TestAddresses.GetAddress1().Longitude, order.PickupAddress.Longitude);
            Assert.AreEqual(TestAddresses.GetAddress2().FullAddress, order.DropOffAddress.FullAddress);
            Assert.AreEqual(TestAddresses.GetAddress2().Latitude, order.DropOffAddress.Latitude);
            Assert.AreEqual(TestAddresses.GetAddress2().Longitude, order.DropOffAddress.Longitude);
            Assert.AreNotEqual(OrderStatus.Completed, order.Status);
        }
Пример #10
0
        public async void create_order()
        {
            var sut   = new OrderServiceClient(BaseUrl, SessionId, new DummyPackageInfo(), null, null);
            var order = new CreateOrderRequest
            {
                Id             = Guid.NewGuid(),
                PickupAddress  = TestAddresses.GetAddress1(),
                DropOffAddress = TestAddresses.GetAddress2(),
                Estimate       = new RideEstimate
                {
                    Price    = 10,
                    Distance = 3
                },
                Settings = new BookingSettings
                {
                    ChargeTypeId   = ChargeTypes.PaymentInCar.Id,
                    VehicleTypeId  = 1,
                    ProviderId     = Provider.ApcuriumIbsProviderId,
                    Phone          = "5145551212",
                    Country        = new CountryISOCode("CA"),
                    Passengers     = 6,
                    NumberOfTaxi   = 1,
                    Name           = "Joe Smith",
                    LargeBags      = 1,
                    AccountNumber  = "123",
                    CustomerNumber = "0"
                },
                ClientLanguageCode = SupportedLanguages.fr.ToString()
            };

            var details = await sut.CreateOrder(order);

            Assert.NotNull(details);

            var orderDetails = await sut.GetOrder(details.OrderId);

            Assert.AreEqual(orderDetails.PickupAddress.FullAddress, order.PickupAddress.FullAddress);
            Assert.AreEqual(orderDetails.DropOffAddress.FullAddress, order.DropOffAddress.FullAddress);
            Assert.AreEqual(6, orderDetails.Settings.Passengers);
            Assert.AreEqual(1, orderDetails.Settings.LargeBags);
            Assert.AreEqual("123", orderDetails.Settings.AccountNumber);
            Assert.AreEqual("0", orderDetails.Settings.CustomerNumber);
        }
Пример #11
0
        public async void create_order_with_user_location()
        {
            var sut   = new OrderServiceClient(BaseUrl, SessionId, new DummyPackageInfo(), null, null);
            var order = new CreateOrderRequest
            {
                Id             = Guid.NewGuid(),
                UserLatitude   = 46.50643,
                UserLongitude  = -74.554052,
                PickupAddress  = TestAddresses.GetAddress1(),
                DropOffAddress = TestAddresses.GetAddress2(),
                Estimate       = new RideEstimate
                {
                    Price    = 10,
                    Distance = 3
                },
                Settings = new BookingSettings
                {
                    ChargeTypeId  = ChargeTypes.PaymentInCar.Id,
                    VehicleTypeId = 1,
                    ProviderId    = Provider.ApcuriumIbsProviderId,
                    Phone         = "5145551212",
                    Country       = new CountryISOCode("CA"),
                    Passengers    = 6,
                    NumberOfTaxi  = 1,
                    Name          = "Joe Smith",
                    LargeBags     = 1
                },
                ClientLanguageCode = SupportedLanguages.en.ToString()
            };

            await sut.CreateOrder(order);

            using (var context = new BookingDbContext(ConfigurationManager.ConnectionStrings["MKWebDev"].ConnectionString))
            {
                var infoGPS = context.Find <OrderUserGpsDetail>(order.Id);
                Assert.AreEqual(order.UserLatitude, infoGPS.UserLatitude);
                Assert.AreEqual(order.UserLongitude, infoGPS.UserLongitude);
            }
        }
        public override void TestFixtureSetup()
        {
            base.TestFixtureSetup();

            var authResponseTask = new AuthServiceClient(BaseUrl, null, new DummyPackageInfo(), null, null).Authenticate(TestAccount.Email, TestAccountPassword);

            authResponseTask.Wait();
            var authResponse = authResponseTask.Result;

            _orderId = Guid.NewGuid();
            var sut   = new OrderServiceClient(BaseUrl, authResponse.SessionId, new DummyPackageInfo(), null, null);
            var order = new CreateOrderRequest
            {
                Id             = _orderId,
                PickupAddress  = TestAddresses.GetAddress1(),
                DropOffAddress = TestAddresses.GetAddress2(),
                Settings       = new BookingSettings
                {
                    ChargeTypeId  = ChargeTypes.PaymentInCar.Id,
                    VehicleTypeId = 1,
                    ProviderId    = Provider.ApcuriumIbsProviderId,
                    Phone         = "5145551212",
                    Country       = new CountryISOCode("CA"),
                    Passengers    = 6,
                    NumberOfTaxi  = 1,
                    Name          = "Joe Smith"
                },
                Estimate = new RideEstimate
                {
                    Distance = 3,
                    Price    = 10
                },
                ClientLanguageCode = "fr"
            };

            sut.CreateOrder(order).Wait();
        }
Пример #13
0
        public void create_order_with_charge_account_with_card_on_file_payment_from_web_app()
        {
            var accountChargeSut      = new AdministrationServiceClient(BaseUrl, SessionId, new DummyPackageInfo(), null);
            var accountChargeName     = "NAME" + new Random(DateTime.Now.Millisecond).Next(0, 5236985);
            var accountChargeNumber   = "NUMBER" + new Random(DateTime.Now.Millisecond).Next(0, 5236985);
            var accountCustomerNumber = "CUSTOMER" + new Random(DateTime.Now.Millisecond).Next(0, 5236985);

            accountChargeSut.CreateAccountCharge(new AccountChargeRequest
            {
                Id                      = Guid.NewGuid(),
                Name                    = accountChargeName,
                AccountNumber           = accountChargeNumber,
                UseCardOnFileForPayment = true,
                Questions               = new[]
                {
                    new AccountChargeQuestion
                    {
                        Question = "Question?",
                        Answer   = "Answer"
                    }
                }
            });

            var sut = new OrderServiceClient(BaseUrl, SessionId, new DummyPackageInfo {
                UserAgent = "FireFox"
            }, null, null);
            var order = new CreateOrderRequest
            {
                Id             = Guid.NewGuid(),
                FromWebApp     = true,
                PickupAddress  = TestAddresses.GetAddress1(),
                DropOffAddress = TestAddresses.GetAddress2(),
                Estimate       = new RideEstimate
                {
                    Price    = 10,
                    Distance = 3
                },
                Settings = new BookingSettings
                {
                    ChargeTypeId   = ChargeTypes.Account.Id,
                    VehicleTypeId  = 1,
                    ProviderId     = Provider.ApcuriumIbsProviderId,
                    Phone          = "5145551212",
                    Country        = new CountryISOCode("CA"),
                    Passengers     = 6,
                    NumberOfTaxi   = 1,
                    Name           = "Joe Smith",
                    LargeBags      = 1,
                    AccountNumber  = accountChargeNumber,
                    CustomerNumber = accountCustomerNumber
                },
                Payment = new PaymentSettings
                {
                    CreditCardId = Guid.NewGuid(),
                    TipPercent   = 15
                },
                QuestionsAndAnswers = new[]
                {
                    new AccountChargeQuestion
                    {
                        Answer = "Answer"
                    }
                },
                ClientLanguageCode = SupportedLanguages.fr.ToString()
            };

            var ex = Assert.Throws <WebServiceException>(async() => await sut.CreateOrder(order));

            Assert.AreEqual("Ce compte n'est pas supporté par la page web", ex.ErrorMessage);
        }
        public async void when_settling_an_overdue_payment()
        {
            var orderId      = Guid.NewGuid();
            var creditCardId = Guid.NewGuid();
            var pickUpDate   = DateTime.Now;

            var client = GetPaymentClient();

            using (var context = ContextFactory.Invoke())
            {
                context.RemoveAll <OrderDetail>();
                context.RemoveAll <OverduePaymentDetail>();
                context.SaveChanges();

                var tokenizeResponse = await client.Tokenize(TestCreditCards.Visa.Number, TestCreditCards.Visa.NameOnCard, TestCreditCards.Visa.ExpirationDate, TestCreditCards.Visa.AvcCvvCvv2.ToString(), null, TestCreditCards.Visa.ZipCode, TestAccount);

                var token = tokenizeResponse.CardOnFileToken;

                var testAccount = context.Set <AccountDetail>().First(a => a.Id == TestAccount.Id);
                testAccount.DefaultCreditCard = creditCardId;

                context.RemoveAll <CreditCardDetails>();
                context.SaveChanges();

                context.Set <CreditCardDetails>().Add(new CreditCardDetails
                {
                    CreditCardId      = creditCardId,
                    AccountId         = TestAccount.Id,
                    CreditCardCompany = "Visa",
                    Token             = token,
                    Country           = new CountryISOCode("CA"),
                    Email             = testAccount.Email,
                    Phone             = "5145552222",
                });

                context.Set <OrderDetail>().Add(new OrderDetail
                {
                    Id                 = orderId,
                    AccountId          = TestAccount.Id,
                    BookingFees        = 15m,
                    CreatedDate        = DateTime.Now,
                    PickupDate         = pickUpDate,
                    PickupAddress      = TestAddresses.GetAddress1(),
                    ClientLanguageCode = SupportedLanguages.en.ToString()
                });

                context.Set <OrderStatusDetail>().Add(new OrderStatusDetail
                {
                    OrderId       = orderId,
                    IBSOrderId    = 12345,
                    VehicleNumber = "9001",
                    Status        = OrderStatus.Canceled,
                    AccountId     = TestAccount.Id,
                    PickupDate    = pickUpDate
                });

                context.Set <OrderPairingDetail>().Add(new OrderPairingDetail
                {
                    OrderId           = orderId,
                    AutoTipPercentage = 15
                });

                context.Set <OverduePaymentDetail>().Add(new OverduePaymentDetail
                {
                    AccountId             = TestAccount.Id,
                    IBSOrderId            = 12345,
                    OrderId               = orderId,
                    TransactionDate       = DateTime.Now,
                    TransactionId         = "TransId",
                    OverdueAmount         = 52.34m,
                    ContainBookingFees    = false,
                    ContainStandaloneFees = false,
                    IsPaid = false
                });

                context.SaveChanges();
            }

            var result = await client.SettleOverduePayment(null);

            Assert.AreEqual(true, result.IsSuccessful);

            var overduePayment = await client.GetOverduePayment();

            Assert.IsNull(overduePayment);
        }