public void AddRangeTest() { Collection.AddRange(new List <string> { "Name", "Email" }); Assert.AreEqual(Collection.Length, 2); }
public void IndexedCollection_AddRange_Duplicate() { var collection = new IndexedCollection <int, TestObject>(t => t.Sequence); collection.AddRange(_objects); collection.AddRange(_objects.GetRange(0, 1)); }
public void IndexedCollection_AddRange() { var collection = new IndexedCollection <int, TestObject>(t => t.Sequence); collection.AddRange(_objects); Assert.AreEqual(1000, collection.Count); }
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); }
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); }
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); }
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); } }
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); }
private void AddQueryToCache(IEnumerable <Query> queries) { lock (_cachedQueries) _cachedQueries.AddRange(queries); }
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())); }
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())); }