コード例 #1
0
        private Test CreateIndexerGetItemsAtInvalidIndexTest()
        {
            return(new TestCase("GetItemsAtInvalidIndex", () =>
            {
                AssertDistinctIntancesNotEmpty();
                var handler = new ListHandler <TList, TItem>(GetSafeDefaultInstance(), Context);

                Assert.Multiple(() =>
                {
                    handler.DoActionAtInvalidIndex(x => - 1, (list, index) => { var o = list[index]; }, "Indexer Getter");         // Negative index.
                    handler.DoActionAtInvalidIndex(x => x.Count + 1, (list, index) => { var o = list[index]; }, "Indexer Getter"); // Index too high.
                });
            }));
        }
コード例 #2
0
        private Test CreateInsertItemsAtInvalidIndexTest()
        {
            return(new TestCase("InsertItemsAtInvalidIndex", () =>
            {
                AssertDistinctIntancesNotEmpty();
                var list = GetSafeDefaultInstance();
                var handler = new ListHandler <TList, TItem>(list, Context);
                var initialContent = new List <TItem>(list);

                Assert.Multiple(() =>
                {
                    foreach (var item in DistinctInstances)
                    {
                        if (!initialContent.Contains(item))
                        {
                            handler.DoActionAtInvalidIndex(x => - 1, (l, i) => l.Insert(i, item), "Insert");         // Negative index.
                            handler.DoActionAtInvalidIndex(x => x.Count + 1, (l, i) => l.Insert(i, item), "Insert"); // Index too high.
                        }
                    }
                });
            }));
        }