public void TryWrappedArrayAsSCIList1() { B[] myarray = new B[] { new B(), new B(), new C() }; System.Collections.IList list = new WrappedArray <B>(myarray); // Should be called with a three-element WrappedArray<B> Assert.AreEqual(3, list.Count); Assert.IsTrue(list.IsFixedSize); Assert.IsFalse(list.IsSynchronized); Assert.AreNotEqual(null, list.SyncRoot); Assert.AreEqual(myarray.SyncRoot, list.SyncRoot); Object b1 = new B(), b2 = new B(), c1 = new C(), c2 = new C(); list[0] = b2; Assert.AreEqual(b2, list[0]); list[1] = c2; Assert.AreEqual(c2, list[1]); Assert.IsTrue(list.Contains(b2)); Assert.IsTrue(list.Contains(c2)); Array arrA = new A[3], arrB = new B[3]; list.CopyTo(arrA, 0); list.CopyTo(arrB, 0); Assert.AreEqual(b2, arrA.GetValue(0)); Assert.AreEqual(b2, arrB.GetValue(0)); Assert.AreEqual(c2, arrA.GetValue(1)); Assert.AreEqual(c2, arrB.GetValue(1)); Assert.AreEqual(0, list.IndexOf(b2)); Assert.AreEqual(-1, list.IndexOf(b1)); Assert.AreEqual(-1, list.IndexOf(c1)); Assert.IsFalse(list.Contains(b1)); Assert.IsFalse(list.Contains(c1)); }
public void TryWrappedArrayAsSCIList2() { B[] myarray = new B[] { }; System.Collections.IList list = new WrappedArray <B>(myarray); // Should be called with an empty WrappedArray<B> Assert.AreEqual(0, list.Count); list.CopyTo(new A[0], 0); list.CopyTo(new B[0], 0); list.CopyTo(new C[0], 0); Assert.IsFalse(list.IsSynchronized); Assert.AreNotEqual(null, list.SyncRoot); Object b1 = new B(), b2 = new B(), c1 = new C(), c2 = new C(); Assert.IsFalse(list.Contains(b2)); Assert.IsFalse(list.Contains(c2)); Assert.AreEqual(-1, list.IndexOf(b1)); Assert.AreEqual(-1, list.IndexOf(c1)); }
public void TryWrappedArrayAsSCIList1() { B[] myarray = new B[] { new B(), new B(), new C() }; System.Collections.IList list = new WrappedArray<B>(myarray); // Should be called with a three-element WrappedArray<B> Assert.AreEqual(3, list.Count); Assert.IsTrue(list.IsFixedSize); Assert.IsFalse(list.IsSynchronized); Assert.AreNotEqual(null, list.SyncRoot); Assert.AreEqual(myarray.SyncRoot, list.SyncRoot); Object b1 = new B(), b2 = new B(), c1 = new C(), c2 = new C(); list[0] = b2; Assert.AreEqual(b2, list[0]); list[1] = c2; Assert.AreEqual(c2, list[1]); Assert.IsTrue(list.Contains(b2)); Assert.IsTrue(list.Contains(c2)); Array arrA = new A[3], arrB = new B[3]; list.CopyTo(arrA, 0); list.CopyTo(arrB, 0); Assert.AreEqual(b2, arrA.GetValue(0)); Assert.AreEqual(b2, arrB.GetValue(0)); Assert.AreEqual(c2, arrA.GetValue(1)); Assert.AreEqual(c2, arrB.GetValue(1)); Assert.AreEqual(0, list.IndexOf(b2)); Assert.AreEqual(-1, list.IndexOf(b1)); Assert.AreEqual(-1, list.IndexOf(c1)); Assert.IsFalse(list.Contains(b1)); Assert.IsFalse(list.Contains(c1)); }
public void TryWrappedArrayAsSCIList2() { B[] myarray = new B[] { }; System.Collections.IList list = new WrappedArray<B>(myarray); // Should be called with an empty WrappedArray<B> Assert.AreEqual(0, list.Count); list.CopyTo(new A[0], 0); list.CopyTo(new B[0], 0); list.CopyTo(new C[0], 0); Assert.IsFalse(list.IsSynchronized); Assert.AreNotEqual(null, list.SyncRoot); Object b1 = new B(), b2 = new B(), c1 = new C(), c2 = new C(); Assert.IsFalse(list.Contains(b2)); Assert.IsFalse(list.Contains(c2)); Assert.AreEqual(-1, list.IndexOf(b1)); Assert.AreEqual(-1, list.IndexOf(c1)); }
public void NoExc() { WrappedArray<int> wrapped = new WrappedArray<int>(new int[] { 4, 6, 5 }); Assert.AreEqual(6, wrapped[1]); Assert.IsTrue(IC.eq(wrapped[1, 2], 6, 5)); // Func<int, bool> is4 = delegate(int i) { return i == 4; }; Assert.AreEqual(EventTypeEnum.None, wrapped.ActiveEvents); Assert.AreEqual(false, wrapped.All(is4)); Assert.AreEqual(true, wrapped.AllowsDuplicates); wrapped.Apply(delegate(int i) { }); Assert.AreEqual("{ 5, 6, 4 }", wrapped.Backwards().ToString()); Assert.AreEqual(true, wrapped.Check()); wrapped.Choose(); Assert.AreEqual(true, wrapped.Contains(4)); Assert.AreEqual(true, wrapped.ContainsAll(new ArrayList<int>())); Assert.AreEqual(1, wrapped.ContainsCount(4)); Assert.AreEqual(Speed.Linear, wrapped.ContainsSpeed); int[] extarray = new int[5]; wrapped.CopyTo(extarray, 1); Assert.IsTrue(IC.eq(extarray, 0, 4, 6, 5, 0)); Assert.AreEqual(3, wrapped.Count); Assert.AreEqual(Speed.Constant, wrapped.CountSpeed); Assert.AreEqual(EnumerationDirection.Forwards, wrapped.Direction); Assert.AreEqual(false, wrapped.DuplicatesByCounting); Assert.AreEqual(System.Collections.Generic.EqualityComparer<int>.Default, wrapped.EqualityComparer); Assert.AreEqual(true, wrapped.Exists(is4)); Assert.IsTrue(IC.eq(wrapped.Filter(is4), 4)); int j = 5; Assert.AreEqual(true, wrapped.Find(ref j)); Assert.AreEqual(true, wrapped.Find(is4, out j)); Assert.AreEqual("[ 0:4 ]", wrapped.FindAll(is4).ToString()); Assert.AreEqual(0, wrapped.FindIndex(is4)); Assert.AreEqual(true, wrapped.FindLast(is4, out j)); Assert.AreEqual(0, wrapped.FindLastIndex(is4)); Assert.AreEqual(4, wrapped.First); wrapped.GetEnumerator(); Assert.AreEqual(CHC.sequencedhashcode(4, 6, 5), wrapped.GetSequencedHashCode()); Assert.AreEqual(CHC.unsequencedhashcode(4, 6, 5), wrapped.GetUnsequencedHashCode()); Assert.AreEqual(Speed.Constant, wrapped.IndexingSpeed); Assert.AreEqual(2, wrapped.IndexOf(5)); Assert.AreEqual(false, wrapped.IsEmpty); Assert.AreEqual(true, wrapped.IsReadOnly); Assert.AreEqual(false, wrapped.IsSorted()); Assert.AreEqual(true, wrapped.IsValid); Assert.AreEqual(5, wrapped.Last); Assert.AreEqual(2, wrapped.LastIndexOf(5)); Assert.AreEqual(EventTypeEnum.None, wrapped.ListenableEvents); Func<int, string> i2s = delegate(int i) { return string.Format("T{0}", i); }; Assert.AreEqual("[ 0:T4, 1:T6, 2:T5 ]", wrapped.Map<string>(i2s).ToString()); Assert.AreEqual(0, wrapped.Offset); wrapped.Reverse(); Assert.AreEqual("[ 0:5, 1:6, 2:4 ]", wrapped.ToString()); IList<int> other = new ArrayList<int>(); other.AddAll(new int[] { 4, 5, 6 }); Assert.IsFalse(wrapped.SequencedEquals(other)); j = 30; Assert.AreEqual(true, wrapped.Show(new System.Text.StringBuilder(), ref j, null)); wrapped.Sort(); Assert.AreEqual("[ 0:4, 1:5, 2:6 ]", wrapped.ToString()); Assert.IsTrue(IC.eq(wrapped.ToArray(), 4, 5, 6)); Assert.AreEqual("[ ... ]", wrapped.ToString("L4", null)); Assert.AreEqual(null, wrapped.Underlying); Assert.IsTrue(IC.seteq(wrapped.UniqueItems(), 4, 5, 6)); Assert.IsTrue(wrapped.UnsequencedEquals(other)); wrapped.Shuffle(); Assert.IsTrue(IC.seteq(wrapped.UniqueItems(), 4, 5, 6)); }
public void View() { int[] inner = new int[] { 3, 4, 6, 5, 7 }; WrappedArray <int> outerwrapped = new WrappedArray <int>(inner); WrappedArray <int> wrapped = (WrappedArray <int>)outerwrapped.View(1, 3); // Assert.AreEqual(6, wrapped[1]); Assert.IsTrue(IC.Eq(wrapped[1, 2], 6, 5)); // bool is4(int i) { return(i == 4); } Assert.AreEqual(EventType.None, wrapped.ActiveEvents); Assert.AreEqual(false, wrapped.All(is4)); Assert.AreEqual(true, wrapped.AllowsDuplicates); wrapped.Apply(delegate(int i) { }); Assert.AreEqual("{ 5, 6, 4 }", wrapped.Backwards().ToString()); Assert.AreEqual(true, wrapped.Check()); wrapped.Choose(); Assert.AreEqual(true, wrapped.Contains(4)); Assert.AreEqual(true, wrapped.ContainsAll(new ArrayList <int>())); Assert.AreEqual(1, wrapped.ContainsCount(4)); Assert.AreEqual(Speed.Linear, wrapped.ContainsSpeed); int[] extarray = new int[5]; wrapped.CopyTo(extarray, 1); Assert.IsTrue(IC.Eq(extarray, 0, 4, 6, 5, 0)); Assert.AreEqual(3, wrapped.Count); Assert.AreEqual(Speed.Constant, wrapped.CountSpeed); Assert.AreEqual(EnumerationDirection.Forwards, wrapped.Direction); Assert.AreEqual(false, wrapped.DuplicatesByCounting); Assert.AreEqual(System.Collections.Generic.EqualityComparer <int> .Default, wrapped.EqualityComparer); Assert.AreEqual(true, wrapped.Exists(is4)); Assert.IsTrue(IC.Eq(wrapped.Filter(is4), 4)); int j = 5; Assert.AreEqual(true, wrapped.Find(ref j)); Assert.AreEqual(true, wrapped.Find(is4, out j)); Assert.AreEqual("[ 0:4 ]", wrapped.FindAll(is4).ToString()); Assert.AreEqual(0, wrapped.FindIndex(is4)); Assert.AreEqual(true, wrapped.FindLast(is4, out j)); Assert.AreEqual(0, wrapped.FindLastIndex(is4)); Assert.AreEqual(4, wrapped.First); wrapped.GetEnumerator(); Assert.AreEqual(CHC.SequencedHashCode(4, 6, 5), wrapped.GetSequencedHashCode()); Assert.AreEqual(CHC.UnsequencedHashCode(4, 6, 5), wrapped.GetUnsequencedHashCode()); Assert.AreEqual(Speed.Constant, wrapped.IndexingSpeed); Assert.AreEqual(2, wrapped.IndexOf(5)); Assert.AreEqual(false, wrapped.IsEmpty); Assert.AreEqual(true, wrapped.IsReadOnly); Assert.AreEqual(false, wrapped.IsSorted()); Assert.AreEqual(true, wrapped.IsValid); Assert.AreEqual(5, wrapped.Last); Assert.AreEqual(2, wrapped.LastIndexOf(5)); Assert.AreEqual(EventType.None, wrapped.ListenableEvents); string i2s(int i) { return(string.Format("T{0}", i)); } Assert.AreEqual("[ 0:T4, 1:T6, 2:T5 ]", wrapped.Map <string>(i2s).ToString()); Assert.AreEqual(1, wrapped.Offset); wrapped.Reverse(); Assert.AreEqual("[ 0:5, 1:6, 2:4 ]", wrapped.ToString()); IList <int> other = new ArrayList <int>(); other.AddAll(new int[] { 4, 5, 6 }); Assert.IsFalse(wrapped.SequencedEquals(other)); j = 30; Assert.AreEqual(true, wrapped.Show(new System.Text.StringBuilder(), ref j, null)); wrapped.Sort(); Assert.AreEqual("[ 0:4, 1:5, 2:6 ]", wrapped.ToString()); Assert.IsTrue(IC.Eq(wrapped.ToArray(), 4, 5, 6)); Assert.AreEqual("[ ... ]", wrapped.ToString("L4", null)); // TODO: Below line removed as NUnit 3.0 test fails trying to enumerate... // Assert.AreEqual(outerwrapped, wrapped.Underlying); Assert.IsTrue(IC.SetEq(wrapped.UniqueItems(), 4, 5, 6)); Assert.IsTrue(wrapped.UnsequencedEquals(other)); // Assert.IsTrue(wrapped.TrySlide(1)); Assert.IsTrue(IC.Eq(wrapped, 5, 6, 7)); Assert.IsTrue(wrapped.TrySlide(-1, 2)); Assert.IsTrue(IC.Eq(wrapped, 4, 5)); Assert.IsFalse(wrapped.TrySlide(-2)); Assert.IsTrue(IC.Eq(wrapped.Span(outerwrapped.ViewOf(7)), 4, 5, 6, 7)); // wrapped.Shuffle(); Assert.IsTrue(IC.SetEq(wrapped.UniqueItems(), 4, 5)); Assert.IsTrue(wrapped.IsValid); wrapped.Dispose(); Assert.IsFalse(wrapped.IsValid); }
public void NoExc() { WrappedArray <int> wrapped = new WrappedArray <int>(new int[] { 4, 6, 5 }); Assert.AreEqual(6, wrapped[1]); Assert.IsTrue(IC.eq(wrapped[1, 2], 6, 5)); // Fun <int, bool> is4 = delegate(int i) { return(i == 4); }; Assert.AreEqual(EventTypeEnum.None, wrapped.ActiveEvents); Assert.AreEqual(false, wrapped.All(is4)); Assert.AreEqual(true, wrapped.AllowsDuplicates); wrapped.Apply(delegate(int i) { }); Assert.AreEqual("{ 5, 6, 4 }", wrapped.Backwards().ToString()); Assert.AreEqual(true, wrapped.Check()); wrapped.Choose(); Assert.AreEqual(true, wrapped.Contains(4)); Assert.AreEqual(true, wrapped.ContainsAll(new ArrayList <int>())); Assert.AreEqual(1, wrapped.ContainsCount(4)); Assert.AreEqual(Speed.Linear, wrapped.ContainsSpeed); int[] extarray = new int[5]; wrapped.CopyTo(extarray, 1); Assert.IsTrue(IC.eq(extarray, 0, 4, 6, 5, 0)); Assert.AreEqual(3, wrapped.Count); Assert.AreEqual(Speed.Constant, wrapped.CountSpeed); Assert.AreEqual(EnumerationDirection.Forwards, wrapped.Direction); Assert.AreEqual(false, wrapped.DuplicatesByCounting); Assert.AreEqual(IntEqualityComparer.Default, wrapped.EqualityComparer); Assert.AreEqual(true, wrapped.Exists(is4)); Assert.IsTrue(IC.eq(wrapped.Filter(is4), 4)); int j = 5; Assert.AreEqual(true, wrapped.Find(ref j)); Assert.AreEqual(true, wrapped.Find(is4, out j)); Assert.AreEqual("[ 0:4 ]", wrapped.FindAll(is4).ToString()); Assert.AreEqual(0, wrapped.FindIndex(is4)); Assert.AreEqual(true, wrapped.FindLast(is4, out j)); Assert.AreEqual(0, wrapped.FindLastIndex(is4)); Assert.AreEqual(4, wrapped.First); wrapped.GetEnumerator(); Assert.AreEqual(CHC.sequencedhashcode(4, 6, 5), wrapped.GetSequencedHashCode()); Assert.AreEqual(CHC.unsequencedhashcode(4, 6, 5), wrapped.GetUnsequencedHashCode()); Assert.AreEqual(Speed.Constant, wrapped.IndexingSpeed); Assert.AreEqual(2, wrapped.IndexOf(5)); Assert.AreEqual(false, wrapped.IsEmpty); Assert.AreEqual(true, wrapped.IsReadOnly); Assert.AreEqual(false, wrapped.IsSorted()); Assert.AreEqual(true, wrapped.IsValid); Assert.AreEqual(5, wrapped.Last); Assert.AreEqual(2, wrapped.LastIndexOf(5)); Assert.AreEqual(EventTypeEnum.None, wrapped.ListenableEvents); Fun <int, string> i2s = delegate(int i) { return(string.Format("T{0}", i)); }; Assert.AreEqual("[ 0:T4, 1:T6, 2:T5 ]", wrapped.Map <string>(i2s).ToString()); Assert.AreEqual(0, wrapped.Offset); wrapped.Reverse(); Assert.AreEqual("[ 0:5, 1:6, 2:4 ]", wrapped.ToString()); IList <int> other = new ArrayList <int>(); other.AddAll <int>(new int[] { 4, 5, 6 }); Assert.IsFalse(wrapped.SequencedEquals(other)); j = 30; Assert.AreEqual(true, wrapped.Show(new System.Text.StringBuilder(), ref j, null)); wrapped.Sort(); Assert.AreEqual("[ 0:4, 1:5, 2:6 ]", wrapped.ToString()); Assert.IsTrue(IC.eq(wrapped.ToArray(), 4, 5, 6)); Assert.AreEqual("[ ... ]", wrapped.ToString("L4", null)); Assert.AreEqual(null, wrapped.Underlying); Assert.IsTrue(IC.seteq(wrapped.UniqueItems(), 4, 5, 6)); Assert.IsTrue(wrapped.UnsequencedEquals(other)); wrapped.Shuffle(); Assert.IsTrue(IC.seteq(wrapped.UniqueItems(), 4, 5, 6)); }
public void View() { int[] inner = new int[] { 3, 4, 6, 5, 7 }; WrappedArray <int> outerwrapped = new WrappedArray <int>(inner, MemoryType); WrappedArray <int> wrapped = (WrappedArray <int>)outerwrapped.View(1, 3); // Assert.AreEqual(6, wrapped[1]); Assert.IsTrue(IC.eq(wrapped[1, 2], 6, 5)); // Func <int, bool> is4 = delegate(int i) { return(i == 4); }; Assert.AreEqual(EventTypeEnum.None, wrapped.ActiveEvents); Assert.AreEqual(false, wrapped.All(is4)); Assert.AreEqual(true, wrapped.AllowsDuplicates); wrapped.Apply(delegate(int i) { }); Assert.AreEqual("{ 5, 6, 4 }", wrapped.Backwards().ToString()); Assert.AreEqual(true, wrapped.Check()); wrapped.Choose(); Assert.AreEqual(true, wrapped.Contains(4)); Assert.AreEqual(true, wrapped.ContainsAll(new ArrayList <int>())); Assert.AreEqual(1, wrapped.ContainsCount(4)); Assert.AreEqual(Speed.Linear, wrapped.ContainsSpeed); int[] extarray = new int[5]; wrapped.CopyTo(extarray, 1); Assert.IsTrue(IC.eq(extarray, 0, 4, 6, 5, 0)); Assert.AreEqual(3, wrapped.Count); Assert.AreEqual(Speed.Constant, wrapped.CountSpeed); Assert.AreEqual(EnumerationDirection.Forwards, wrapped.Direction); Assert.AreEqual(false, wrapped.DuplicatesByCounting); Assert.AreEqual(System.Collections.Generic.EqualityComparer <int> .Default, wrapped.EqualityComparer); Assert.AreEqual(true, wrapped.Exists(is4)); // The following condition can be tested only if we are not in memory strict mode. // the reason behind that is that the method Filter is not memory safe and thus // will cannot be used in MemoryType.Strict (it will raise an exception) if (MemoryType != MemoryType.Strict) { Assert.IsTrue(IC.eq(wrapped.Filter(is4), 4)); } int j = 5; Assert.AreEqual(true, wrapped.Find(ref j)); Assert.AreEqual(true, wrapped.Find(is4, out j)); Assert.AreEqual("[ 0:4 ]", wrapped.FindAll(is4).ToString()); Assert.AreEqual(0, wrapped.FindIndex(is4)); Assert.AreEqual(true, wrapped.FindLast(is4, out j)); Assert.AreEqual(0, wrapped.FindLastIndex(is4)); Assert.AreEqual(4, wrapped.First); // the using below is needed when testing MemoryType.Strict. In this memory mode // only one enumerator per collection is available. Requesting more than one enumerator // in this specific memory mode will raise an exception using (wrapped.GetEnumerator()) { } Assert.AreEqual(CHC.sequencedhashcode(4, 6, 5), wrapped.GetSequencedHashCode()); Assert.AreEqual(CHC.unsequencedhashcode(4, 6, 5), wrapped.GetUnsequencedHashCode()); Assert.AreEqual(Speed.Constant, wrapped.IndexingSpeed); Assert.AreEqual(2, wrapped.IndexOf(5)); Assert.AreEqual(false, wrapped.IsEmpty); Assert.AreEqual(true, wrapped.IsReadOnly); Assert.AreEqual(false, wrapped.IsSorted()); Assert.AreEqual(true, wrapped.IsValid); Assert.AreEqual(5, wrapped.Last); Assert.AreEqual(2, wrapped.LastIndexOf(5)); Assert.AreEqual(EventTypeEnum.None, wrapped.ListenableEvents); Func <int, string> i2s = delegate(int i) { return(string.Format("T{0}", i)); }; Assert.AreEqual("[ 0:T4, 1:T6, 2:T5 ]", wrapped.Map <string>(i2s).ToString()); Assert.AreEqual(1, wrapped.Offset); wrapped.Reverse(); Assert.AreEqual("[ 0:5, 1:6, 2:4 ]", wrapped.ToString()); IList <int> other = new ArrayList <int>(); other.AddAll(new int[] { 4, 5, 6 }); Assert.IsFalse(wrapped.SequencedEquals(other)); j = 30; Assert.AreEqual(true, wrapped.Show(new System.Text.StringBuilder(), ref j, null)); wrapped.Sort(); Assert.AreEqual("[ 0:4, 1:5, 2:6 ]", wrapped.ToString()); Assert.IsTrue(IC.eq(wrapped.ToArray(), 4, 5, 6)); Assert.AreEqual("[ ... ]", wrapped.ToString("L4", null)); // TODO: Below line removed as NUnit 3.0 test fails trying to enumerate... // Assert.AreEqual(outerwrapped, wrapped.Underlying); Assert.IsTrue(IC.seteq(wrapped.UniqueItems(), 4, 5, 6)); Assert.IsTrue(wrapped.UnsequencedEquals(other)); // Assert.IsTrue(wrapped.TrySlide(1)); Assert.IsTrue(IC.eq(wrapped, 5, 6, 7)); Assert.IsTrue(wrapped.TrySlide(-1, 2)); Assert.IsTrue(IC.eq(wrapped, 4, 5)); Assert.IsFalse(wrapped.TrySlide(-2)); Assert.IsTrue(IC.eq(wrapped.Span(outerwrapped.ViewOf(7)), 4, 5, 6, 7)); // wrapped.Shuffle(); Assert.IsTrue(IC.seteq(wrapped.UniqueItems(), 4, 5)); Assert.IsTrue(wrapped.IsValid); wrapped.Dispose(); Assert.IsFalse(wrapped.IsValid); }
public void NoExc() { WrappedArray<int> wrapped = new WrappedArray<int>(new int[] { 4, 6, 5 }, MemoryType); Assert.AreEqual(6, wrapped[1]); Assert.IsTrue(IC.eq(wrapped[1, 2], 6, 5)); // Func<int, bool> is4 = delegate(int i) { return i == 4; }; Assert.AreEqual(EventTypeEnum.None, wrapped.ActiveEvents); Assert.AreEqual(false, wrapped.All(is4)); Assert.AreEqual(true, wrapped.AllowsDuplicates); wrapped.Apply(delegate(int i) { }); Assert.AreEqual("{ 5, 6, 4 }", wrapped.Backwards().ToString()); Assert.AreEqual(true, wrapped.Check()); wrapped.Choose(); Assert.AreEqual(true, wrapped.Contains(4)); Assert.AreEqual(true, wrapped.ContainsAll(new ArrayList<int>())); Assert.AreEqual(1, wrapped.ContainsCount(4)); Assert.AreEqual(Speed.Linear, wrapped.ContainsSpeed); int[] extarray = new int[5]; wrapped.CopyTo(extarray, 1); Assert.IsTrue(IC.eq(extarray, 0, 4, 6, 5, 0)); Assert.AreEqual(3, wrapped.Count); Assert.AreEqual(Speed.Constant, wrapped.CountSpeed); Assert.AreEqual(EnumerationDirection.Forwards, wrapped.Direction); Assert.AreEqual(false, wrapped.DuplicatesByCounting); Assert.AreEqual(System.Collections.Generic.EqualityComparer<int>.Default, wrapped.EqualityComparer); Assert.AreEqual(true, wrapped.Exists(is4)); // The following condition can be tested only if we are not in memory strict mode. // the reason behind that is that the method Filter is not memory safe and thus // will cannot be used in MemoryType.Strict (it will raise an exception) if (MemoryType != MemoryType.Strict) Assert.IsTrue(IC.eq(wrapped.Filter(is4), 4)); int j = 5; Assert.AreEqual(true, wrapped.Find(ref j)); Assert.AreEqual(true, wrapped.Find(is4, out j)); Assert.AreEqual("[ 0:4 ]", wrapped.FindAll(is4).ToString()); Assert.AreEqual(0, wrapped.FindIndex(is4)); Assert.AreEqual(true, wrapped.FindLast(is4, out j)); Assert.AreEqual(0, wrapped.FindLastIndex(is4)); Assert.AreEqual(4, wrapped.First); // the using below is needed when testing MemoryType.Strict. In this memory mode // only one enumerator per collection is available. Requesting more than one enumerator // in this specific memory mode will raise an exception using (wrapped.GetEnumerator()) { } Assert.AreEqual(CHC.sequencedhashcode(4, 6, 5), wrapped.GetSequencedHashCode()); Assert.AreEqual(CHC.unsequencedhashcode(4, 6, 5), wrapped.GetUnsequencedHashCode()); Assert.AreEqual(Speed.Constant, wrapped.IndexingSpeed); Assert.AreEqual(2, wrapped.IndexOf(5)); Assert.AreEqual(false, wrapped.IsEmpty); Assert.AreEqual(true, wrapped.IsReadOnly); Assert.AreEqual(false, wrapped.IsSorted()); Assert.AreEqual(true, wrapped.IsValid); Assert.AreEqual(5, wrapped.Last); Assert.AreEqual(2, wrapped.LastIndexOf(5)); Assert.AreEqual(EventTypeEnum.None, wrapped.ListenableEvents); Func<int, string> i2s = delegate (int i) { return string.Format("T{0}", i); }; Assert.AreEqual("[ 0:T4, 1:T6, 2:T5 ]", wrapped.Map<string>(i2s).ToString()); Assert.AreEqual(0, wrapped.Offset); wrapped.Reverse(); Assert.AreEqual("[ 0:5, 1:6, 2:4 ]", wrapped.ToString()); IList<int> other = new ArrayList<int>(); other.AddAll(new int[] { 4, 5, 6 }); Assert.IsFalse(wrapped.SequencedEquals(other)); j = 30; Assert.AreEqual(true, wrapped.Show(new System.Text.StringBuilder(), ref j, null)); wrapped.Sort(); Assert.AreEqual("[ 0:4, 1:5, 2:6 ]", wrapped.ToString()); Assert.IsTrue(IC.eq(wrapped.ToArray(), 4, 5, 6)); Assert.AreEqual("[ ... ]", wrapped.ToString("L4", null)); Assert.AreEqual(null, wrapped.Underlying); Assert.IsTrue(IC.seteq(wrapped.UniqueItems(), 4, 5, 6)); Assert.IsTrue(wrapped.UnsequencedEquals(other)); wrapped.Shuffle(); Assert.IsTrue(IC.seteq(wrapped.UniqueItems(), 4, 5, 6)); }