Esempio n. 1
0
        public async Task SetAllRidesToAccepted_AllRidesHasStatusWaitingForAccept_UpdateChangesRideToAccepted()
        {
            //Add customer to ensure constraints holds
            var customer = new Customer();


            //Create list
            List <Ride> rides = new List <Ride>()
            {
                new Ride()
                {
                    CustomerId           = customer.Id,
                    DepartureTime        = DateTime.Now,
                    ConfirmationDeadline = DateTime.Now,
                    PassengerCount       = 0,
                    CreatedOn            = DateTime.Now,
                    Price            = 100,
                    Status           = RideStatus.WaitingForAccept,
                    EndDestination   = new Address("City", 8200, "Street", 21),
                    StartDestination = new Address("City", 8200, "Street", 21)
                },
                new Ride()
                {
                    CustomerId           = customer.Id,
                    DepartureTime        = DateTime.Now,
                    ConfirmationDeadline = DateTime.Now,
                    PassengerCount       = 0,
                    CreatedOn            = DateTime.Now,
                    Price            = 100,
                    Status           = RideStatus.WaitingForAccept,
                    EndDestination   = new Address("City", 8200, "Street", 21),
                    StartDestination = new Address("City", 8200, "Street", 21)
                }
            };

            using (var context = _factory.CreateContext())
            {
                context.Customers.Add(customer);
                context.SaveChanges();
            }

            _uut.RideRepository.SetAllRidesToAccepted(rides);
            await _uut.SaveChangesAsync();

            using (var context = _factory.CreateContext())
            {
                //Dummy expression to get all as a list
                foreach (var ride in context.Rides.Where(x => x.Price != -1))
                {
                    Assert.That(ride.Status, Is.EqualTo(RideStatus.Accepted));
                }
            }
        }
        public void SetUp()
        {
            _factory = new InMemorySqlLiteContextFactory();
            var identityRepository = Substitute.For <IIdentityUserRepository>();

            _uut = new UnitOfWork.UnitOfWork(_factory.CreateContext(), identityRepository);
        }
Esempio n. 3
0
 public void SetUp()
 {
     _factory = new InMemorySqlLiteContextFactory();
     //Store context to ensure it's possible to save changes for testing.
     _context = _factory.CreateContext();
     _uut     = new GenericRepository <Customer>(_context);
 }
Esempio n. 4
0
 public void SetUp()
 {
     _factory = new InMemorySqlLiteContextFactory <TContext>(options => Activator.CreateInstance(typeof(TContext), options) as TContext);
     _context = _factory.CreateContext(true);
     _publish = Substitute.For <IPublishEndpoint>();
     _authorizationService = Substitute.For <IAuthorizationService>();
     _eventService         = EventServiceFactory.CreateEventService(_context, _publish);
 }
        private Customer addCustomerToTestDatabase(int balance = 0, int reservedAmount = 0)
        {
            Customer customer = new Customer
            {
                Email          = "*****@*****.**",
                Name           = "Name",
                PhoneNumber    = "12345678",
                Balance        = balance,
                ReservedAmount = reservedAmount
            };

            using (var context = _factory.CreateContext())
            {
                context.Customers.Add(customer);
                context.SaveChanges();
            }

            return(customer);
        }
        private TaxiCompany addTaxiCompanyToTestDatabase(int balance = 0)
        {
            TaxiCompany taxiCompany = new TaxiCompany
            {
                Email       = "*****@*****.**",
                Name        = "Name",
                PhoneNumber = "12345678"
            };

            using (var context = _factory.CreateContext())
            {
                context.TaxiCompanies.Add(taxiCompany);
                context.SaveChanges();
            }

            return(taxiCompany);
        }
Esempio n. 7
0
        public async Task AddRideToOrder_OrderAndRideExists_1RideAddedToOrder()
        {
            Customer customer = new Customer();
            Order    order    = new Order();

            using (var context = _factory.CreateContext())
            {
                context.Customers.Add(customer);
                context.Orders.Add(order);
                context.SaveChanges();
            }

            SoloRide soloRide = new SoloRide()
            {
                CustomerId           = customer.Id,
                DepartureTime        = DateTime.Now,
                ConfirmationDeadline = DateTime.Now,
                PassengerCount       = 0,
                CreatedOn            = DateTime.Now,
                Price            = 100,
                Status           = RideStatus.WaitingForAccept,
                EndDestination   = new Address("City", 8200, "Street", 21),
                StartDestination = new Address("City", 8200, "Street", 21)
            };
            await _uut.OrderRepository.AddRideToOrderAsync(soloRide, order);

            await _uut.SaveChangesAsync();

            using (var context = _factory.CreateContext())
            {
                Assert.That(context.Orders.Find(order.Id).Rides.Count, Is.EqualTo(1));
            }
        }
Esempio n. 8
0
        public async Task All_1EntityInDatabase_ReturnsEntity()
        {
            using (var context = _factory.CreateContext())
            {
                context.Customers.Add(new Customer());
                context.SaveChanges();
            }

            var entities = await _uut.AllAsync();

            Assert.That(entities.Count, Is.EqualTo(1));
        }