Ejemplo n.º 1
0
            public void TrueForAll_VerifyVanilla(T[] items)
            {
                T?expectedItem         = default(T);
                SegmentedList <T> list = new SegmentedList <T>();
                Predicate <T>     expectedItemDelegate = delegate(T item) { return(expectedItem == null ? item != null : !expectedItem.Equals(item)); };
                bool typeNullable = default(T) == null;

                for (int i = 0; i < items.Length; ++i)
                {
                    list.Add(items[i]);
                }

                //[] Verify TrueForAll looks at every item
                for (int i = 0; i < items.Length; ++i)
                {
                    expectedItem = items[i];
                    Assert.False(list.TrueForAll(expectedItemDelegate)); //"Err_282308ahid Verify TrueForAll looks at every item FAILED\n"
                }

                //[] Verify TrueForAll returns true if the match returns true on every item
                Assert.True(list.TrueForAll(delegate(T item) { return(true); }),
                            "Err_548ahid Verify TrueForAll returns true if the match returns true on every item FAILED\n");

                //[] Verify TrueForAll returns false if the match returns false on every item
                Assert.True((0 == items.Length) == list.TrueForAll(delegate(T item) { return(false); }),
                            "Err_30848ahidi Verify TrueForAll returns " + (0 == items.Length) + " if the match returns false on every item FAILED\n");
            }
Ejemplo n.º 2
0
            public void TrueForAll_VerifyExceptions(T[] items)
            {
                var list = new SegmentedList <T>(items);

                Assert.True(list.TrueForAll(item => true));
                Assert.Throws <ArgumentNullException>(() => list.TrueForAll(null !)); //"Err_858ahia Expected null match to throw ArgumentNullException"
            }