Exemplo n.º 1
0
        /// <summary>
        /// Applies Capacity+1 times the same test to the same buffer "logical" content but with
        /// different internal offsets each time.
        /// The "logical" initial buffer content is restored each time and at the end of the test.
        /// </summary>
        static void TestWithInternalOffsets <T>(FIFOBuffer <T> f, Action <FIFOBuffer <T> > testPredicate)
        {
            var saved = f.ToArray();

            for (int iTry = 0; iTry <= f.Capacity; ++iTry)
            {
                f.Clear();
                for (int i = 0; i < iTry; ++i)
                {
                    f.Push(default(T));
                }
                foreach (var i in saved)
                {
                    f.Push(i);
                }
                while (f.Count > saved.Length)
                {
                    f.Pop();
                }
                f.SequenceEqual(saved).Should().BeTrue();
                testPredicate(f);
            }
            foreach (var i in saved)
            {
                f.Push(i);
            }
            f.Truncate(saved.Length);
        }