コード例 #1
0
        public void TryWriteXmlOfFunctionWithoutName_ThrowException()
        {
            IilFunction actual_src = new IilFunction();

            XmlSerializer serializer = new XmlSerializer(typeof (IilFunction));

            Assert.Catch<Exception>(() => serializer.Serialize(GenerateWriter(), actual_src));
        }
コード例 #2
0
        public void ReadXmlOfFunctionWithChildren_EisFunctionObjectWithChildren()
        {
            IilFunction expected = new IilFunction("test_fun", new IilIdentifier("test_id"), new IilNumeral(42));

            XmlSerializer serializer = new XmlSerializer(typeof (IilFunction));

            XElement actual_src = XElement.Parse(
                @"<function name=""test_fun"">
                    <identifier value=""test_id"" />
                    <number value=""42"" />
                </function>");

            IilFunction actual = (IilFunction) serializer.Deserialize(actual_src.CreateReader());
            Assert.AreEqual(expected, actual);
        }
コード例 #3
0
        public void WriteXmlOfFunctionWithChildren_ReturnXmlWithContentAsChildren()
        {
            IilFunction actual_src = new IilFunction("test_fun", new IilNumeral(42));

            StringBuilder sb = new StringBuilder();

            XmlSerializer serializer = new XmlSerializer(typeof (IilFunction));
            serializer.Serialize(XmlWriter.Create(sb), actual_src);

            XDocument expected = XDocument.Parse(
                @"<?xml version=""1.0"" encoding=""utf-16""?>
                <function name=""test_fun"">
                    <number value=""42"" />
                </function>");
            XDocument actual = XDocument.Parse(sb.ToString());

            Assert.AreEqual(expected.ToString(), actual.ToString());
        }