Пример #1
0
        public void GetAllXmlTest()
        {
            string expected = @"<?xml version=""1.0"" encoding=""utf-8""?>
<itemdetail>
    <quantity>15325</quantity>
    <serialno>S2355235</serialno>
    <aisle>55</aisle>
    <row>1</row>
    <bin>12</bin>
</itemdetail>";

            Stream            stream      = new MemoryStream();
            XmlWriterSettings xmlSettings = new XmlWriterSettings();

            xmlSettings.Encoding    = Encoding.UTF8;
            xmlSettings.Indent      = true;
            xmlSettings.IndentChars = "    ";

            IaXmlWriter xml = new IaXmlWriter(stream, xmlSettings);

            TransactionItemDetail record = new TransactionItemDetail()
            {
                Quantity     = 15325,
                SerialNumber = "S2355235",
                Aisle        = "55",
                Row          = "1",
                Bin          = "12",
            };

            record.WriteXml(ref xml);

            xml.Flush();
            stream.Position = 0;
            StreamReader reader = new StreamReader(stream);

            Diff xmlDiff = DiffBuilder.Compare(expected).WithTest(reader.ReadToEnd())
                           .WithDifferenceEvaluator(DifferenceEvaluators.Default)
                           .Build();

            Assert.IsFalse(xmlDiff.HasDifferences(), xmlDiff.ToString());
        }
Пример #2
0
        public void GetXmlTest()
        {
            string expected = @"<?xml version=""1.0"" encoding=""utf-8""?>
<itemdetail>
    <quantity>5523</quantity>
    <lotno>223</lotno>
    <itemexpiration>
        <year>2017</year>
        <month>12</month>
        <day>31</day>
    </itemexpiration>
</itemdetail>";

            Stream            stream      = new MemoryStream();
            XmlWriterSettings xmlSettings = new XmlWriterSettings();

            xmlSettings.Encoding    = Encoding.UTF8;
            xmlSettings.Indent      = true;
            xmlSettings.IndentChars = "    ";

            IaXmlWriter xml = new IaXmlWriter(stream, xmlSettings);

            TransactionItemDetail record = new TransactionItemDetail()
            {
                Quantity       = 5523,
                LotNumber      = "223",
                ItemExpiration = new DateTime(2017, 12, 31),
            };

            record.WriteXml(ref xml);

            xml.Flush();
            stream.Position = 0;
            StreamReader reader = new StreamReader(stream);

            Diff xmlDiff = DiffBuilder.Compare(expected).WithTest(reader.ReadToEnd())
                           .WithDifferenceEvaluator(DifferenceEvaluators.Default)
                           .Build();

            Assert.IsFalse(xmlDiff.HasDifferences(), xmlDiff.ToString());
        }