public void Constructor() { var source = new CloneableType[4, 2] { { "a", "b" }, { "c", "d" }, { "e", "f" }, { "g", "h" } }; StringArray array = new StringArray(source, true); Assert.AreEqual(8, array.Length); Assert.AreEqual(2, array.Rank); Assert.AreEqual(4, array.GetLength(0)); Assert.AreEqual(2, array.GetLength(1)); // check equality by multidimensional index for (int i = 0; i < array.Length; i++) { int[] indices = array.GetIndices(i); var value = source.GetValue(indices); Assert.AreEqual(value, array[i]); Assert.AreSame(value, array[i]); } // check equality by enumeration sequence int index = 0; foreach (CloneableType value in source) { Assert.AreEqual(value, array[index]); Assert.AreSame(value, array[index]); index++; } }
public void EqualsArray() { CloneableType[,] array = new CloneableType[2, 3] { { "one", "two", "three" }, { "four", "five", "six" } }; CompareToArray(array, false); }
public bool Equals(CloneableType cloneable) { if (cloneable == null) { return(false); } return(Text == cloneable.Text); }
public void GetEnumerator() { CloneableType[] array = new CloneableType[3]; _queue.CopyTo(array, 0); int i = 0; foreach (CloneableType item in _queue) { Assert.AreEqual(array[i++], item); } }
public void CopyToZero() { CloneableType[] array = new CloneableType[4]; _queue.CopyTo(array, 0); int count = _queue.Count; for (int i = 0; i < count; i++) { Assert.AreEqual(_queue.Dequeue(), array[i]); } }
public void CopyToOne() { CloneableType[] array = new CloneableType[4]; Assert.Throws <ArgumentException>(() => _queue.CopyTo(array, 3)); _queue.CopyTo(array, 1); int count = _queue.Count; for (int i = 0; i < count; i++) { Assert.AreEqual(_queue.Dequeue(), array[i + 1]); } }
public void Constructor() { StringQueue queue = new StringQueue(567); queue.Enqueue("foo"); queue.Enqueue("bar"); Assert.AreEqual(2, queue.Count); CloneableType[] array = new CloneableType[4] { "a", "b", "c", "d" }; queue = new StringQueue(array); Assert.AreEqual(4, queue.Count); Assert.IsTrue(queue.Equals(array)); }
public void AddRange() { var array = new CloneableType[3] { "a", "b", "c" }; Assert.Throws <NotSupportedException>(() => _readOnly.AddRange(_list)); Assert.Throws <NotSupportedException>(() => _unique.AddRange(_list)); _list.AddRange(array); Assert.AreEqual(new CloneableType("a"), _list[3]); Assert.AreEqual(new CloneableType("b"), _list[4]); Assert.AreEqual(new CloneableType("c"), _list[5]); }
public void Copy() { StringQueue copy = _queue.Copy(); Assert.AreEqual(_queue.Count, copy.Count); int count = _queue.Count; for (int i = 0; i < count; i++) { CloneableType x = _queue.Dequeue(), y = copy.Dequeue(); Assert.AreEqual(x, y); Assert.AreNotSame(x, y); } }
public void Clone() { StringQueue clone = (StringQueue)_queue.Clone(); Assert.AreEqual(_queue.Count, clone.Count); int count = _queue.Count; for (int i = 0; i < count; i++) { CloneableType x = _queue.Dequeue(), y = clone.Dequeue(); Assert.AreEqual(x, y); Assert.AreSame(x, y); } }
public void CopyFrom() { var source = new CloneableType[] { "a", "b", "c", "d" }; Assert.Throws <NotSupportedException>(() => _readOnly.CopyFrom(source, 1)); Assert.Throws <ArgumentException>(() => _array.CopyFrom(source, 3)); _array.CopyFrom(source, 1); Assert.AreEqual(new CloneableType("one"), _array[0]); Assert.AreEqual(new CloneableType("a"), _array[1]); Assert.AreEqual(new CloneableType("b"), _array[2]); Assert.AreEqual(new CloneableType("c"), _array[3]); Assert.AreEqual(new CloneableType("d"), _array[4]); Assert.AreEqual(new CloneableType("six"), _array[5]); }
public void Copy() { StringStack copy = _stack.Copy(); Assert.AreEqual(_stack.Count, copy.Count); int count = _stack.Count; for (int i = 0; i < count; i++) { CloneableType x = _stack.Pop(), y = copy.Pop(); Assert.AreEqual(x, y); Assert.AreNotSame(x, y); } }
public void Clone() { StringStack clone = (StringStack)_stack.Clone(); Assert.AreEqual(_stack.Count, clone.Count); int count = _stack.Count; for (int i = 0; i < count; i++) { CloneableType x = _stack.Pop(), y = clone.Pop(); Assert.AreEqual(x, y); Assert.AreSame(x, y); } }
public void Constructor() { StringStack stack = new StringStack(567); stack.Push("foo"); stack.Push("bar"); Assert.AreEqual(2, stack.Count); CloneableType[] array = new CloneableType[4] { "a", "b", "c", "d" }; stack = new StringStack(array); Assert.AreEqual(4, stack.Count); Assert.IsFalse(stack.Equals(array)); Assert.IsTrue(stack.EqualsReverse(array)); }
public void InsertRange() { var array = new CloneableType[3] { "a", "b", "c" }; Assert.Throws <ArgumentOutOfRangeException>(() => _list.InsertRange(4, array)); Assert.Throws <NotSupportedException>(() => _readOnly.InsertRange(2, array)); Assert.Throws <NotSupportedException>(() => _unique.InsertRange(1, _list)); _list.InsertRange(1, array); Assert.AreEqual(new CloneableType("a"), _list[1]); Assert.AreEqual(new CloneableType("b"), _list[2]); Assert.AreEqual(new CloneableType("c"), _list[3]); }
public void CopyTo() { CloneableType[] array = new CloneableType[4]; Assert.Throws <ArgumentException>(() => _list.CopyTo(array, 3)); _list.CopyTo(array, 0); for (int i = 0; i < _list.Count; i++) { Assert.AreEqual(_list[i], array[i]); } _list.CopyTo(array, 1); for (int i = 0; i < _list.Count; i++) { Assert.AreEqual(_list[i], array[i + 1]); } }
public void CopyTo() { CloneableType[] array = new CloneableType[7]; Assert.Throws <ArgumentException>(() => _array.CopyTo(array, 3)); _array.CopyTo(array, 0); for (int i = 0; i < _array.Length; i++) { Assert.AreEqual(_array[i], array[i]); } _array.CopyTo(array, 1); for (int i = 0; i < _array.Length; i++) { Assert.AreEqual(_array[i], array[i + 1]); } }
public void CopyToEmpty() { _queue.Clear(); CloneableType[] array = new CloneableType[0]; _queue.CopyTo(array, 0); }