예제 #1
0
        public void Test_Deserialize_DataContract()
        {
            var    ipnetwork  = IPNetwork.Parse("10.0.0.1/8");
            string serialized = DataContractSerializeHelper.Serialize(ipnetwork);

            var result = DataContractSerializeHelper.Deserialize <IPNetwork>(serialized);

            Assert.AreEqual(ipnetwork, result);
        }
예제 #2
0
        public void Test_Serialize_DataContract()
        {
            var ipnetwork = IPNetwork.Parse("10.0.0.1/8");

            string result = DataContractSerializeHelper.Serialize(ipnetwork);

            string expected = $"<IPNetwork xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:x=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"http://schemas.datacontract.org/2004/07/System.Net\">{Environment.NewLine}  <IPNetwork i:type=\"x:string\" xmlns=\"\">10.0.0.0/8</IPNetwork>{Environment.NewLine}</IPNetwork>";

            Assert.AreEqual(expected, result);
        }