예제 #1
0
 public void AddRangeTest()
 {
     Collection.AddRange(new List <string> {
         "Name", "Email"
     });
     Assert.AreEqual(Collection.Length, 2);
 }
예제 #2
0
        public void IndexedCollection_AddRange_Duplicate()
        {
            var collection = new IndexedCollection <int, TestObject>(t => t.Sequence);

            collection.AddRange(_objects);
            collection.AddRange(_objects.GetRange(0, 1));
        }
예제 #3
0
        public void IndexedCollection_AddRange()
        {
            var collection = new IndexedCollection <int, TestObject>(t => t.Sequence);

            collection.AddRange(_objects);

            Assert.AreEqual(1000, collection.Count);
        }
예제 #4
0
        public void IndexedCollection_CopyToNullArray()
        {
            int count      = 10;
            var collection = new IndexedCollection <int, TestObject>(t => t.Sequence);

            collection.AddRange(_objects.GetRange(0, count));

            TestObject[] array = null;
            collection.CopyTo(array, 0);
        }
예제 #5
0
        public void IndexedCollection_Remove()
        {
            int count      = 10;
            var collection = new IndexedCollection <int, TestObject>(t => t.Sequence);

            collection.AddRange(_objects.GetRange(0, count));

            Assert.AreEqual(true, collection.Remove(_objects[9]));
            Assert.AreEqual(false, collection.Remove(_objects[9]));
            Assert.AreEqual(count - 1, collection.Count);
        }
예제 #6
0
        public void IndexedCollection_CopyToNotEnoughSpace()
        {
            int count      = 10;
            var collection = new IndexedCollection <int, TestObject>(t => t.Sequence);

            collection.AddRange(_objects.GetRange(0, count));

            var array = new TestObject[count];

            collection.CopyTo(array, 1);
        }
예제 #7
0
        public void IndexedCollection_CopyToSuccess()
        {
            int count      = 10;
            var collection = new IndexedCollection <int, TestObject>(t => t.Sequence);

            collection.AddRange(_objects.GetRange(0, count));

            var array = new TestObject[count];

            collection.CopyTo(array, 0);

            for (int i = 0; i < array.Length; ++i)
            {
                var item = array[i];
                Assert.IsNotNull(item);
                Assert.AreEqual(i, item.Sequence);
                Assert.AreEqual($"Test{i}", item.Name);
            }
        }
예제 #8
0
        public void IndexedCollection_EnumeratorGeneric()
        {
            int count      = 10;
            var collection = new IndexedCollection <int, TestObject>(t => t.Sequence);

            collection.AddRange(_objects.GetRange(0, count));

            IEnumerator <TestObject> enumerator = collection.GetEnumerator();

            Assert.IsNotNull(enumerator);

            int iterations = 0;

            while (enumerator.MoveNext())
            {
                var obj = enumerator.Current;
                ++iterations;
            }
            Assert.AreEqual(count, iterations);
        }
예제 #9
0
 private void AddQueryToCache(IEnumerable <Query> queries)
 {
     lock (_cachedQueries)
         _cachedQueries.AddRange(queries);
 }
예제 #10
0
 internal void Initialize(IEnumerable <ResourceQuerier> queriers)
 {
     _cachedQueries = new IndexedCollection <Query>(k => k.ResourceKey, k => k.Namespace, k => k.ArgCount, k => k.Arguments);
     _baseQueries   = new IndexedCollection <Query>(k => k.ResourceKey, k => k.Namespace, k => k.ArgCount, k => k.Arguments);
     _baseQueries.AddRange(queriers.SelectMany(q => q.ReturnQueries()));
 }
예제 #11
0
 internal void Initialize(IEnumerable<ResourceQuerier> queriers)
 {
     _cachedQueries = new IndexedCollection<Query>(k => k.ResourceKey, k => k.Namespace, k => k.ArgCount, k=>k.Arguments);
     _baseQueries = new IndexedCollection<Query>(k => k.ResourceKey, k => k.Namespace, k => k.ArgCount, k => k.Arguments);
     _baseQueries.AddRange(queriers.SelectMany(q => q.ReturnQueries()));
 }