Пример #1
0
        public void TestSerializeSingleCityWithValues()
        {
            var c = new City("Aarau", "Switzerland", 10, 1.1, 2.2);

            var stream = new StringWriter();
            var writer = new SimpleObjectWriter(stream);
            writer.Next(c);
            var result = stream.ToString();

            Assert.AreEqual(CityWithValues, result);
        }
Пример #2
0
        public void TestSerializeMultCitiesWithValues()
        {
            const string expectedString1 = "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 expectedString2 = "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 expectedString = expectedString1 + expectedString2;
            var c1 = new City("Aarau", "Switzerland", 10, 1.1, 2.2);
            var c2 = new City("Bern", "Switzerland", 10, 1.1, 2.2);

            var stream = new StringWriter();
            var writer = new SimpleObjectWriter(stream);
            writer.Next(c1);
            var result = stream.ToString();
            Assert.AreEqual(expectedString1, result);

            // write second city
            writer.Next(c2);

            // result is expected to contain both cities
            result = stream.ToString();
            Assert.AreEqual(expectedString, result);
        }