Ejemplo n.º 1
0
        public void AddFilterTest()
        {
            string expected = @"<?xml version=""1.0"" encoding=""utf-8""?>" +
                              "<and>" +
                              "<greaterthanorequalto>" +
                              "<field>RECORDNO</field>" +
                              "<value>1</value>" +
                              "</greaterthanorequalto>" +
                              "<lessthanorequalto>" +
                              "<field>RECORDNO</field>" +
                              "<value>100</value>" +
                              "</lessthanorequalto>" +
                              "</and>";

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

            IaXmlWriter xml = new IaXmlWriter(stream, xmlSettings);

            AndOperator andFilter = new AndOperator(null);

            andFilter.AddFilter((new Filter("RECORDNO")).SetGreaterThanOrEqualTo("1"));
            andFilter.AddFilter((new Filter("RECORDNO")).SetLessThanOrEqualTo("100"));
            andFilter.WriteXml(ref xml);

            xml.Flush();

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

            Assert.Equal(expected, reader.ReadToEnd());
        }
Ejemplo n.º 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 andFilter = new AndOperator(null);

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

            Assert.IsType <IntacctException>(ex);
            Assert.Equal("Two or more IFilter objects required for and", ex.Message);
        }
Ejemplo n.º 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 andFilter = new AndOperator(filters);

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

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