Esempio n. 1
0
        static void GenerateData()
        {
            using (var dbContext = new ForecastDbContext())
            {
                dbContext.Database.EnsureCreated();

                if (!dbContext.ForecastDays.Any())
                {
                    Entities.SolarSystems.MeLi.MeLiSolarSystem meliSolarSystem = new Entities.SolarSystems.MeLi.MeLiSolarSystem();
                    for (int i = 0; i < (365 * 10); i++)
                    {
                        ForecastDay forecastDay = new ForecastDay();
                        forecastDay.Day                     = i;
                        forecastDay.FerengiPosition         = meliSolarSystem.FerengiPlanet.GetPosition(i).ToString();
                        forecastDay.FerengiAngle            = meliSolarSystem.FerengiPlanet.GetAngle(i);
                        forecastDay.BetasoidePosition       = meliSolarSystem.BetasoidePlanet.GetPosition(i).ToString();
                        forecastDay.BetasoideAngle          = meliSolarSystem.BetasoidePlanet.GetAngle(i);
                        forecastDay.VulcanoPosition         = meliSolarSystem.VulcanoPlanet.GetPosition(i).ToString();
                        forecastDay.VulcanoAngle            = meliSolarSystem.VulcanoPlanet.GetAngle(i);
                        forecastDay.AreAlignedWithTheSun    = meliSolarSystem.AreAlignedWithTheSun((uint)i);
                        forecastDay.AreAlignedWithoutTheSun = meliSolarSystem.AreAlignedWithoutTheSun((uint)i);
                        forecastDay.IsSunInside             = meliSolarSystem.IsSunInside((uint)i);
                        forecastDay.Weather                 = meliSolarSystem.GetWeather((uint)i);
                        forecastDay.TrianglePerimeter       = meliSolarSystem.GetTrianglePerimeter((uint)i);
                        dbContext.ForecastDays.Add(forecastDay);
                    }
                    dbContext.SaveChanges();
                }
            }
        }
Esempio n. 2
0
        public ForecastDbContextFixture()
        {
            ForecastDbContext = new ForecastDbContext(new DbContextOptionsBuilder <ForecastDbContext>()
                                                      .UseInMemoryDatabase("unit testing")
                                                      .Options);

            // create data for test
            ForecastDbContext.Database.EnsureCreated();
            ForecastDbContext.WeathreForecasts.AddRange(
                new WeatherForecast {
                Id = 1, Date = DateTimeOffset.ParseExact("2020/04/01", "yyyy/MM/dd", null), Summary = "s1", TemperatureC = 0
            },
                new WeatherForecast {
                Id = 2, Date = DateTimeOffset.ParseExact("2020/04/02", "yyyy/MM/dd", null), Summary = "s2", TemperatureC = 10
            },
                new WeatherForecast {
                Id = 3, Date = DateTimeOffset.ParseExact("2020/04/03", "yyyy/MM/dd", null), Summary = "s3", TemperatureC = 20
            }
                );
            ForecastDbContext.SaveChanges();
        }