Beispiel #1
0
        public void when_payment_initiated_then_dto_populated()
        {
            var paymentId = Guid.NewGuid();
            var orderId   = Guid.NewGuid();
            var t         = Guid.NewGuid().ToString();

            Sut.Handle(new CreditCardPaymentInitiated
            {
                SourceId      = paymentId,
                Amount        = 34.56m,
                TransactionId = "the transaction",
                OrderId       = orderId,
                CardToken     = t,
                Provider      = PaymentProvider.Braintree
            });

            using (var context = new BookingDbContext(DbName))
            {
                var dto = context.Find <OrderPaymentDetail>(paymentId);
                Assert.NotNull(dto);
                Assert.AreEqual(orderId, dto.OrderId);
                Assert.AreEqual(34.56m, dto.PreAuthorizedAmount);
                Assert.AreEqual(0, dto.Amount);
                Assert.AreEqual("the transaction", dto.TransactionId);
                Assert.AreEqual("the transaction", dto.FirstPreAuthTransactionId);
                Assert.AreEqual(false, dto.IsCompleted);
                Assert.AreEqual(t, dto.CardToken);
                Assert.AreEqual(PaymentProvider.Braintree, dto.Provider);
                Assert.AreEqual(PaymentType.CreditCard, dto.Type);
            }
        }
Beispiel #2
0
        public void Add_status_to_database()
        {
            var TestEntity = new Status()
            {
                StatusId = 1, StatusName = "pending"
            };
            var options = new DbContextOptionsBuilder <BookingDbContext>()
                          .UseInMemoryDatabase(databaseName: "Add_status_to_database")
                          .Options;

            // Run the test against one instance of the context
            var context    = new BookingDbContext(options);
            var unWork     = new UnitOfWork(context);
            var StatusRepo = unWork.StatusRepository;

            StatusRepo.Insert(TestEntity);
            unWork.Commit();

            // Use a separate instance of the context to verify correct data was saved to database
            using (var context2 = new BookingDbContext(options))
            {
                Assert.Equal(1, context2.Status.Count());
                Assert.Equal(TestEntity, context.Status.Single());
            }
        }
Beispiel #3
0
        public void SelectAll_status_from_database()
        {
            var options = new DbContextOptionsBuilder <BookingDbContext>()
                          .UseInMemoryDatabase(databaseName: "selectAll_database")
                          .Options;

            // Run the test against one instance of the context
            var context    = new BookingDbContext(options);
            var unWork     = new UnitOfWork(context);
            var StatusRepo = unWork.StatusRepository;

            //Seed some data to status to query from.
            context.Status.Add(new Status()
            {
                StatusId = 2, StatusName = "Complete"
            });
            context.Status.Add(new Status()
            {
                StatusId = 3, StatusName = "Complete"
            });
            context.Status.Add(new Status()
            {
                StatusId = 6, StatusName = "Canceled"
            });
            unWork.Commit();

            // Use a separate instance of the context to verify correct data was saved to database
            using (var context2 = new BookingDbContext(options))
            {
                var unitWork = new UnitOfWork(context);
                var result   = unitWork.StatusRepository.Select();
                Assert.Equal(3, result.Count());
            }
        }
Beispiel #4
0
        public void when_ratingType_created_ratingType_dto_populated()
        {
            var ratingTypeId = Guid.NewGuid();
            var companyId    = Guid.NewGuid();

            foreach (var language in Enum.GetNames(typeof(SupportedLanguages)))
            {
                var ratingTypeAdded = new RatingTypeAdded
                {
                    SourceId     = companyId,
                    RatingTypeId = ratingTypeId,
                    Name         = "RatingType",
                    Language     = language
                };

                Sut.Handle(ratingTypeAdded);

                using (var context = new BookingDbContext(DbName))
                {
                    string ratingLanguage = language;
                    var    list           = context.Query <RatingTypeDetail>().Where(x => x.Id == ratingTypeId && x.Name == "RatingType" && x.Language == ratingLanguage);
                    Assert.AreEqual(1, list.Count());
                    var dto = list.Single();
                    Assert.AreEqual(ratingTypeId, dto.Id);
                    Assert.AreEqual(companyId, dto.CompanyId);
                    Assert.AreEqual(language, dto.Language);
                    Assert.That(dto.Name, Is.EqualTo(ratingTypeAdded.Name));
                }
            }
        }
        public void when_account_charge_created_then_dto_populated()
        {
            var @event = new AccountChargeAddedUpdated
            {
                SourceId        = Guid.NewGuid(),
                AccountChargeId = Guid.NewGuid(),
                Number          = "number",
                Name            = "VIP",
                Questions       = new[]
                {
                    new AccountChargeQuestion
                    {
                        Answer   = "answer",
                        Id       = 0,
                        Question = "question"
                    }
                }
            };

            Sut.Handle(@event);

            using (var context = new BookingDbContext(DbName))
            {
                var list = context.Query <AccountChargeDetail>().ToList();
                Assert.AreEqual(1, list.Count());
                var dto = list.Single();
                Assert.AreEqual(@event.AccountChargeId, dto.Id);
                Assert.AreEqual(@event.Number, dto.Number);
                Assert.AreEqual(@event.Name, dto.Name);
                Assert.AreEqual(@event.Questions[0].Question, dto.Questions[0].Question);
                Assert.AreEqual(@event.Questions[0].Answer, dto.Questions[0].Answer);
            }
        }
Beispiel #6
0
        public void when_fare_information_set()
        {
            double fare = 12;
            double tip  = 2;
            double toll = 5;
            double tax  = 3;

            Sut.Handle(new OrderStatusChanged
            {
                SourceId = _orderId,
                Fare     = fare,
                Tip      = tip,
                Toll     = toll,
                Tax      = tax,
            });

            using (var context = new BookingDbContext(DbName))
            {
                var dto = context.Find <OrderDetail>(_orderId);
                Assert.NotNull(dto);
                Assert.AreEqual(fare, dto.Fare);
                Assert.AreEqual(tip, dto.Tip);
                Assert.AreEqual(tax, dto.Tax);
                Assert.AreEqual(toll, dto.Toll);

                var details = context.Find <OrderStatusDetail>(_orderId);
                Assert.NotNull(details);
                Assert.IsTrue(details.FareAvailable);
            }
        }
Beispiel #7
0
        public void when_trip_status_changed_to_timedout()
        {
            var now = DateTime.Now;

            Sut.Handle(new OrderStatusChangedForManualRideLinq
            {
                SourceId = _orderId,
                Status   = OrderStatus.TimedOut,
                LastTripPollingDateInUtc = now
            });

            using (var context = new BookingDbContext(DbName))
            {
                var order = context.Find <OrderDetail>(_orderId);
                Assert.NotNull(order);
                Assert.AreEqual((int)OrderStatus.TimedOut, order.Status);

                var orderStatus = context.Find <OrderStatusDetail>(_orderId);
                Assert.NotNull(orderStatus);
                Assert.AreEqual(OrderStatus.TimedOut, orderStatus.Status);
                Assert.AreEqual(now.ToLongDateString(), orderStatus.LastTripPollingDateInUtc.Value.ToLongDateString());

                var rideLinq = context.Find <OrderManualRideLinqDetail>(_orderId);
                Assert.NotNull(rideLinq);
                Assert.AreEqual(true, rideLinq.EndTime.HasValue);
                Assert.AreEqual(false, rideLinq.IsWaitingForPayment);
            }
        }
Beispiel #8
0
        public void when_account_registered_then_account_settings_populated()
        {
            var accountId = Guid.NewGuid();

            var accountRegistered = new AccountRegistered
            {
                SourceId = accountId,
                Name     = "Bob",
                Email    = "*****@*****.**",
                Country  = CountryCode.GetCountryCodeByIndex(CountryCode.GetCountryCodeIndexByCountryISOCode("CA")).CountryISOCode,
                Phone    = "555.555.2525",
                Password = new byte[] { 1 }
            };

            Sut.Handle(accountRegistered);

            using (var context = new BookingDbContext(DbName))
            {
                var dto = context.Find <AccountDetail>(accountId);

                Assert.NotNull(dto);
                Assert.AreEqual(dto.Settings.Name, dto.Name);
                Assert.AreEqual(CountryCode.GetCountryCodeByIndex(CountryCode.GetCountryCodeIndexByCountryISOCode("CA")).CountryISOCode.Code, dto.Settings.Country.Code);
                Assert.AreEqual(accountRegistered.Phone, dto.Settings.Phone);


                var config = new TestServerSettings();
                Assert.IsNull(dto.Settings.ChargeTypeId);
                Assert.AreEqual(dto.Settings.Passengers, config.ServerData.DefaultBookingSettings.NbPassenger);
                Assert.IsNull(dto.Settings.VehicleTypeId);
                Assert.IsNull(dto.Settings.ProviderId);
            }
        }
        public void when_sending_receipt_with_no_dropoff_and_no_vehicle_position_should_not_have_address()
        {
            var orderId = Guid.NewGuid();

            using (var context = new BookingDbContext(DbName))
            {
                context.Save(new OrderStatusDetail
                {
                    OrderId    = orderId,
                    PickupDate = DateTime.Now,
                });
            }

            Sut.When(new SendReceipt
            {
                OrderId       = orderId,
                EmailAddress  = "*****@*****.**",
                PickupAddress = new Address
                {
                    FullAddress = "5250, rue Ferrier, Montreal, H1P 4L4",
                    Latitude    = 1.23456,
                    Longitude   = 7.890123
                },
                ClientLanguageCode = "fr"
            });

            // verify that geocoding is not called
            _geocodingMock.Verify(g => g.TryToGetExactDropOffAddress(It.IsAny <OrderStatusDetail>(), null, null, null, It.IsAny <string>()), Times.Once);

            // verify templateData (2 times for subject + body)
            AssertTemplateValueEquals("DropOffAddress", "-");
            AssertTemplateValueEquals("StaticMapUri", string.Empty);
        }
Beispiel #10
0
        public void when_account_registered_then_account_dto_populated()
        {
            var accountId = Guid.NewGuid();

            Sut.Handle(new AccountRegistered
            {
                SourceId   = accountId,
                Name       = "Bob",
                Email      = "*****@*****.**",
                Password   = new byte[] { 1 },
                FacebookId = "FacebookId",
                TwitterId  = "TwitterId",
                Language   = "fr"
            });

            using (var context = new BookingDbContext(DbName))
            {
                var dto = context.Find <AccountDetail>(accountId);

                Assert.NotNull(dto);
                Assert.AreEqual("Bob", dto.Name);
                Assert.AreEqual("*****@*****.**", dto.Email);
                Assert.AreEqual(1, dto.Password.Length);
                Assert.AreEqual("FacebookId", dto.FacebookId);
                Assert.AreEqual("TwitterId", dto.TwitterId);
                Assert.AreEqual(false, dto.IsConfirmed);
                Assert.AreEqual(false, dto.DisabledByAdmin);
                Assert.AreEqual("fr", dto.Language);
            }
        }
Beispiel #11
0
        public void when_account_unlinked_from_ibs_then_dto_updated()
        {
            Sut.Handle(new AccountLinkedToIbs
            {
                SourceId     = _accountId,
                IbsAccountId = 122
            });

            Sut.Handle(new AccountLinkedToIbs
            {
                SourceId     = _accountId,
                IbsAccountId = 555,
                CompanyKey   = "test"
            });

            Sut.Handle(new AccountUnlinkedFromIbs
            {
                SourceId = _accountId
            });

            using (var context = new BookingDbContext(DbName))
            {
                var accountDetail    = context.Query <AccountDetail>().FirstOrDefault(x => x.Id == _accountId);
                var accountIbsDetail = context.Query <AccountIbsDetail>().FirstOrDefault(x => x.AccountId == _accountId);

                Assert.NotNull(accountDetail);
                Assert.AreEqual(null, accountDetail.IBSAccountId);
                Assert.Null(accountIbsDetail);
            }
        }
Beispiel #12
0
            public void when_settings_updated_with_default_values_then_account_dto_populated()
            {
                Sut.Handle(new BookingSettingsUpdated
                {
                    SourceId       = _accountId,
                    Name           = "Robert",
                    ChargeTypeId   = 1,
                    NumberOfTaxi   = 3,
                    Country        = CountryCode.GetCountryCodeByIndex(CountryCode.GetCountryCodeIndexByCountryISOCode("CA")).CountryISOCode,
                    Phone          = "123",
                    Passengers     = 3,
                    ProviderId     = 1,
                    VehicleTypeId  = 1,
                    AccountNumber  = "1234",
                    CustomerNumber = "0"
                });

                using (var context = new BookingDbContext(DbName))
                {
                    var dto = context.Find <AccountDetail>(_accountId);

                    Assert.NotNull(dto);
                    Assert.IsNull(dto.Settings.ChargeTypeId);
                    Assert.IsNull(dto.Settings.ProviderId);
                    Assert.IsNull(dto.Settings.VehicleTypeId);
                    Assert.AreEqual(dto.Settings.Country.Code, CountryCode.GetCountryCodeByIndex(CountryCode.GetCountryCodeIndexByCountryISOCode("CA")).CountryISOCode.Code);
                }
            }
Beispiel #13
0
            public void when_settings_updated_then_account_dto_populated()
            {
                Sut.Handle(new BookingSettingsUpdated
                {
                    SourceId       = _accountId,
                    Name           = "Robert",
                    ChargeTypeId   = 123,
                    NumberOfTaxi   = 3,
                    Country        = CountryCode.GetCountryCodeByIndex(CountryCode.GetCountryCodeIndexByCountryISOCode("CA")).CountryISOCode,
                    Phone          = "123",
                    Passengers     = 3,
                    ProviderId     = 85,
                    VehicleTypeId  = 69,
                    AccountNumber  = "1234",
                    CustomerNumber = "0"
                });

                using (var context = new BookingDbContext(DbName))
                {
                    var dto = context.Find <AccountDetail>(_accountId);

                    Assert.NotNull(dto);
                    Assert.AreEqual("Robert", dto.Settings.Name);
                    Assert.AreEqual(123, dto.Settings.ChargeTypeId);
                    Assert.AreEqual(3, dto.Settings.NumberOfTaxi);
                    Assert.AreEqual(CountryCode.GetCountryCodeByIndex(CountryCode.GetCountryCodeIndexByCountryISOCode("CA")).CountryISOCode.Code, dto.Settings.Country.Code);
                    Assert.AreEqual("123", dto.Settings.Phone);
                    Assert.AreEqual(3, dto.Settings.Passengers);
                    Assert.AreEqual(85, dto.Settings.ProviderId);
                    Assert.AreEqual(69, dto.Settings.VehicleTypeId);
                    Assert.AreEqual("1234", dto.Settings.AccountNumber);
                    Assert.AreEqual("0", dto.Settings.CustomerNumber);
                    Assert.AreEqual("*****@*****.**", dto.Email);
                }
            }
Beispiel #14
0
        public void when_vehicle_type_updated_then_dto_updated()
        {
            var @event = new VehicleTypeAddedUpdated
            {
                SourceId                      = Guid.NewGuid(),
                VehicleTypeId                 = _vehicleTypeId,
                LogoName                      = "taxi2",
                Name                          = "Taxi2",
                ReferenceDataVehicleId        = 111,
                ReferenceNetworkVehicleTypeId = 9
            };

            Sut.Handle(@event);

            using (var context = new BookingDbContext(DbName))
            {
                var list = context.Query <VehicleTypeDetail>().ToList();
                Assert.AreEqual(1, list.Count());
                var dto = list.Single();
                Assert.AreEqual(@event.VehicleTypeId, dto.Id);
                Assert.AreEqual(@event.LogoName, dto.LogoName);
                Assert.AreEqual(@event.Name, dto.Name);
                Assert.AreEqual(@event.ReferenceDataVehicleId, dto.ReferenceDataVehicleId);
                Assert.AreEqual(@event.ReferenceNetworkVehicleTypeId, dto.ReferenceNetworkVehicleTypeId);
            }
        }
        public void when_sending_receipt_with_no_dropoff_should_geocode_vehicle_position()
        {
            var orderId = Guid.NewGuid();

            using (var context = new BookingDbContext(DbName))
            {
                context.Save(new OrderStatusDetail
                {
                    OrderId          = orderId,
                    VehicleLatitude  = 45.531608,
                    VehicleLongitude = -73.622791,
                    PickupDate       = DateTime.Now,
                });
            }

            Sut.When(new SendReceipt
            {
                OrderId       = orderId,
                EmailAddress  = "*****@*****.**",
                PickupAddress = new Address
                {
                    FullAddress = "5250, rue Ferrier, Montreal, H1P 4L4",
                    Latitude    = 1.23456,
                    Longitude   = 7.890123
                },
                ClientLanguageCode = "fr"
            });

            // verify templateData (2 times for subject + body)
            TemplateServiceMock.Verify(x => x.Render(It.IsAny <string>(), It.Is <object>(o => ObjectPropertyEquals(o, "DropOffAddress", "7250 Rue du Mile End, Montréal, QC H2R 2W1"))), Times.Exactly(2));
            TemplateServiceMock.Verify(x => x.Render(It.IsAny <string>(), It.Is <object>(o => ObjectPropertyContains(o, "StaticMapUri", "?markers=color:0x1EC022%7Csize:medium%7C1.23456,7.890123&markers=color:0xFF0000%7Csize:medium%7C45.531608,-73.622791"))), Times.Exactly(2));
        }
Beispiel #16
0
        public async Task SeedAsync(BookingDbContext dbContext, IServiceProvider serviceProvider)
        {
            if (dbContext == null)
            {
                throw new ArgumentNullException(nameof(dbContext));
            }

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

            var logger = serviceProvider.GetService <ILoggerFactory>().CreateLogger(typeof(BookingDbContext));

            var seeders = new List <ISeeder>
            {
                new RolesSeeder(),
                new UsersSeeder(),
                new HotelsSeeder(),
                new PeriodsSeeder()
            };

            foreach (var seeder in seeders)
            {
                await seeder.SeedAsync(dbContext, serviceProvider);

                await dbContext.SaveChangesAsync();

                logger.LogInformation($"Seeder {seeder.GetType().Name} done.");
            }
        }
Beispiel #17
0
        public void when_order_completed_then_order_dto_populated()
        {
            var orderCompleted = new OrderStatusChanged
            {
                SourceId    = _orderId,
                Fare        = 23,
                Toll        = 2,
                Tip         = 5,
                Tax         = 12,
                Surcharge   = 1,
                IsCompleted = true
            };

            Sut.Handle(orderCompleted);

            using (var context = new BookingDbContext(DbName))
            {
                var dto = context.Find <OrderDetail>(_orderId);
                Assert.NotNull(dto);
                Assert.NotNull(dto.Status == (int)OrderStatus.Completed);
                Assert.AreEqual(orderCompleted.Fare, dto.Fare);
                Assert.AreEqual(orderCompleted.Toll, dto.Toll);
                Assert.AreEqual(orderCompleted.Tip, dto.Tip);
                Assert.AreEqual(orderCompleted.Tax, dto.Tax);
                Assert.AreEqual(orderCompleted.Surcharge, dto.Surcharge);
            }
        }
        public void when_overdue_payment_logged_then_dto_populated()
        {
            var orderId         = Guid.NewGuid();
            var transactionDate = DateTime.Now;

            Sut.Handle(new OverduePaymentLogged
            {
                OrderId         = orderId,
                IBSOrderId      = 4455,
                Amount          = 42.35m,
                TransactionDate = transactionDate,
                TransactionId   = "1337"
            });

            using (var context = new BookingDbContext(DbName))
            {
                var dto = context.Find <OverduePaymentDetail>(orderId);
                Assert.NotNull(dto);

                Assert.AreEqual(orderId, dto.OrderId);
                Assert.AreEqual(4455, dto.IBSOrderId);
                Assert.AreEqual(42.35m, dto.OverdueAmount);
                Assert.AreEqual("1337", dto.TransactionId);
                Assert.AreEqual(false, dto.IsPaid);
            }
        }
Beispiel #19
0
        public void when_order_switched_to_next_dispatch_company_then_dto_updated()
        {
            const int    ibsOrderId          = 98754;
            const string dispatchCompanyKey  = "x2s42";
            const string dispatchCompanyName = "Vector Industries";

            Sut.Handle(new OrderSwitchedToNextDispatchCompany
            {
                SourceId    = _orderId,
                IBSOrderId  = ibsOrderId,
                CompanyKey  = dispatchCompanyKey,
                CompanyName = dispatchCompanyName
            });

            using (var context = new BookingDbContext(DbName))
            {
                var orderDto = context.Find <OrderDetail>(_orderId);
                Assert.NotNull(orderDto);
                Assert.AreEqual(_orderId, orderDto.Id);
                Assert.AreEqual(ibsOrderId, orderDto.IBSOrderId);
                Assert.AreEqual(dispatchCompanyKey, orderDto.CompanyKey);

                var statusDto = context.Find <OrderStatusDetail>(_orderId);
                Assert.NotNull(statusDto);
                Assert.AreEqual(_orderId, statusDto.OrderId);
                Assert.AreEqual(ibsOrderId, statusDto.IBSOrderId);
                Assert.AreEqual(dispatchCompanyKey, statusDto.CompanyKey);
                Assert.IsNull(statusDto.NextDispatchCompanyKey);
                Assert.IsNull(statusDto.NextDispatchCompanyName);
                Assert.IsNull(statusDto.NetworkPairingTimeout);
                Assert.AreEqual(OrderStatus.Created, statusDto.Status);
            }
        }
        public ActionResult RecoverPassword([Bind(Include = "Username,Password,Email")] Registration registraion)
        {
            using (BookingDbContext dbs = new BookingDbContext())
            {
                var udr = db.registrations.Where(u => u.Email == registraion.Email && u.Username == registraion.Username).FirstOrDefault();
                if (udr != null)
                {
                    // dynamic email = new Email("View");

                    //email.To = registraion.Email;
                    //var udg = db.registrations.Where(m => m.Password == registraion.Password && m.firstName == registraion.firstName);
                    //email.pass = udr.Password;
                    //email.name = registraion.firstName;
                    //email.userName = registraion.Username;
                    //email.message = "Have a great day";
                    //email.Send();
                    //return RedirectToAction("Login");
                }
                else
                {
                    ModelState.AddModelError("", "Invalid Email Address");
                }
            }
            return(View(registraion));
        }
Beispiel #21
0
        public void when_tariff_updated_then_dto_updated()
        {
            Sut.Handle(new TariffUpdated
            {
                SourceId          = _companyId,
                TariffId          = _tariffId,
                DaysOfTheWeek     = DayOfTheWeek.Tuesday,
                KilometricRate    = 19,
                PerMinuteRate     = 20,
                FlatRate          = 20,
                MarginOfError     = 22,
                KilometerIncluded = 26,
                StartTime         = DateTime.Today.AddHours(23),
                EndTime           = DateTime.Today.AddHours(24),
                Name = "Updated Rate",
            });

            using (var context = new BookingDbContext(DbName))
            {
                var list = context.Query <TariffDetail>().Where(x => x.Id == _tariffId);
                Assert.AreEqual(1, list.Count());
                var dto = list.Single();
                Assert.AreEqual(_tariffId, dto.Id);
                Assert.AreEqual(_companyId, dto.CompanyId);
                Assert.AreEqual(20, dto.FlatRate);
                Assert.AreEqual(19, dto.KilometricRate);
                Assert.AreEqual(20, dto.PerMinuteRate);
                Assert.AreEqual(22, dto.MarginOfError);
                Assert.AreEqual(26, dto.KilometerIncluded);
                Assert.AreEqual((int)(DayOfTheWeek.Tuesday), dto.DaysOfTheWeek);
                Assert.AreEqual(23, dto.StartTime.Hour);
                Assert.AreEqual(0, dto.EndTime.Hour);
            }
        }
Beispiel #22
0
 public static void Initialize(IServiceProvider serviceProvider)
 {
     using (var context = new BookingDbContext(serviceProvider.GetRequiredService <DbContextOptions <BookingDbContext> >()))
     {
         Initialize(context);
     }
 }
Beispiel #23
0
 public static void Initialize(BookingDbContext context)
 {
     new BookingStatusBuilder(context).Seed();
     new CitiesBuilder(context).Seed();
     new RoleBuilder(context).Seed();
     new UserProfileBuilder(context).Seed();
 }
Beispiel #24
0
        public void when_address_is_added_to_companydefaultfavorites_then_list_updated()
        {
            var addressId = Guid.NewGuid();

            Sut.Handle(new DefaultFavoriteAddressAdded
            {
                Address = new Address
                {
                    Id           = addressId,
                    FriendlyName = "Chez François",
                    Apartment    = "3938",
                    FullAddress  = "1234 rue Saint-Hubert",
                    RingCode     = "3131",
                    BuildingName = "Hôtel de Ville",
                    Latitude     = 45.515065,
                    Longitude    = -73.558064
                }
            });

            using (var context = new BookingDbContext(DbName))
            {
                var list = context.Query <DefaultAddressDetails>().Where(x => x.Id == addressId);

                Assert.AreEqual(1, list.Count());
                var dto = list.Single();
                Assert.AreEqual(addressId, dto.Id);
                Assert.AreEqual("Chez François", dto.FriendlyName);
                Assert.AreEqual("3938", dto.Apartment);
                Assert.AreEqual("1234 rue Saint-Hubert", dto.FullAddress);
                Assert.AreEqual("3131", dto.RingCode);
                Assert.AreEqual("Hôtel de Ville", dto.BuildingName);
                Assert.AreEqual(45.515065, dto.Latitude);
                Assert.AreEqual(-73.558064, dto.Longitude);
            }
        }
Beispiel #25
0
        public void FixtureSetUp()
        {
            using (var context = new BookingDbContext(DbName))
            {
                context.Save(new AccountDetail
                {
                    Id           = Guid.NewGuid(),
                    Email        = "*****@*****.**",
                    CreationDate = DateTime.Now
                });
            }

            using (var context = new ConfigurationDbContext(DbName))
            {
                context.Save(new NotificationSettings
                {
                    Id      = AppConstants.CompanyId,
                    Enabled = true,
                    BookingConfirmationEmail = true,
                    ConfirmPairingPush       = true,
                    DriverAssignedPush       = true,
                    PaymentConfirmationPush  = true,
                    NearbyTaxiPush           = true,
                    ReceiptEmail             = true,
                    PromotionUnlockedEmail   = true,
                    VehicleAtPickupPush      = true,
                    UnpairingReminderPush    = true,
                    DriverBailedPush         = true,
                    NoShowPush = true
                });
            }
        }
Beispiel #26
0
        public void when_order_created_no_duplicate_address_is_added_to_history_even_if_optional_fields_are_not_set()
        {
            var command = new OrderCreated
            {
                SourceId      = Guid.NewGuid(),
                AccountId     = Guid.NewGuid(),
                PickupAddress = new Address {
                    FullAddress = "1234 rue Saint-Hubert"
                },
                CreatedDate = DateTime.Now.AddDays(-1)
            };

            // Use the same address twice
            Sut.Handle(command);
            Sut.Handle(command);

            using (var context = new BookingDbContext(DbName))
            {
                var list =
                    context.Query <AddressDetails>().Where(
                        x => x.AccountId == command.AccountId && x.IsHistoric.Equals(true));
                Assert.AreEqual(1, list.Count());
                var dto = list.Single();
                Assert.AreEqual(command.AccountId, dto.AccountId);
                Assert.AreEqual(null, dto.Apartment);
                Assert.AreEqual("1234 rue Saint-Hubert", dto.FullAddress);
                Assert.AreEqual(null, dto.RingCode);
                Assert.AreEqual(default(double), dto.Latitude);
                Assert.AreEqual(default(double), dto.Longitude);
            }
        }
Beispiel #27
0
        public void when_company_popular_address_is_updated_successfully()
        {
            Sut.Handle(new PopularAddressUpdated
            {
                Address = new Address
                {
                    Id           = _popularAddressId,
                    FriendlyName = "Chez Costo2 popular !",
                    FullAddress  = "25 rue Berri Montreal",
                    BuildingName = "Hôtel de Ville",
                }
            });

            using (var context = new BookingDbContext(DbName))
            {
                var address = context.Find <PopularAddressDetails>(_popularAddressId);

                Assert.NotNull(address);
                Assert.AreEqual("25 rue Berri Montreal", address.FullAddress);
                Assert.AreEqual("Chez Costo2 popular !", address.FriendlyName);
                Assert.Null(address.RingCode);
                Assert.Null(address.Apartment);
                Assert.AreEqual("Hôtel de Ville", address.BuildingName);
                Assert.AreEqual(0, address.Latitude);
                Assert.AreEqual(0, address.Longitude);
            }
        }
Beispiel #28
0
 public TransactionBehaviour(BookingDbContext dbContext,
                             IBookingIntegrationEventService bookingIntegrationEventService,
                             ILogger <TransactionBehaviour <TRequest, TResponse> > logger)
 {
     _dbContext = dbContext ?? throw new ArgumentException(nameof(BookingDbContext));
     _orderingIntegrationEventService = bookingIntegrationEventService ?? throw new ArgumentException(nameof(bookingIntegrationEventService));
     _logger = logger ?? throw new ArgumentException(nameof(ILogger));
 }
Beispiel #29
0
        public AccountsController(IHttpContextAccessor httpContextAccessor, ISecurityService service)
        {
            Session         = httpContextAccessor.HttpContext.Session;
            _context        = new BookingDbContext();
            securityService = service;

            email = Session.GetString("account");
        }
 public UnitOfWork(BookingDbContext context)
 {
     _context = context;
     ReservationRepository = new Repository <Reservation>(_context);
     DurationRepository    = new Repository <Duration>(_context);
     StatusRepository      = new Repository <Status>(_context);
     GuestRepository       = new Repository <Guest>(_context);
 }
Beispiel #31
0
 public ShowController()
 {
     _dbContext = new BookingDbContext();
 }