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

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

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

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

            XElement actual_src = XElement.Parse(@"<number value=""42"" />");

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

            StringBuilder sb = new StringBuilder();

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

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

            string actualstr = XDocument.Parse(sb.ToString()).ToString();

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