Exemplo n.º 1
0
        public void WriteXmlDefaultsOverride21Test()
        {
            SdkConfig config = new SdkConfig()
            {
                SenderId       = "testsenderid",
                SenderPassword = "******",
                ControlId      = "testcontrol",
                UniqueId       = true,
                DtdVersion     = "2.1",
                PolicyId       = "testpolicy",
                Debug          = true,
            };

            string expected = @"<?xml version=""1.0"" encoding=""utf-8""?>
<control>
    <senderid>testsenderid</senderid>
    <password>pass123!</password>
    <controlid>testcontrol</controlid>
    <uniqueid>true</uniqueid>
    <dtdversion>2.1</dtdversion>
    <policyid>testpolicy</policyid>
    <includewhitespace>false</includewhitespace>
    <debug>true</debug>
</control>";

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

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

            IaXmlWriter xml = new IaXmlWriter(stream, xmlSettings);

            ControlBlock controlBlock = new ControlBlock(config);

            controlBlock.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());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns a Stream of the XML request
        /// </summary>
        public Stream WriteXml()
        {
            Stream            stream      = new MemoryStream();
            XmlWriterSettings xmlSettings = new XmlWriterSettings();

            xmlSettings.Encoding = encoding;

            IaXmlWriter xml = new IaXmlWriter(stream, xmlSettings);

            xml.WriteStartElement("request");

            control.WriteXml(ref xml);   // Create control block

            operation.WriteXml(ref xml); // Create operation block

            xml.WriteEndElement();       // request

            xml.Flush();

            return(stream);
        }