public void BufferingReadingTest()
        {
            this.CombinatorialEngineProvider.RunCombinations(
                new bool[] { false, true },
                new bool[] { false, true },
                (moveToElementBeforeRead, verifyAttributes) =>
                {
                    using (XmlReader baselineReader = XmlReader.Create(new StringReader(TestXml)))
                    {
                        this.expectedXmlBaseUriStack.Clear();
                        using (XmlReader comparedReader = XmlReader.Create(new StringReader(TestXml)))
                        {
                            BufferingXmlReader bufferingXmlReader = new BufferingXmlReader(
                                comparedReader,
                                /*parentXmlReader*/ null,
                                /*documentBaseUri*/ null,
                                /*disableXmlBase*/ false,
                                ODataConstants.DefaultMaxRecursionDepth, 
                                this.Assert);
                            bufferingXmlReader.StartBuffering();

                            this.VerifyReadersAreEqual(baselineReader, bufferingXmlReader, Int32.MaxValue, moveToElementBeforeRead, verifyAttributes);
                        }
                    }
                });
        }
Esempio n. 2
0
        public void BufferingAndNonBufferingReaderTest()
        {
            this.CombinatorialEngineProvider.RunCombinations(
                new bool[] { false, true },
                new int[][] {  // The arrays will be looped over until the end of the input. Start non-buffering, reads the number, switches to buffering, reads the number and over.
                new int[] { 3 },
                new int[] { 3, 0 },
                new int[] { 0, 3, 3, 0 },
                new int[] { 1 },
                new int[] { 7 },
            },
                (verifyAttribtues, readCountLoop) =>
            {
                using (XmlReader comparedReader = XmlReader.Create(new StringReader(TestXml)))
                {
                    BufferingXmlReader bufferingXmlReader = new BufferingXmlReader(
                        comparedReader,
                        /*parentXmlReader*/ null,
                        /*documentBaseUri*/ null,
                        /*disableXmlBase*/ false,
                        ODataConstants.DefaultMaxRecursionDepth,
                        this.Assert);

                    var countLoop     = readCountLoop.EndLessLoop();
                    bool buffering    = false;
                    int nodesConsumed = 0;
                    while (true)
                    {
                        countLoop.MoveNext();
                        int readCount = countLoop.Current;

                        using (XmlReader baselineReader = XmlReader.Create(new StringReader(TestXml)))
                        {
                            this.expectedXmlBaseUriStack.Clear();
                            for (int i = 0; i < nodesConsumed; i++)
                            {
                                this.ReadFromBaselineReader(baselineReader);
                            }

                            // Note we have to move to element always, because StartBuffering/StopBuffering is supported only on element boundary.
                            bool moreAvailable = this.VerifyReadersAreEqual(baselineReader, bufferingXmlReader, readCount, true, verifyAttribtues);
                            if (buffering)
                            {
                                bufferingXmlReader.StopBuffering();
                                buffering = false;
                            }
                            else
                            {
                                nodesConsumed += readCount;

                                if (!moreAvailable)
                                {
                                    break;
                                }

                                bufferingXmlReader.StartBuffering();
                                buffering = true;
                            }
                        }
                    }
                }
            });
        }
        public void BufferingAndNonBufferingReaderTest()
        {
            this.CombinatorialEngineProvider.RunCombinations(
                new bool[] { false, true },
                new int[][] {  // The arrays will be looped over until the end of the input. Start non-buffering, reads the number, switches to buffering, reads the number and over.
                    new int[] { 3 },
                    new int[] { 3, 0 },
                    new int[] { 0, 3, 3, 0 },
                    new int[] { 1 },
                    new int[] { 7 },
                },
                (verifyAttribtues, readCountLoop) =>
                {
                    using (XmlReader comparedReader = XmlReader.Create(new StringReader(TestXml)))
                    {
                        BufferingXmlReader bufferingXmlReader = new BufferingXmlReader(
                            comparedReader,
                            /*parentXmlReader*/ null,
                            /*documentBaseUri*/ null,
                            /*disableXmlBase*/ false,
                            ODataConstants.DefaultMaxRecursionDepth,
                            this.Assert);

                        var countLoop = readCountLoop.EndLessLoop();
                        bool buffering = false;
                        int nodesConsumed = 0;
                        while (true)
                        {
                            countLoop.MoveNext();
                            int readCount = countLoop.Current;

                            using (XmlReader baselineReader = XmlReader.Create(new StringReader(TestXml)))
                            {
                                this.expectedXmlBaseUriStack.Clear();
                                for (int i = 0; i < nodesConsumed; i++)
                                {
                                    this.ReadFromBaselineReader(baselineReader);
                                }

                                // Note we have to move to element always, because StartBuffering/StopBuffering is supported only on element boundary.
                                bool moreAvailable = this.VerifyReadersAreEqual(baselineReader, bufferingXmlReader, readCount, true, verifyAttribtues);
                                if (buffering)
                                {
                                    bufferingXmlReader.StopBuffering();
                                    buffering = false;
                                }
                                else
                                {
                                    nodesConsumed += readCount;

                                    if (!moreAvailable)
                                    {
                                        break;
                                    }

                                    bufferingXmlReader.StartBuffering();
                                    buffering = true;
                                }
                            }
                        }
                    }
                });
        }