Esempio n. 1
0
 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);
            }
        }
Esempio n. 3
0
        // 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);
        }
Esempio n. 4
0
 public MessagesController(DBInteractor context)
 {
     _context = context;
 }
Esempio n. 5
0
 public ChatsController(DBInteractor context)
 {
     _context = context;
 }
Esempio n. 6
0
 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);
 }
Esempio n. 9
0
 public UsersController(DBInteractor context)
 {
     db = context;
 }
Esempio n. 10
0
 public CitiesController(DBInteractor context)
 {
     db = context;
 }
Esempio n. 11
0
 public FlightsController(DBInteractor context)
 {
     db                = context;
     manager           = new FlightManager(new FlightPlanManager(context), context);
     ServerManagerProp = new ServerManager(db);
 }
Esempio n. 12
0
 public ServerController(DBInteractor newDB)
 {
     db = newDB;
 }