public DatabaseTestDB()
        {
            // gebruik in memory data voor testdata
            // gebruik van context vh te testen project
            var options = new DbContextOptionsBuilder <FlightServicesContext>().UseInMemoryDatabase(Guid.NewGuid().ToString()).Options;

            // property dependancy voorbereiden
            Context = new FlightServicesContext(options);

            Context.Database.EnsureCreated(); // seed vanuit standaard API project door SaveChanges Uit te voeren bij OnModelCreating
            //DatabaseInitializer.Initialize(Context); // extra seeding kan voor test omgeving met FakeData
        }
예제 #2
0
        public FlightsController_Test()
        {
            context         = Context;
            flightList      = Context.Flights;
            departureList   = Context.Departures;
            destinationList = Context.Destinations;
            airplaneList    = Context.Airplanes;
            locationList    = Context.Locations;

            var mapperConfig = new MapperConfiguration(opts =>
            {
                opts.AddProfile(new FlightProfiles());
            });

            this.mapper = mapperConfig.CreateMapper();
        }
예제 #3
0
        private static void Seed(FlightServicesContext context)
        {
            var fakeFlights = new[]
            {
                new Flight
                {
                    Id = Guid.Parse("e5a74ec1-4185-41e4-befc-155c8bbb5d8e"),
                    TimeOfDeparture = DateTime.Parse("24/12/2020 13:40"),
                    TimeOfArrival   = DateTime.Parse("24/12/2020 15:00"),
                    FlightStatus    = "On time",
                    Departure       =
                    {
                        Location    =
                        {
                            Id      = Guid.NewGuid(),
                            Country = "Sweden",
                            City    = "Stockholm",
                            Airport = "ARN"
                        }
                    },
                    Destination =
                    {
                        Location    =
                        {
                            Id      = Guid.NewGuid(),
                            Country = "Belgium",
                            City    = "Charleroi",
                            Airport = "CRL"
                        }
                    },
                    Airplane =
                    {
                        Id         = Guid.NewGuid(),
                        Name       = "CH7652",
                        Type       = "Boejing",
                        TotalSeats = 200
                    }
                },
            };

            context.Flights.AddRange(fakeFlights);
            context.SaveChanges();
        }
예제 #4
0
 //ctor dependancy van de applicatie context:
 public FlightRepo(FlightServicesContext context) : base(context)
 {
     this._context = context;
 }
 public DepartureRepo(FlightServicesContext _context) : base(_context)
 {
     this._context = _context;
 }
예제 #6
0
 //ctor dependancy van de applicatie context:
 public GenericRepo(FlightServicesContext context)
 {
     this._context = context;
 }
예제 #7
0
 public static void Initialize(FlightServicesContext context)
 {
     Seed(context);
 }
예제 #8
0
 public AirplaneRepo(FlightServicesContext _context) : base(_context)
 {
     this.context = _context;
 }
 public ReservationRepo(FlightServicesContext _context) : base(_context)
 {
     this.context = _context;
 }
예제 #10
0
 public DestinationRepo(FlightServicesContext _context) : base(_context)
 {
     context = _context;
 }