Пример #1
0
        public void TestSerializeOtherThings()
        {
            const string expected =
                "Instance of Fhnw.Ecnf.RoutePlanner.RoutePlannerTest.SerializeTest\r\n"
                + "ADouble=0.54444\r\n"
                + "BInt=1\r\n"
                + "CString=\"a\"\r\n"
                + "End of instance\r\n";
            var obj = new SimpleObjectReader(new StringReader(expected)).Next() as SerializeTest;

            Assert.IsNotNull(obj);
            Assert.AreEqual(obj.CString, "a");
            Assert.AreEqual(obj.ADouble, 0.54444);
            Assert.AreEqual(obj.BInt, 1);

            {
                var sw = new StringWriter();
                new SimpleObjectWriter(sw).Next(obj);
                Assert.AreEqual(expected, sw.ToString());
            }

            {
                var tl = new ThirdLevel()
                {
                    T = new SecondLevel()
                    {
                        T = obj
                    }
                };

                var sw = new StringWriter();
                new SimpleObjectWriter(sw).Next(tl);
                Assert.AreEqual(
                    "Instance of Fhnw.Ecnf.RoutePlanner.RoutePlannerTest.ThirdLevel\r\n"
                    + "T is a nested object...\r\n"
                    + "Instance of Fhnw.Ecnf.RoutePlanner.RoutePlannerTest.SecondLevel\r\n"
                    + "T is a nested object...\r\n"
                    + "Instance of Fhnw.Ecnf.RoutePlanner.RoutePlannerTest.SerializeTest\r\n"
                    + "ADouble=0.54444\r\n"
                    + "BInt=1\r\n"
                    + "CString=\"a\"\r\n"
                    + "End of instance\r\n"
                    + "End of instance\r\n"
                    + "End of instance\r\n", sw.ToString());
            }
        }
        public void TestSerializeOtherThings()
        {
            const string expected =
                  "Instance of Fhnw.Ecnf.RoutePlanner.RoutePlannerTest.SerializeTest\r\n"
                + "ADouble=0.54444\r\n"
                + "BInt=1\r\n"
                + "CString=\"a\"\r\n"
                + "End of instance\r\n";
            var obj = new SimpleObjectReader(new StringReader(expected)).Next() as SerializeTest;

            Assert.AreEqual(obj.CString, "a");
            Assert.AreEqual(obj.ADouble, 0.54444);
            Assert.AreEqual(obj.BInt, 1);

            {
                var sw = new StringWriter();
                new SimpleObjectWriter(sw).Next(obj);
                Assert.AreEqual(expected, sw.ToString());
            }

            {
                var tl = new ThirdLevel()
                {
                    t = new SecondLevel()
                    {
                        t = obj
                    }
                };

                var sw = new StringWriter();
                new SimpleObjectWriter(sw).Next(tl);
                Assert.AreEqual(
                      "Instance of Fhnw.Ecnf.RoutePlanner.RoutePlannerTest.ThirdLevel\r\n"
                    + "t is a nested object...\r\n"
                    + "Instance of Fhnw.Ecnf.RoutePlanner.RoutePlannerTest.SecondLevel\r\n"
                    + "t is a nested object...\r\n"
                    + "Instance of Fhnw.Ecnf.RoutePlanner.RoutePlannerTest.SerializeTest\r\n"
                    + "ADouble=0.54444\r\n"
                    + "BInt=1\r\n"
                    + "CString=\"a\"\r\n"
                    + "End of instance\r\n"
                    + "End of instance\r\n"
                    + "End of instance\r\n", sw.ToString());
            }
        }