Ejemplo n.º 1
0
        public void FromEmptyWeatherInfo()
        {
            var parser                = new TemperatureParser();
            var weatherlist           = new List <string>();
            var weatherInfoCollection = parser.GetWeatherInfoCollection("emptyTestList", weatherlist);

            Assert.AreEqual(weatherInfoCollection.Count, 0);
        }
Ejemplo n.º 2
0
        public void FromSingleWeatherInfoWithPrecipitation()
        {
            var parser      = new TemperatureParser();
            var weatherlist = new List <string>()
            {
                "12/25/2017,200,-200,1.1"
            };
            var weatherInfoCollection = parser.GetWeatherInfoCollection("singleTestList", weatherlist);

            Assert.AreEqual(weatherInfoCollection.Count, 1);
        }
Ejemplo n.º 3
0
        public void FromSingleWeatherInfoNoPrecipitationCorruptLowTemp()
        {
            var parser      = new TemperatureParser();
            var weatherlist = new List <string>()
            {
                "12/25/2017,200,-2{corrupt}00"
            };
            var weatherInfoCollection = parser.GetWeatherInfoCollection("singleTestList", weatherlist);

            Assert.AreEqual(weatherInfoCollection.Count, 0);
        }
Ejemplo n.º 4
0
        public void FromManyWeatherInfoMixedPrecipitationContainingDuplicates()
        {
            var parser      = new TemperatureParser();
            var weatherlist = new List <string>()
            {
                "12/25/2017,200,-200", "12/25/2017,200,-200", "12/25/2017,200,-200,1.1"
            };
            var weatherInfoCollection = parser.GetWeatherInfoCollection("manyDuplicateTestList", weatherlist);

            Assert.AreEqual(weatherInfoCollection.Count, 3);
        }
Ejemplo n.º 5
0
        public void FromManyWeatherInfoWithPrecipitationMultiCorrupt()
        {
            var parser      = new TemperatureParser();
            var weatherlist = new List <string>()
            {
                "12/{corrupt}25/2017,200,-200,1.1", "12/26/2017,20{corrupt}0,-200,1.1", "12/27/2017,200,-2{corrupt}00,1.1", "12/27/2017,200,-200,1.{corrupt}1"
            }
            ;
            var weatherInfoCollection = parser.GetWeatherInfoCollection("manyWeatherMultiCorruptionTestList", weatherlist);

            Assert.AreEqual(weatherInfoCollection.Count, 0);
        }
Ejemplo n.º 6
0
        public void FromManyWeatherInfoWithoutPrecipitationSingleCorrupt()
        {
            var parser      = new TemperatureParser();
            var weatherlist = new List <string>()
            {
                "12/25/2017,20{corrupt}0,-200", "12/26/2017,200,-200", "12/27/2017,200,-200"
            }
            ;
            var weatherInfoCollection = parser.GetWeatherInfoCollection("manyWeatherSingleCorruptionTestList", weatherlist);

            Assert.AreEqual(weatherInfoCollection.Count, 2);
        }
Ejemplo n.º 7
0
        public void FromManyWeatherInfoSinglePrecipitationLast()
        {
            var parser      = new TemperatureParser();
            var weatherlist = new List <string>()
            {
                "12/25/2017,200,-200", "12/26/2017,200,-200", "12/27/2017,200,-200,1.1"
            }
            ;
            var weatherInfoCollection = parser.GetWeatherInfoCollection("manyTestList", weatherlist);

            Assert.AreEqual(weatherInfoCollection.Count, 3);
        }
        private async Task <WeatherInfoCollection> getData()
        {
            if (this.ImportDialog.File.FileType == "xml")
            {
                this.NewWeatherInfoCollection = await XMLSerializer.ReadWeatherCollection(this.ImportDialog.File);
            }
            else
            {
                var fileReader = new FileLineGenerator();

                var lines = await fileReader.GetFileLines(this.ImportDialog.File);

                var weatherDataParser = new TemperatureParser();
                this.NewWeatherInfoCollection =
                    weatherDataParser.GetWeatherInfoCollection(this.ImportDialog.CollectionName, lines);
                this.ErrorMessageList = weatherDataParser.ErrorMessages.ToList();
            }
            return(this.NewWeatherInfoCollection);
        }