コード例 #1
0
        public void when_adding_an_item_using_the_base_type_does_the_index_get_updated()
        {
            var testClasses = new List <TestClass>
            {
                new TestClass {
                    TestProperty1 = "Hello1"
                },
                new TestClass {
                    TestProperty1 = "Hello2"
                },
                new TestClass {
                    TestProperty1 = "Hello3"
                },
            };

            var indexedTestClasses = new TestIndexableCollection <TestClass>(testClasses, TestClass.GetIndexSpec());

            var baseCollection = indexedTestClasses as ICollection <TestClass>;

            baseCollection.Add(new TestClass {
                TestProperty1 = "Hello4"
            });

            Assert.AreEqual(4, indexedTestClasses.CountOfValuesIndexedFor(p => p.TestProperty1));
        }
コード例 #2
0
        public void when_inserting_an_item_at_a_particular_index_the_new_item_should_get_indexed()
        {
            var testClasses = new List <TestClass>
            {
                new TestClass {
                    TestProperty1 = "Hello1"
                },
                new TestClass {
                    TestProperty1 = "Hello2"
                },
                new TestClass {
                    TestProperty1 = "Hello3"
                },
            };

            var indexedTestClasses = new TestIndexableCollection <TestClass>(testClasses, TestClass.GetIndexSpec());

            var baseCollection = indexedTestClasses as IList <TestClass>;

            baseCollection.Insert(0, new TestClass {
                TestProperty1 = "Hello4"
            });

            Assert.AreEqual(4, indexedTestClasses.CountOfValuesIndexedFor(p => p.TestProperty1));
        }
コード例 #3
0
        public void when_removing_an_item_at_a_particular_index_the_item_should_be_removed_from_the_index()
        {
            var testClasses = new List <TestClass>
            {
                new TestClass {
                    TestProperty1 = "Hello1"
                },
                new TestClass {
                    TestProperty1 = "Hello2"
                },
                new TestClass {
                    TestProperty1 = "Hello3"
                },
            };

            var indexedTestClasses = new TestIndexableCollection <TestClass>(testClasses, TestClass.GetIndexSpec());

            throw new NotImplementedException();
            //indexedTestClasses.RemoveAt(0);

            Assert.AreEqual(2, indexedTestClasses.CountOfValuesIndexedFor(p => p.TestProperty1));
        }