public GpsContext GetContext(bool newInstance = false)
        {
            if (context == null || newInstance == true)
            {
                var options = new DbContextOptionsBuilder <GpsContext>()
                              .UseInMemoryDatabase(databaseName: "TestDb")
                              .Options;

                GpsContext gpsContext = new GpsContext(options);
                gpsContext.Database.EnsureDeleted(); //Make sure that data will be deleted

                List <Locations> locations = LocationsListStub.GetLocationsList();
                gpsContext.Locations.AddRange(locations);

                List <Trackers> trackers = TrackersListStub.GetTrackersList();
                gpsContext.Trackers.AddRange(trackers);

                List <Transports> transports = TransportListStub.GetTransportList();
                gpsContext.Transports.AddRange(transports);

                List <Orders> orders = OrdersListStub.GetOrdersList();
                gpsContext.Orders.AddRange(orders);

                Users user = UserStub.GetUser();
                gpsContext.Users.Add(user);


                gpsContext.SaveChanges();
                context = gpsContext;
            }

            return(context);
        }
 public AuthenticationService(GpsContext context)
 {
     _context = context;
 }
Example #3
0
 public GpsController(GpsContext context)
 {
     _context = context;
 }