Example #1
0
 public void TestDeserializeSingleCityWithValues()
 {
     var expectedCity = new City("Aarau", "Switzerland", 10, 1.1, 2.2);
     var stream = new StringReader(CityWithValues);
     var reader = new SimpleObjectReader(stream);
     var city = reader.Next() as City;
     Assert.IsNotNull(city);
     Assert.AreEqual(expectedCity.Name, city.Name);
     Assert.AreEqual(expectedCity.Country, city.Country);
     Assert.AreEqual(expectedCity.Location.Latitude, city.Location.Latitude);
 }
Example #2
0
        public void TestDeserializeMultCitiesWithValues()
        {
            const string cityString1 = "Instance of Fhnw.Ecnf.RoutePlanner.RoutePlannerLib_JW.City\r\nName=\"Aarau\"\r\nCountry=\"Switzerland\"\r\nPopulation=10\r\nLocation is a nested object...\r\nInstance of Fhnw.Ecnf.RoutePlanner.RoutePlannerLib_JW.WayPoint\r\nName=\"Aarau\"\r\nLongitude=2.2\r\nLatitude=1.1\r\nEnd of instance\r\nEnd of instance\r\n";
            const string cityString2 = "Instance of Fhnw.Ecnf.RoutePlanner.RoutePlannerLib_JW.City\r\nName=\"Bern\"\r\nCountry=\"Switzerland\"\r\nPopulation=10\r\nLocation is a nested object...\r\nInstance of Fhnw.Ecnf.RoutePlanner.RoutePlannerLib_JW.WayPoint\r\nName=\"Bern\"\r\nLongitude=2.2\r\nLatitude=1.1\r\nEnd of instance\r\nEnd of instance\r\n";
            const string cityString = cityString1 + cityString2;
            var expectedCity1 = new City("Aarau", "Switzerland", 10, 1.1, 2.2);
            var expectedCity2 = new City("Bern", "Switzerland", 10, 1.1, 2.2);
            var stream = new StringReader(cityString);
            var reader = new SimpleObjectReader(stream);
            var city1 = reader.Next() as City;

            Assert.IsNotNull(city1);
            Assert.AreEqual(expectedCity1.Name, city1.Name);
            Assert.AreEqual(expectedCity1.Country, city1.Country);
            Assert.AreEqual(expectedCity1.Location.Latitude, city1.Location.Latitude);
            var city2 = reader.Next() as City;
            Assert.IsNotNull(city2);
            Assert.AreEqual(expectedCity2.Name, city2.Name);
            Assert.AreEqual(expectedCity2.Country, city2.Country);
            Assert.AreEqual(expectedCity2.Location.Latitude, city2.Location.Latitude);
        }