コード例 #1
0
        public static void Main(string[] args)
        {
            customerDatabaseContext context        = new customerDatabaseContext();
            TruckConnector          truckConnector = new TruckConnector(context);

            truckConnector.getAllTrucksAndUpdateTruckStatus();
        }
コード例 #2
0
        public UnitTests()
        {
            // we will supply a new service provider for each context,
            // that will enable us to have a single database instance per test.
            var serviceProvider = new ServiceCollection()
                                  .AddEntityFrameworkInMemoryDatabase()
                                  .BuildServiceProvider();

            // Build context options
            var builder = new DbContextOptionsBuilder <customerDatabaseContext>()
                          .UseInMemoryDatabase("customerDatabase")
                          .UseInternalServiceProvider(serviceProvider);

            _context = new customerDatabaseContext(builder.Options);
            _context.CustomerTrucks.AddRange(
                Enumerable.Range(1, 10)
                .Select(t => new CustomerTrucks
            {
                VehicleId           = "vehicleID" + t,
                CustomerCompanyName = "customerCompanyName" + t,
                Adress = "adressssss" + t,
                RegNr  = "RegNR" + t,
                TruckConnectionStatus = "iThinkItsConnected" + t
            })
                );

            _context.SaveChanges();
        }
コード例 #3
0
 public TruckConnector(customerDatabaseContext context)
 {
     _context = context;
 }
コード例 #4
0
 public TrucksController(customerDatabaseContext context)
 {
     _context = context;
 }