public virtual void TestValuesPaging_without_comparator() { FillMap(); var predicate = new PagingPredicate(6, Predicates.IsILike("this", "value-%")); var valuesPage1 = map.Values(predicate); predicate.NextPage(); var valuesPage2 = map.Values(predicate); predicate.NextPage(); var valuesPage3 = map.Values(predicate); Assert.That(new[] { "value-0", "value-1", "value-2", "value-3", "value-4", "value-5" }, Is.EquivalentTo(valuesPage1.ToArray())); Assert.That(new[] { "value-6", "value-7", "value-8", "value-9" }, Is.EquivalentTo(valuesPage2.ToArray())); Assert.That(new string[] {}, Is.EquivalentTo(valuesPage3.ToArray())); }
public virtual void TestEntrySetPaging_without_comparator() { FillMap(); var predicate = new PagingPredicate(6, Predicates.IsILike("this", "value-%")); var page1 = map.EntrySet(predicate); predicate.NextPage(); var page2 = map.EntrySet(predicate); predicate.NextPage(); var page3 = map.EntrySet(predicate); Assert.That(GenerateKeyValuePair(0, 6), Is.EquivalentTo(page1)); Assert.That(GenerateKeyValuePair(6, 10), Is.EquivalentTo(page2)); Assert.That(GenerateKeyValuePair(0, 0), Is.EquivalentTo(page3)); }
public virtual void TestKeySetPaging_without_comparator() { FillMap(); var predicate = new PagingPredicate(6, Predicates.Key().ILike("key-%")); var keySetPage1 = map.KeySet(predicate); predicate.NextPage(); var keySetPage2 = map.KeySet(predicate); predicate.NextPage(); var keySetPage3 = map.KeySet(predicate); Assert.That(new[] { "key-0", "key-1", "key-2", "key-3", "key-4", "key-5" }, Is.EquivalentTo(keySetPage1.ToArray())); Assert.That(new[] { "key-6", "key-7", "key-8", "key-9" }, Is.EquivalentTo(keySetPage2.ToArray())); Assert.That(new string[] {}, Is.EquivalentTo(keySetPage3.ToArray())); }
public virtual void TestValuesPaging_without_comparator() { FillMap(); var predicate = new PagingPredicate(6, Predicates.IsLessThan("this", 10)); var valuesPage1 = map.Values(predicate); predicate.NextPage(); var valuesPage2 = map.Values(predicate); predicate.NextPage(); var valuesPage3 = map.Values(predicate); Assert.That(new[] { 0, 1, 2, 3, 4, 5 }, Is.EquivalentTo(valuesPage1.ToArray())); Assert.That(new[] { 6, 7, 8, 9 }, Is.EquivalentTo(valuesPage2.ToArray())); Assert.That(new int[] {}, Is.EquivalentTo(valuesPage3.ToArray())); }
public virtual void TestKeySetPaging_without_comparator() { FillMap(); var predicate = new PagingPredicate(6, Predicates.Key().GreaterThanOrEqual(0)); var keySetPage1 = map.KeySet(predicate); predicate.NextPage(); var keySetPage2 = map.KeySet(predicate); predicate.NextPage(); var keySetPage3 = map.KeySet(predicate); Assert.That(new[] { 0, 1, 2, 3, 4, 5 }, Is.EquivalentTo(keySetPage1.ToArray())); Assert.That(new[] { 6, 7, 8, 9 }, Is.EquivalentTo(keySetPage2.ToArray())); Assert.That(new int[] {}, Is.EquivalentTo(keySetPage3.ToArray())); }
public void PagingPredicateTest() { AssertPredicate(new PagingPredicate(3, Predicates.True()), PredicateDataSerializerHook.PagingPredicate); AssertPredicate(new PagingPredicate(3, Predicates.True(), new PredicateComparer()), PredicateDataSerializerHook.PagingPredicate); var paging = new PagingPredicate(3, Predicates.True()); paging.AnchorList.Add(new KeyValuePair <int, KeyValuePair <object, object> >(0, new KeyValuePair <object, object>("a", "b"))); paging.AnchorList.Add(new KeyValuePair <int, KeyValuePair <object, object> >(1, new KeyValuePair <object, object>("c", "d"))); AssertPredicate(paging, PredicateDataSerializerHook.PagingPredicate); Assert.That(paging.Page, Is.EqualTo(0)); paging.NextPage(); Assert.That(paging.Page, Is.EqualTo(1)); paging.PreviousPage(); Assert.That(paging.Page, Is.EqualTo(0)); paging.PreviousPage(); Assert.That(paging.Page, Is.EqualTo(0)); paging.Reset(); Assert.That(paging.IterationType, Is.Null); Assert.Throws <ArgumentOutOfRangeException>(() => _ = new PagingPredicate(-1)); Assert.Throws <ArgumentOutOfRangeException>(() => _ = new PagingPredicate(0)); Assert.Throws <ArgumentException>(() => _ = new PagingPredicate(1, new PagingPredicate(1))); // cannot test reading data as the paging predicate is not really meant to read data // so we cannot test that writing then reading works, need integration tests for this Assert.Throws <NotSupportedException>(() => paging.ReadData(new ObjectDataInput(new byte[0], null, Endianness.BigEndian))); }
public virtual void TestValuePaging_with_comparator() { FillMap2(); var predicate = new PagingPredicate(6, null, new CustomComparator(2, IterationType.Value)); var page1 = map.Values(predicate); predicate.NextPage(); var page2 = map.Values(predicate); predicate.NextPage(); var page3 = map.Values(predicate); Assert.That(new[] { "A", "BB", "CCC", "DDDD", "EEEEE", "FFFFFF" }, Is.EquivalentTo(page1.ToArray())); Assert.That(new[] { "GGGGGGG", "HHHHHHHH", "IIIIIIIII", "JJJJJJJJJJ" }, Is.EquivalentTo(page2.ToArray())); Assert.That(new string[] {}, Is.EquivalentTo(page3.ToArray())); }
public virtual void TestKeySetPaging_with_comparator() { FillMap(); var predicate = new PagingPredicate(6, Predicates.Key().LessThanOrEqual(10), new CustomComparator(1)); var keySetPage1 = map.KeySet(predicate); predicate.NextPage(); var keySetPage2 = map.KeySet(predicate); predicate.NextPage(); var keySetPage3 = map.KeySet(predicate); Assert.That(new[] { 9, 8, 7, 6, 5, 4 }, Is.EquivalentTo(keySetPage1.ToArray())); Assert.That(new[] { 3, 2, 1, 0 }, Is.EquivalentTo(keySetPage2.ToArray())); Assert.That(new int[] {}, Is.EquivalentTo(keySetPage3.ToArray())); }