private void ClearDBButton_Click(object sender, RoutedEventArgs e) { lock (_links) { Task.Run(() => { Application.Current.Dispatcher.Invoke(new Action(() => DBButtonsEnabled = false)); DBInteractor.ClearDB(); Application.Current.Dispatcher.Invoke(new Action(() => DBButtonsEnabled = true)); }); } }
public async Task GetFlightPlan_ShouldReturnFlightPlanById_fromExternalServer() { //arrange - create In Memory Database var options = new DbContextOptionsBuilder <DBInteractor>() .UseInMemoryDatabase(databaseName: "filghtContolDB") .Options; //// Create mocked Context by seeding Data as per Schema/// using (var context = new DBInteractor(options)) { context.Servers.Add(new Server { Id = "1", Url = "serverTest" }); context.ExternalFlights.Add(new ExternalFlight { FlightId = "1", ExternalServerUrl = "serverTest" }); context.SaveChanges(); } //act using (var context = new DBInteractor(options)) { var stub = new StubIServerManager(); FlightPlanController controller = new FlightPlanController(context) { ServerManagerProp = stub }; var actionResult = await controller.GetFlightPlan("1"); var okObject = actionResult as OkObjectResult; //var actualResult = result.Value; var flight = JsonConvert.DeserializeObject <FlightPlan>(okObject.Value.ToString()); Assert.AreEqual(1, flight.Passengers); Assert.AreEqual("testCompany", flight.CompanyName); Assert.AreEqual(3, flight.Segments.Count); Assert.AreEqual(20, flight.InitialLocation.Latitude); Assert.AreEqual(25, flight.InitialLocation.Longitude); } }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, DBInteractor context) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseDefaultFiles(); app.UseStaticFiles(); app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); SeedData.Initialize(context); }
public MessagesController(DBInteractor context) { _context = context; }
public ChatsController(DBInteractor context) { _context = context; }
public ToysController(DBInteractor context) { _context = context; }
public AddressesController(DBInteractor context) { _context = context; }
public FlightPlanController(DBInteractor newDB) { db = newDB; manager = new FlightPlanManager(db); ServerManagerProp = new ServerManager(db); }
public UsersController(DBInteractor context) { db = context; }
public CitiesController(DBInteractor context) { db = context; }
public FlightsController(DBInteractor context) { db = context; manager = new FlightManager(new FlightPlanManager(context), context); ServerManagerProp = new ServerManager(db); }
public ServerController(DBInteractor newDB) { db = newDB; }