상속: DbContext
 public void CanGetWeatherEventsFilteredByDate()
 {
     _context = CreateAndSeedContext();
     using (var controller = new WeatherController(_context,null))
     {
         var results = controller.Get(DateTime.Now.Date);
         Assert.Equal(2, results.Count());
     }
 }
 public void CanGetWeatherEvents()
 {
     _context = CreateAndSeedContext();
     using (var controller = new WeatherController(_context,null))
     {
         var results = controller.Get();
         Assert.Equal(7, results.Count());
     }
 }
        private WeatherContext CreateAndSeedContext()
        {
            var optionsBuilder = new DbContextOptionsBuilder<WeatherContext>();
            optionsBuilder.UseInMemoryDatabase();

            var context = new WeatherContext(optionsBuilder.Options);
            context.Database.EnsureDeleted();
            context.Database.EnsureCreated();
            context.WeatherEvents.AddRange(BuildWeatherEvents());
            context.SaveChanges();
            return context;

        }
        private WeatherContext CreateAndSeedContext()
        {
            // All contexts that share the same service provider will share the same InMemory database
            var serviceProvider = _services.BuildServiceProvider();
            var serviceScope = serviceProvider.GetRequiredService<IServiceScopeFactory>().CreateScope();
            context = serviceScope.ServiceProvider.GetService<WeatherContext>();

            context.WeatherEvents.AddRange(BuildWeatherEvents());
            context.SaveChanges();

            return context;



        }
 public WeatherController(WeatherContext context, WeatherDataRepository services)
 {
     _context = context;
     _repo = services;
 }
 public WeatherDataRepository(WeatherContext context)
 {
     _context = context;
 }