コード例 #1
0
        public void DefaultParamsTest()
        {
            string expected = @"<?xml version=""1.0"" encoding=""utf-8""?>" +
                              "<or>" +
                              "<lessthanorequalto>" +
                              "<field>RECORDNO</field>" +
                              "<value>1</value>" +
                              "</lessthanorequalto>" +
                              "<equalto>" +
                              "<field>RECORDNO</field>" +
                              "<value>100</value>" +
                              "</equalto>" +
                              "<equalto>" +
                              "<field>RECORDNO</field>" +
                              "<value>1000</value>" +
                              "</equalto>" +
                              "<equalto>" +
                              "<field>RECORDNO</field>" +
                              "<value>10000</value>" +
                              "</equalto>" +
                              "</or>";

            Stream            stream      = new MemoryStream();
            XmlWriterSettings xmlSettings = new XmlWriterSettings
            {
                Encoding = Encoding.GetEncoding("UTF-8")
            };

            IaXmlWriter xml = new IaXmlWriter(stream, xmlSettings);

            List <IFilter> filters = new List <IFilter>();

            filters.Add((new Filter("RECORDNO")).SetLessThanOrEqualTo("1"));
            filters.Add((new Filter("RECORDNO")).SetEqualTo("100"));
            filters.Add((new Filter("RECORDNO")).SetEqualTo("1000"));
            filters.Add((new Filter("RECORDNO")).SetEqualTo("10000"));
            IFilter orFilter = new OrOperator(filters);

            orFilter.WriteXml(ref xml);

            xml.Flush();

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

            Assert.Equal(expected, reader.ReadToEnd());
        }
コード例 #2
0
        public void NullFilterTest()
        {
            Stream            stream      = new MemoryStream();
            XmlWriterSettings xmlSettings = new XmlWriterSettings
            {
                Encoding = Encoding.GetEncoding("UTF-8")
            };

            IaXmlWriter xml = new IaXmlWriter(stream, xmlSettings);

            IFilter orFilter = new OrOperator(null);

            var ex = Record.Exception(() => orFilter.WriteXml(ref xml));

            Assert.IsType <IntacctException>(ex);
            Assert.Equal("Two or more IFilter objects required for or", ex.Message);
        }
コード例 #3
0
        public void SingleFilterTest()
        {
            Stream            stream      = new MemoryStream();
            XmlWriterSettings xmlSettings = new XmlWriterSettings
            {
                Encoding = Encoding.GetEncoding("UTF-8")
            };

            IaXmlWriter xml = new IaXmlWriter(stream, xmlSettings);

            List <IFilter> filters = new List <IFilter>();

            filters.Add((new Filter("RECORDNO")).SetGreaterThanOrEqualTo("1"));
            IFilter orFilter = new OrOperator(filters);

            var ex = Record.Exception(() => orFilter.WriteXml(ref xml));

            Assert.IsType <IntacctException>(ex);
            Assert.Equal("Two or more IFilter objects required for or", ex.Message);
        }