public void ImportLocations_BigZippedFile_ParseAll(string filePath)
        {
            var discovered = new ImportLocationService().ImportLocations(filePath);

            discovered.Should()
            .NotContainNulls()
            .And.OnlyHaveUniqueItems()
            .And.OnlyContain(loc => loc.CountryCode.Length == 2);
        }
        public void ImportLocations_BigFile_ParseAll()
        {
            var discovered = new ImportLocationService()
                             .ImportLocations(@".\Data\AllLocations.json");

            discovered.Should()
            .NotContainNulls()
            .And.OnlyHaveUniqueItems()
            .And.HaveCountGreaterThan(100);
        }
Exemplo n.º 3
0
        protected override void Seed(OpenWeatherMap.DataAccess.DatabaseContext context)
        {
            if (!context.Locations.Any())
            {
                var importService = new ImportLocationService();
                //var filePath = Path.Combine(Directory.GetCurrentDirectory(),
                //							@"PredefinedData\city.list.json.gz");
                var locations = importService.ImportLocations(@"D:\Projects\LIS\studying\pet_projects\weather\simple_client\Weather.Solution\OpenWeatherMap.DataAccess\PredefinedData\city.list.json.gz");
                context.Locations.AddRange(locations);

                try
                {
                    context.SaveChanges();
                }
                catch (DbEntityValidationException exc)
                {
                    foreach (var result in exc.EntityValidationErrors)
                    {
                        Console.WriteLine($"{result.Entry} has validation errors {string.Join("\n", result.ValidationErrors.Select(err => $"{err.PropertyName}: {err.ErrorMessage}"))}");
                    }
                }
            }
        }
        public void ImportLocations_FileWithTwoLocations_ParseTwoItemsOut(string filePath)
        {
            var discovered = new ImportLocationService().ImportLocations(filePath);

            discovered.Should().HaveCount(2);
        }