Пример #1
0
        public void GetXmlTest()
        {
            string expected = @"<?xml version=""1.0"" encoding=""utf-8""?>
<function controlid=""unittest"">
    <create>
        <TIMESHEET>
            <EMPLOYEEID>E1234</EMPLOYEEID>
            <BEGINDATE>06/30/2016</BEGINDATE>
            <TIMESHEETENTRIES>
                <TIMESHEETENTRY>
                    <ENTRYDATE>06/30/2016</ENTRYDATE>
                    <QTY>1.75</QTY>
                </TIMESHEETENTRY>
            </TIMESHEETENTRIES>
        </TIMESHEET>
    </create>
</function>";

            TimesheetCreate record = new TimesheetCreate("unittest")
            {
                EmployeeId = "E1234",
                BeginDate  = new DateTime(2016, 06, 30)
            };

            TimesheetEntryCreate entry = new TimesheetEntryCreate
            {
                EntryDate = new DateTime(2016, 06, 30),
                Quantity  = 1.75M
            };

            record.Entries.Add(entry);

            this.CompareXml(expected, record);
        }
Пример #2
0
        public void GetXmlTest()
        {
            string expected = @"<?xml version=""1.0"" encoding=""utf-8""?>
<function controlid=""unittest"">
    <create>
        <TIMESHEET>
            <EMPLOYEEID>E1234</EMPLOYEEID>
            <BEGINDATE>06/30/2016</BEGINDATE>
            <TIMESHEETENTRIES>
                <TIMESHEETENTRY>
                    <ENTRYDATE>06/30/2016</ENTRYDATE>
                    <QTY>1.75</QTY>
                </TIMESHEETENTRY>
            </TIMESHEETENTRIES>
        </TIMESHEET>
    </create>
</function>";

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

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

            IaXmlWriter xml = new IaXmlWriter(stream, xmlSettings);

            TimesheetCreate record = new TimesheetCreate("unittest");

            record.EmployeeId = "E1234";
            record.BeginDate  = new DateTime(2016, 06, 30);

            TimesheetEntryCreate entry = new TimesheetEntryCreate();

            entry.EntryDate = new DateTime(2016, 06, 30);
            entry.Quantity  = 1.75M;

            record.Entries.Add(entry);

            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());
        }
Пример #3
0
        public void GetAllXmlTest()
        {
            string expected = @"<?xml version=""1.0"" encoding=""utf-8""?>
<function controlid=""unittest"">
    <create>
        <TIMESHEET>
            <EMPLOYEEID>E1234</EMPLOYEEID>
            <BEGINDATE>06/30/2016</BEGINDATE>
            <DESCRIPTION>desc</DESCRIPTION>
            <SUPDOCID>A1234</SUPDOCID>
            <STATE>Submitted</STATE>
            <TIMESHEETENTRIES>
                <TIMESHEETENTRY>
                    <ENTRYDATE>06/30/2016</ENTRYDATE>
                    <QTY>1.75</QTY>
                </TIMESHEETENTRY>
            </TIMESHEETENTRIES>
            <customfield1>customvalue1</customfield1>
        </TIMESHEET>
    </create>
</function>";

            TimesheetCreate record = new TimesheetCreate("unittest")
            {
                EmployeeId    = "E1234",
                BeginDate     = new DateTime(2016, 06, 30),
                Description   = "desc",
                AttachmentsId = "A1234",
                Action        = "Submitted",
                CustomFields  = new Dictionary <string, dynamic>
                {
                    { "customfield1", "customvalue1" }
                }
            };

            TimesheetEntryCreate entry = new TimesheetEntryCreate
            {
                EntryDate = new DateTime(2016, 06, 30),
                Quantity  = 1.75M
            };

            record.Entries.Add(entry);

            this.CompareXml(expected, record);
        }
Пример #4
0
        public void GetAllXmlTest()
        {
            string expected = @"<?xml version=""1.0"" encoding=""utf-8""?>
<function controlid=""unittest"">
    <create>
        <TIMESHEET>
            <EMPLOYEEID>E1234</EMPLOYEEID>
            <BEGINDATE>06/30/2016</BEGINDATE>
            <DESCRIPTION>desc</DESCRIPTION>
            <SUPDOCID>A1234</SUPDOCID>
            <STATE>Submitted</STATE>
            <TIMESHEETENTRIES>
                <TIMESHEETENTRY>
                    <ENTRYDATE>06/30/2016</ENTRYDATE>
                    <QTY>1.75</QTY>
                </TIMESHEETENTRY>
            </TIMESHEETENTRIES>
            <customfield1>customvalue1</customfield1>
        </TIMESHEET>
    </create>
</function>";

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

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

            IaXmlWriter xml = new IaXmlWriter(stream, xmlSettings);

            TimesheetCreate record = new TimesheetCreate("unittest");

            record.EmployeeId    = "E1234";
            record.BeginDate     = new DateTime(2016, 06, 30);
            record.Description   = "desc";
            record.AttachmentsId = "A1234";
            record.Action        = "Submitted";
            record.CustomFields  = new Dictionary <string, dynamic>
            {
                { "customfield1", "customvalue1" }
            };

            TimesheetEntryCreate entry = new TimesheetEntryCreate();

            entry.EntryDate = new DateTime(2016, 06, 30);
            entry.Quantity  = 1.75M;

            record.Entries.Add(entry);

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