Ejemplo n.º 1
0
        public void GetXmlTest()
        {
            string expected = @"<?xml version=""1.0"" encoding=""utf-8""?>
<function controlid=""unittest"">
    <create_expensereport>
        <employeeid>E0001</employeeid>
        <datecreated>
            <year>2015</year>
            <month>06</month>
            <day>30</day>
        </datecreated>
        <expenses>
            <expense>
                <glaccountno />
            </expense>
        </expenses>
    </create_expensereport>
</function>";

            ExpenseReportCreate record = new ExpenseReportCreate("unittest")
            {
                EmployeeId      = "E0001",
                TransactionDate = new DateTime(2015, 06, 30)
            };

            ExpenseReportLineCreate line1 = new ExpenseReportLineCreate();

            record.Lines.Add(line1);

            this.CompareXml(expected, record);
        }
        public void GetXmlTest()
        {
            string expected = @"<?xml version=""1.0"" encoding=""utf-8""?>
<function controlid=""unittest"">
    <create_expensereport>
        <employeeid>E0001</employeeid>
        <datecreated>
            <year>2015</year>
            <month>06</month>
            <day>30</day>
        </datecreated>
        <expenses>
            <expense>
                <glaccountno />
            </expense>
        </expenses>
    </create_expensereport>
</function>";

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

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

            IaXmlWriter xml = new IaXmlWriter(stream, xmlSettings);

            ExpenseReportCreate record = new ExpenseReportCreate("unittest");

            record.EmployeeId      = "E0001";
            record.TransactionDate = new DateTime(2015, 06, 30);

            ExpenseReportLineCreate line1 = new ExpenseReportLineCreate();

            record.Lines.Add(line1);

            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());
        }
Ejemplo n.º 3
0
        public void GetAllXmlTest()
        {
            string expected = @"<?xml version=""1.0"" encoding=""utf-8""?>
<function controlid=""unittest"">
    <create_expensereport>
        <employeeid>E0001</employeeid>
        <datecreated>
            <year>2015</year>
            <month>06</month>
            <day>30</day>
        </datecreated>
        <dateposted>
            <year>2015</year>
            <month>06</month>
            <day>30</day>
        </dateposted>
        <batchkey>123</batchkey>
        <expensereportno>ER001</expensereportno>
        <state>Submitted</state>
        <description>For hotel</description>
        <memo>Memo</memo>
        <externalid>122</externalid>
        <basecurr>USD</basecurr>
        <currency>USD</currency>
        <customfields>
            <customfield>
                <customfieldname>customfield1</customfieldname>
                <customfieldvalue>customvalue1</customfieldvalue>
            </customfield>
        </customfields>
        <supdocid>AT122</supdocid>
        <expenses>
            <expense>
                <glaccountno />
            </expense>
        </expenses>
    </create_expensereport>
</function>";

            ExpenseReportCreate record = new ExpenseReportCreate("unittest")
            {
                EmployeeId          = "E0001",
                TransactionDate     = new DateTime(2015, 06, 30),
                GlPostingDate       = new DateTime(2015, 06, 30),
                SummaryRecordNo     = 123,
                ExpenseReportNumber = "ER001",
                Action                = "Submitted",
                ReasonForExpense      = "For hotel",
                Memo                  = "Memo",
                ExternalId            = "122",
                BaseCurrency          = "USD",
                ReimbursementCurrency = "USD",
                AttachmentsId         = "AT122",
                CustomFields          = new Dictionary <string, dynamic>
                {
                    { "customfield1", "customvalue1" }
                },
            };


            ExpenseReportLineCreate line1 = new ExpenseReportLineCreate();

            record.Lines.Add(line1);

            this.CompareXml(expected, record);
        }
        public void GetAllXmlTest()
        {
            string expected = @"<?xml version=""1.0"" encoding=""utf-8""?>
<function controlid=""unittest"">
    <create_expensereport>
        <employeeid>E0001</employeeid>
        <datecreated>
            <year>2015</year>
            <month>06</month>
            <day>30</day>
        </datecreated>
        <dateposted>
            <year>2015</year>
            <month>06</month>
            <day>30</day>
        </dateposted>
        <batchkey>123</batchkey>
        <expensereportno>ER001</expensereportno>
        <state>Submitted</state>
        <description>For hotel</description>
        <memo>Memo</memo>
        <externalid>122</externalid>
        <basecurr>USD</basecurr>
        <currency>USD</currency>
        <customfields>
            <customfield>
                <customfieldname>customfield1</customfieldname>
                <customfieldvalue>customvalue1</customfieldvalue>
            </customfield>
        </customfields>
        <supdocid>AT122</supdocid>
        <expenses>
            <expense>
                <glaccountno />
            </expense>
        </expenses>
    </create_expensereport>
</function>";

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

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

            IaXmlWriter xml = new IaXmlWriter(stream, xmlSettings);

            ExpenseReportCreate record = new ExpenseReportCreate("unittest")
            {
                EmployeeId          = "E0001",
                TransactionDate     = new DateTime(2015, 06, 30),
                GlPostingDate       = new DateTime(2015, 06, 30),
                SummaryRecordNo     = 123,
                ExpenseReportNumber = "ER001",
                Action                = "Submitted",
                ReasonForExpense      = "For hotel",
                Memo                  = "Memo",
                ExternalId            = "122",
                BaseCurrency          = "USD",
                ReimbursementCurrency = "USD",
                AttachmentsId         = "AT122",
                CustomFields          = new Dictionary <string, dynamic>
                {
                    { "customfield1", "customvalue1" }
                },
            };


            ExpenseReportLineCreate line1 = new ExpenseReportLineCreate();

            record.Lines.Add(line1);

            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());
        }