namespace MonoTests.System.Collections
{
[TestFixture]
- public class ArrayListTest : Assertion
+ public class ArrayListTest
{
[Test]
public void TestCtor ()
{
{
ArrayList al1 = new ArrayList ();
- AssertNotNull ("no basic ArrayList", al1);
+ Assert.IsNotNull (al1, "no basic ArrayList");
}
{
bool errorThrown = false;
} catch (ArgumentNullException) {
errorThrown = true;
}
- Assert ("null icollection error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "null icollection error not thrown");
}
{
// what can I say? I like chars. [--DB]
char [] coll = { 'a', 'b', 'c', 'd' };
ArrayList al1 = new ArrayList (coll);
- AssertNotNull ("no icollection ArrayList", al1);
+ Assert.IsNotNull (al1, "no icollection ArrayList");
for (int i = 0; i < coll.Length; i++) {
- AssertEquals (i + " not ctor'ed properly.",
- coll [i], al1 [i]);
+ Assert.AreEqual (coll [i], al1 [i], i + " not ctor'ed properly.");
}
}
{
try {
Char [,] c1 = new Char [2, 2];
ArrayList al1 = new ArrayList (c1);
- Fail ("Should fail with multi-dimensional array in constructor.");
+ Assert.Fail ("Should fail with multi-dimensional array in constructor.");
} catch (RankException) {
}
}
} catch (ArgumentOutOfRangeException) {
errorThrown = true;
}
- Assert ("negative capacity error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "negative capacity error not thrown");
}
}
#endif
for (int i = 1; i < 100; i++) {
ArrayList al1 = new ArrayList (i);
- AssertEquals ("Bad capacity of " + i,
- i, al1.Capacity);
+ Assert.AreEqual (i, al1.Capacity, "Bad capacity of " + i);
}
{
ArrayList al1 = new ArrayList (0);
// LAMESPEC:
- // AssertEquals("Bad capacity when set to 0",
- // 16, al1.Capacity);
+ // Assert.AreEqual (// 16, al1.Capacity, "Bad capacity when set to 0");
al1.Add ("?");
- AssertEquals ("Bad capacity when set to 0",
- default_capacity, al1.Capacity);
+ Assert.AreEqual (default_capacity, al1.Capacity, "Bad capacity when set to 0");
}
{
ArrayList al1 = new ArrayList ();
- AssertEquals ("Bad default capacity",
- unspecified_capacity, al1.Capacity);
+ Assert.AreEqual (unspecified_capacity, al1.Capacity, "Bad default capacity");
}
}
{
{
ArrayList al1 = new ArrayList ();
- AssertEquals ("Bad initial count",
- 0, al1.Count);
+ Assert.AreEqual (0, al1.Count, "Bad initial count");
for (int i = 1; i <= 100; i++) {
al1.Add (i);
- AssertEquals ("Bad count " + i,
- i, al1.Count);
+ Assert.AreEqual (i, al1.Count, "Bad count " + i);
}
}
for (int i = 0; i < 100; i++) {
char [] coll = new Char [i];
ArrayList al1 = new ArrayList (coll);
- AssertEquals ("Bad count for " + i,
- i, al1.Count);
+ Assert.AreEqual (i, al1.Count, "Bad count for " + i);
}
}
public void TestIsFixed ()
{
ArrayList al1 = new ArrayList ();
- Assert ("should not be fixed by default", !al1.IsFixedSize);
+ Assert.IsTrue (!al1.IsFixedSize, "should not be fixed by default");
ArrayList al2 = ArrayList.FixedSize (al1);
- Assert ("fixed-size wrapper not working", al2.IsFixedSize);
+ Assert.IsTrue (al2.IsFixedSize, "fixed-size wrapper not working");
}
[Test]
public void TestIsReadOnly ()
{
ArrayList al1 = new ArrayList ();
- Assert ("should not be ReadOnly by default", !al1.IsReadOnly);
+ Assert.IsTrue (!al1.IsReadOnly, "should not be ReadOnly by default");
ArrayList al2 = ArrayList.ReadOnly (al1);
- Assert ("read-only wrapper not working", al2.IsReadOnly);
+ Assert.IsTrue (al2.IsReadOnly, "read-only wrapper not working");
}
[Test]
public void TestIsSynchronized ()
{
ArrayList al1 = new ArrayList ();
- Assert ("should not be synchronized by default",
- !al1.IsSynchronized);
+ Assert.IsTrue (!al1.IsSynchronized, "should not be synchronized by default");
ArrayList al2 = ArrayList.Synchronized (al1);
- Assert ("synchronized wrapper not working", al2.IsSynchronized);
+ Assert.IsTrue (al2.IsSynchronized, "synchronized wrapper not working");
}
[Test]
} catch (ArgumentOutOfRangeException) {
errorThrown = true;
}
- Assert ("negative item error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "negative item error not thrown");
}
{
bool errorThrown = false;
} catch (ArgumentOutOfRangeException) {
errorThrown = true;
}
- Assert ("past-end item error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "past-end item error not thrown");
}
for (int i = 0; i <= 100; i++) {
al1.Add (i);
}
for (int i = 0; i <= 100; i++) {
- AssertEquals ("item not fetched for " + i,
- i, al1 [i]);
+ Assert.AreEqual (i, al1 [i], "item not fetched for " + i);
}
}
} catch (ArgumentNullException) {
errorThrown = true;
} catch (Exception e) {
- Fail ("Incorrect exception thrown at 1: " + e.ToString ());
+ Assert.Fail ("Incorrect exception thrown at 1: " + e.ToString ());
}
- Assert ("null adapter error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "null adapter error not thrown");
}
{
char [] list = { 'a', 'b', 'c', 'd' };
ArrayList al1 = ArrayList.Adapter (list);
- AssertNotNull ("Couldn't get an adapter", al1);
+ Assert.IsNotNull (al1, "Couldn't get an adapter");
for (int i = 0; i < list.Length; i++) {
- AssertEquals ("adapter not adapting", list [i], al1 [i]);
+ Assert.AreEqual (list [i], al1 [i], "adapter not adapting");
}
list [0] = 'z';
for (int i = 0; i < list.Length; i++) {
- AssertEquals ("adapter not adapting", list [i], al1 [i]);
+ Assert.AreEqual (list [i], al1 [i], "adapter not adapting");
}
}
// Test Binary Search
// this is what the docs say it should throw
errorThrown = true;
} catch (Exception e) {
- Fail ("Incorrect exception thrown at 1: " + e.ToString ());
+ Assert.Fail ("Incorrect exception thrown at 1: " + e.ToString ());
}
- Assert ("search-for-wrong-type error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "search-for-wrong-type error not thrown");
}
{
char [] arr = { 'a', 'b', 'b', 'c', 'c', 'c', 'd', 'd' };
ArrayList al1 = ArrayList.Adapter (arr);
- Assert ("couldn't find elem #1",
- al1.BinarySearch ('c') >= 3);
- Assert ("couldn't find elem #2",
- al1.BinarySearch ('c') < 6);
+ Assert.IsTrue (al1.BinarySearch ('c') >= 3, "couldn't find elem #1");
+ Assert.IsTrue (al1.BinarySearch ('c') < 6, "couldn't find elem #2");
}
{
char [] arr = { 'a', 'b', 'b', 'd', 'd', 'd', 'e', 'e' };
ArrayList al1 = ArrayList.Adapter (arr);
- AssertEquals ("couldn't find next-higher elem",
- -4, al1.BinarySearch ('c'));
+ Assert.AreEqual (-4, al1.BinarySearch ('c'), "couldn't find next-higher elem");
}
{
char [] arr = { 'a', 'b', 'b', 'c', 'c', 'c', 'd', 'd' };
ArrayList al1 = ArrayList.Adapter (arr);
- AssertEquals ("couldn't find end",
- -9, al1.BinarySearch ('e'));
+ Assert.AreEqual (-9, al1.BinarySearch ('e'), "couldn't find end");
}
// Sort
{
char [] starter = { 'd', 'b', 'f', 'e', 'a', 'c' };
ArrayList al1 = ArrayList.Adapter (starter);
al1.Sort ();
- AssertEquals ("Should be sorted", 'a', al1 [0]);
- AssertEquals ("Should be sorted", 'b', al1 [1]);
- AssertEquals ("Should be sorted", 'c', al1 [2]);
- AssertEquals ("Should be sorted", 'd', al1 [3]);
- AssertEquals ("Should be sorted", 'e', al1 [4]);
- AssertEquals ("Should be sorted", 'f', al1 [5]);
+ Assert.AreEqual ('a', al1 [0], "Should be sorted");
+ Assert.AreEqual ('b', al1 [1], "Should be sorted");
+ Assert.AreEqual ('c', al1 [2], "Should be sorted");
+ Assert.AreEqual ('d', al1 [3], "Should be sorted");
+ Assert.AreEqual ('e', al1 [4], "Should be sorted");
+ Assert.AreEqual ('f', al1 [5], "Should be sorted");
}
// TODO - test other adapter types?
} catch (NotSupportedException) {
errorThrown = true;
} catch (Exception e) {
- Fail ("Incorrect exception thrown at 1: " + e.ToString ());
+ Assert.Fail ("Incorrect exception thrown at 1: " + e.ToString ());
}
- Assert ("add to fixed size error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "add to fixed size error not thrown");
}
{
bool errorThrown = false;
} catch (NotSupportedException) {
errorThrown = true;
} catch (Exception e) {
- Fail ("Incorrect exception thrown at 2: " + e.ToString ());
+ Assert.Fail ("Incorrect exception thrown at 2: " + e.ToString ());
}
- Assert ("add to read only error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "add to read only error not thrown");
}
{
ArrayList al1 = new ArrayList ();
for (int i = 1; i <= 100; i++) {
al1.Add (i);
- AssertEquals ("add failed " + i,
- i, al1.Count);
- AssertEquals ("add failed " + i,
- i, al1 [i - 1]);
+ Assert.AreEqual (i, al1.Count, "add failed " + i);
+ Assert.AreEqual (i, al1 [i - 1], "add failed " + i);
}
}
ArrayList al1 = new ArrayList (strArray);
al1.Add ("Hi!");
al1.Add ("Hi!");
- AssertEquals ("add failed", 2, al1.Count);
+ Assert.AreEqual (2, al1.Count, "add failed");
}
}
} catch (NotSupportedException) {
errorThrown = true;
} catch (Exception e) {
- Fail ("Incorrect exception thrown at 1: " + e.ToString ());
+ Assert.Fail ("Incorrect exception thrown at 1: " + e.ToString ());
}
- Assert ("add to fixed size error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "add to fixed size error not thrown");
}
{
bool errorThrown = false;
} catch (NotSupportedException) {
errorThrown = true;
} catch (Exception e) {
- Fail ("Incorrect exception thrown at 2: " + e.ToString ());
+ Assert.Fail ("Incorrect exception thrown at 2: " + e.ToString ());
}
- Assert ("add to read only error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "add to read only error not thrown");
}
{
bool errorThrown = false;
} catch (ArgumentNullException) {
errorThrown = true;
} catch (Exception e) {
- Fail ("Incorrect exception thrown at 3: " + e.ToString ());
+ Assert.Fail ("Incorrect exception thrown at 3: " + e.ToString ());
}
- Assert ("add to read only error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "add to read only error not thrown");
}
{
ArrayList a1 = new ArrayList ();
- AssertEquals ("ArrayList should start empty",
- 0, a1.Count);
+ Assert.AreEqual (0, a1.Count, "ArrayList should start empty");
char [] coll = { 'a', 'b', 'c' };
a1.AddRange (coll);
- AssertEquals ("ArrayList has wrong elements",
- 3, a1.Count);
+ Assert.AreEqual (3, a1.Count, "ArrayList has wrong elements");
a1.AddRange (coll);
- AssertEquals ("ArrayList has wrong elements",
- 6, a1.Count);
+ Assert.AreEqual (6, a1.Count, "ArrayList has wrong elements");
}
{
list.Add (1);
}
- AssertEquals ("BinarySearch off-by-one bug",
- 49, list.BinarySearch (1));
+ Assert.AreEqual (49, list.BinarySearch (1), "BinarySearch off-by-one bug");
}
}
// this is what the docs say it should throw
errorThrown = true;
} catch (Exception e) {
- Fail ("Incorrect exception thrown at 1: " + e.ToString ());
+ Assert.Fail ("Incorrect exception thrown at 1: " + e.ToString ());
}
- Assert ("search-for-wrong-type error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "search-for-wrong-type error not thrown");
}
{
char [] arr = { 'a', 'b', 'b', 'c', 'c', 'c', 'd', 'd' };
ArrayList al1 = new ArrayList (arr);
- Assert ("couldn't find elem #1",
- al1.BinarySearch ('c') >= 3);
- Assert ("couldn't find elem #2",
- al1.BinarySearch ('c') < 6);
+ Assert.IsTrue (al1.BinarySearch ('c') >= 3, "couldn't find elem #1");
+ Assert.IsTrue (al1.BinarySearch ('c') < 6, "couldn't find elem #2");
}
{
char [] arr = { 'a', 'b', 'b', 'd', 'd', 'd', 'e', 'e' };
ArrayList al1 = new ArrayList (arr);
- AssertEquals ("couldn't find next-higher elem",
- -4, al1.BinarySearch ('c'));
+ Assert.AreEqual (-4, al1.BinarySearch ('c'), "couldn't find next-higher elem");
}
{
char [] arr = { 'a', 'b', 'b', 'c', 'c', 'c', 'd', 'd' };
ArrayList al1 = new ArrayList (arr);
- AssertEquals ("couldn't find end",
- -9, al1.BinarySearch ('e'));
+ Assert.AreEqual (-9, al1.BinarySearch ('e'), "couldn't find end");
}
}
{
ArrayList al = new ArrayList ();
al.Add (this);
- AssertEquals ("null", -1, al.BinarySearch (null));
+ Assert.AreEqual (-1, al.BinarySearch (null), "null");
}
// TODO - BinarySearch with IComparer
} catch (NotSupportedException) {
errorThrown = true;
}
- Assert ("add to fixed size error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "add to fixed size error not thrown");
}
{
bool errorThrown = false;
} catch (NotSupportedException) {
errorThrown = true;
}
- Assert ("add to read only error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "add to read only error not thrown");
}
{
ArrayList al1 = new ArrayList ();
al1.Add ('c');
- AssertEquals ("should have one element",
- 1, al1.Count);
+ Assert.AreEqual (1, al1.Count, "should have one element");
al1.Clear ();
- AssertEquals ("should be empty",
- 0, al1.Count);
+ Assert.AreEqual (0, al1.Count, "should be empty");
}
{
int [] i1 = { 1, 2, 3, 4 };
ArrayList al1 = new ArrayList (i1);
- AssertEquals ("should have elements",
- i1.Length, al1.Count);
+ Assert.AreEqual (i1.Length, al1.Count, "should have elements");
int capacity = al1.Capacity;
al1.Clear ();
- AssertEquals ("should be empty again",
- 0, al1.Count);
- AssertEquals ("capacity shouldn't have changed",
- capacity, al1.Capacity);
+ Assert.AreEqual (0, al1.Count, "should be empty again");
+ Assert.AreEqual (capacity, al1.Capacity, "capacity shouldn't have changed");
}
}
char [] c1 = { 'a', 'b', 'c' };
ArrayList al1 = new ArrayList (c1);
ArrayList al2 = (ArrayList) al1.Clone ();
- AssertEquals ("ArrayList match", al1 [0], al2 [0]);
- AssertEquals ("ArrayList match", al1 [1], al2 [1]);
- AssertEquals ("ArrayList match", al1 [2], al2 [2]);
+ Assert.AreEqual (al1 [0], al2 [0], "ArrayList match");
+ Assert.AreEqual (al1 [1], al2 [1], "ArrayList match");
+ Assert.AreEqual (al1 [2], al2 [2], "ArrayList match");
}
{
char [] d10 = { 'a', 'b' };
char [] [] d1 = { d10, d11, d12 };
ArrayList al1 = new ArrayList (d1);
ArrayList al2 = (ArrayList) al1.Clone ();
- AssertEquals ("Array match", al1 [0], al2 [0]);
- AssertEquals ("Array match", al1 [1], al2 [1]);
- AssertEquals ("Array match", al1 [2], al2 [2]);
+ Assert.AreEqual (al1 [0], al2 [0], "Array match");
+ Assert.AreEqual (al1 [1], al2 [1], "Array match");
+ Assert.AreEqual (al1 [2], al2 [2], "Array match");
((char []) al1 [0]) [0] = 'z';
- AssertEquals ("shallow copy", al1 [0], al2 [0]);
+ Assert.AreEqual (al1 [0], al2 [0], "shallow copy");
}
}
{
char [] c1 = { 'a', 'b', 'c' };
ArrayList al1 = new ArrayList (c1);
- Assert ("never find a null", !al1.Contains (null));
- Assert ("can't find value", al1.Contains ('b'));
- Assert ("shouldn't find value", !al1.Contains ('?'));
+ Assert.IsTrue (!al1.Contains (null), "never find a null");
+ Assert.IsTrue (al1.Contains ('b'), "can't find value");
+ Assert.IsTrue (!al1.Contains ('?'), "shouldn't find value");
}
[Test]
} catch (ArgumentNullException) {
errorThrown = true;
} catch (Exception e) {
- Fail ("Incorrect exception thrown at 1: " + e.ToString ());
+ Assert.Fail ("Incorrect exception thrown at 1: " + e.ToString ());
}
- Assert ("error not thrown 1", errorThrown);
+ Assert.IsTrue (errorThrown, "error not thrown 1");
}
{
bool errorThrown = false;
} catch (ArgumentException) {
errorThrown = true;
} catch (Exception e) {
- Fail ("Incorrect exception thrown at 2: " + e.ToString ());
+ Assert.Fail ("Incorrect exception thrown at 2: " + e.ToString ());
}
- Assert ("error not thrown 2", errorThrown);
+ Assert.IsTrue (errorThrown, "error not thrown 2");
}
{
bool errorThrown = false;
} catch (ArgumentException) {
errorThrown = true;
} catch (Exception e) {
- Fail ("Incorrect exception thrown at 3: " + e.ToString ());
+ Assert.Fail ("Incorrect exception thrown at 3: " + e.ToString ());
}
- Assert ("error not thrown 3", errorThrown);
+ Assert.IsTrue (errorThrown, "error not thrown 3");
}
{
bool errorThrown = false;
} catch (ArgumentOutOfRangeException) {
errorThrown = true;
} catch (Exception e) {
- Fail ("Incorrect exception thrown at 4: " + e.ToString ());
+ Assert.Fail ("Incorrect exception thrown at 4: " + e.ToString ());
}
- Assert ("error not thrown 4", errorThrown);
+ Assert.IsTrue (errorThrown, "error not thrown 4");
}
{
bool errorThrown = false;
} catch (ArgumentException) {
errorThrown = true;
} catch (Exception e) {
- Fail ("Incorrect exception thrown at 5: " + e.ToString ());
+ Assert.Fail ("Incorrect exception thrown at 5: " + e.ToString ());
}
- Assert ("error not thrown 5", errorThrown);
+ Assert.IsTrue (errorThrown, "error not thrown 5");
}
{
bool errorThrown = false;
} catch (ArgumentException) {
errorThrown = true;
} catch (Exception e) {
- Fail ("Incorrect exception thrown at 6: " + e.ToString ());
+ Assert.Fail ("Incorrect exception thrown at 6: " + e.ToString ());
}
- Assert ("error not thrown 6", errorThrown);
+ Assert.IsTrue (errorThrown, "error not thrown 6");
}
{
bool errorThrown = false;
} catch (InvalidCastException) {
errorThrown = true;
} catch (Exception e) {
- Fail ("Incorrect exception thrown at 7: " + e.ToString ());
+ Assert.Fail ("Incorrect exception thrown at 7: " + e.ToString ());
}
- Assert ("error not thrown 7", errorThrown);
+ Assert.IsTrue (errorThrown, "error not thrown 7");
}
Char [] orig = { 'a', 'b', 'c', 'd' };
Char [] copy = new Char [10];
Array.Clear (copy, 0, copy.Length);
al.CopyTo (copy, 3);
- AssertEquals ("Wrong CopyTo 0", (char) 0, copy [0]);
- AssertEquals ("Wrong CopyTo 1", (char) 0, copy [1]);
- AssertEquals ("Wrong CopyTo 2", (char) 0, copy [2]);
- AssertEquals ("Wrong CopyTo 3", orig [0], copy [3]);
- AssertEquals ("Wrong CopyTo 4", orig [1], copy [4]);
- AssertEquals ("Wrong CopyTo 5", orig [2], copy [5]);
- AssertEquals ("Wrong CopyTo 6", orig [3], copy [6]);
- AssertEquals ("Wrong CopyTo 7", (char) 0, copy [7]);
- AssertEquals ("Wrong CopyTo 8", (char) 0, copy [8]);
- AssertEquals ("Wrong CopyTo 9", (char) 0, copy [9]);
+ Assert.AreEqual ((char) 0, copy [0], "Wrong CopyTo 0");
+ Assert.AreEqual ((char) 0, copy [1], "Wrong CopyTo 1");
+ Assert.AreEqual ((char) 0, copy [2], "Wrong CopyTo 2");
+ Assert.AreEqual (orig [0], copy [3], "Wrong CopyTo 3");
+ Assert.AreEqual (orig [1], copy [4], "Wrong CopyTo 4");
+ Assert.AreEqual (orig [2], copy [5], "Wrong CopyTo 5");
+ Assert.AreEqual (orig [3], copy [6], "Wrong CopyTo 6");
+ Assert.AreEqual ((char) 0, copy [7], "Wrong CopyTo 7");
+ Assert.AreEqual ((char) 0, copy [8], "Wrong CopyTo 8");
+ Assert.AreEqual ((char) 0, copy [9], "Wrong CopyTo 9");
}
[Test]
} catch (ArgumentNullException) {
errorThrown = true;
}
- Assert ("null arg error not thrown", errorThrown);
+ Assert.IsTrue (errorThrown, "null arg error not thrown");
}
{
ArrayList al1 = new ArrayList ();
- AssertEquals ("arrays start un-fixed.",
- false, al1.IsFixedSize);
+ Assert.AreEqual (false, al1.IsFixedSize, "arrays start un-fixed.");
ArrayList al2 = ArrayList.FixedSize (al1);
- AssertEquals ("should be fixed.",
- true, al2.IsFixedSize);
+ Assert.AreEqual (true, al2.IsFixedSize, "should be fixed.");
}
}
al1.Add ("something");
try {
en.MoveNext ();
- Fail ("Add() didn't invalidate the enumerator");
+ Assert.Fail ("Add() didn't invalidate the enumerator");
} catch (InvalidOperationException) {
// do nothing...this is what we expect
}
al1.AddRange (al1);
try {
en.MoveNext ();
- Fail ("AddRange() didn't invalidate the enumerator");
+ Assert.Fail ("AddRange() didn't invalidate the enumerator");
} catch (InvalidOperationException) {
// do nothing...this is what we expect
}
al1.Clear ();
try {
en.MoveNext ();
- Fail ("Clear() didn't invalidate the enumerator");
+ Assert.Fail ("Clear() didn't invalidate the enumerator");
} catch (InvalidOperationException) {
// do nothing...this is what we expect
}
al1.Insert (0, "new first");
try {
en.MoveNext ();
- Fail ("Insert() didn't invalidate the enumerator");
+ Assert.Fail ("Insert() didn't invalidate the enumerator");
} catch (InvalidOperationException) {
// do nothing...this is what we expect
}
al1.InsertRange (0, al1);
try {
en.MoveNext ();
- Fail ("InsertRange() didn't invalidate the enumerator");
+ Assert.Fail ("InsertRange() didn't invalidate the enumerator");
} catch (InvalidOperationException) {
// do nothing...this is what we expect
}
al1.Remove ("this");
try {
en.MoveNext ();
- Fail ("Remove() didn't invalidate the enumerator");
+ Assert.Fail ("Remove() didn't invalidate the enumerator");
} catch (InvalidOperationException) {
// do nothing...this is what we expect
}
al1.RemoveAt (2);
try {
en.MoveNext ();
- Fail ("RemoveAt() didn't invalidate the enumerator");
+ Assert.Fail ("RemoveAt() didn't invalidate the enumerator");
} catch (InvalidOperationException) {
// do nothing...this is what we expect
}
al1.RemoveRange (1, 1);
try {
en.MoveNext ();
- Fail ("RemoveRange() didn't invalidate the enumerator");
+ Assert.Fail ("RemoveRange() didn't invalidate the enumerator");
} catch (InvalidOperationException) {
// do nothing...this is what we expect
}
al1.Reverse ();
try {
en.MoveNext ();
- Fail ("Reverse() didn't invalidate the enumerator");
+ Assert.Fail ("Reverse() didn't invalidate the enumerator");
} catch (InvalidOperationException) {
// do nothing...this is what we expect
}
al1.Sort ();
try {
en.MoveNext ();
- Fail ("Sort() didn't invalidate the enumerator");
+ Assert.Fail ("Sort() didn't invalidate the enumerator");
} catch (InvalidOperationException) {
// do nothing...this is what we expect
}
} catch (ArgumentOutOfRangeException) {
errorThrown = true;
}
- Assert ("negative index error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "negative index error not thrown");
}
{
bool errorThrown = false;
} catch (ArgumentOutOfRangeException) {
errorThrown = true;
}
- Assert ("negative index error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "negative index error not thrown");
}
{
bool errorThrown = false;
} catch (ArgumentException) {
errorThrown = true;
}
- Assert ("out-of-range index error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "out-of-range index error not thrown");
}
{
String [] s1 = { "this", "is", "a", "test" };
ArrayList al1 = new ArrayList (s1);
IEnumerator en = al1.GetEnumerator ();
- AssertNotNull ("No enumerator", en);
+ Assert.IsNotNull (en, "No enumerator");
for (int i = 0; i < s1.Length; i++) {
en.MoveNext ();
- AssertEquals ("Not enumerating",
- al1 [i], en.Current);
+ Assert.AreEqual (al1 [i], en.Current, "Not enumerating");
}
}
{
String [] s1 = { "this", "is", "a", "test" };
ArrayList al1 = new ArrayList (s1);
IEnumerator en = al1.GetEnumerator (1, 2);
- AssertNotNull ("No enumerator", en);
+ Assert.IsNotNull (en, "No enumerator");
for (int i = 0; i < 2; i++) {
en.MoveNext ();
- AssertEquals ("Not enumerating",
- al1 [i + 1], en.Current);
+ Assert.AreEqual (al1 [i + 1], en.Current, "Not enumerating");
}
}
}
} catch (ArgumentOutOfRangeException) {
errorThrown = true;
}
- Assert ("negative index error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "negative index error not thrown");
}
{
bool errorThrown = false;
} catch (ArgumentOutOfRangeException) {
errorThrown = true;
}
- Assert ("negative index error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "negative index error not thrown");
}
{
bool errorThrown = false;
} catch (ArgumentException) {
errorThrown = true;
}
- Assert ("out-of-range index error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "out-of-range index error not thrown");
}
{
char [] chars = { 'a', 'b', 'c', 'd', 'e', 'f' };
ArrayList a = new ArrayList (chars);
ArrayList b = a.GetRange (1, 3);
- AssertEquals ("GetRange returned wrong size ArrayList", 3, b.Count);
+ Assert.AreEqual (3, b.Count, "GetRange returned wrong size ArrayList");
for (int i = 0; i < b.Count; i++) {
- AssertEquals ("range didn't work",
- chars [i + 1], b [i]);
+ Assert.AreEqual (chars [i + 1], b [i], "range didn't work");
}
a [2] = '?'; // should screw up ArrayList b.
} catch (InvalidOperationException) {
errorThrown = true;
}
- AssertEquals ("Munging 'a' should mess up 'b'",
- true, errorThrown);
+ Assert.AreEqual (true, errorThrown, "Munging 'a' should mess up 'b'");
}
{
char [] chars = { 'a', 'b', 'c', 'd', 'e', 'f' };
object [] obj_chars = b.ToArray ();
for (int i = 0; i < 3; i++) {
char c = (char) obj_chars [i];
- AssertEquals ("range.ToArray didn't work",
- chars [i + 3], c);
+ Assert.AreEqual (chars [i + 3], c, "range.ToArray didn't work");
}
char [] new_chars = (char []) b.ToArray (typeof (char));
for (int i = 0; i < 3; i++) {
- AssertEquals ("range.ToArray with type didn't work",
- chars [i + 3], new_chars [i]);
+ Assert.AreEqual (chars [i + 3], new_chars [i], "range.ToArray with type didn't work");
}
}
}
} catch (ArgumentOutOfRangeException) {
errorThrown = true;
}
- Assert ("negative indexof error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "negative indexof error not thrown");
}
{
bool errorThrown = false;
} catch (ArgumentOutOfRangeException) {
errorThrown = true;
}
- Assert ("past-end indexof error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "past-end indexof error not thrown");
}
{
bool errorThrown = false;
} catch (ArgumentOutOfRangeException) {
errorThrown = true;
}
- Assert ("negative indexof error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "negative indexof error not thrown");
}
{
bool errorThrown = false;
} catch (ArgumentOutOfRangeException) {
errorThrown = true;
}
- Assert ("past-end indexof error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "past-end indexof error not thrown");
}
{
bool errorThrown = false;
} catch (ArgumentOutOfRangeException) {
errorThrown = true;
}
- Assert ("past-end indexof error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "past-end indexof error not thrown");
}
{
char [] c = { 'a', 'b', 'c', 'd', 'e' };
ArrayList a = new ArrayList (c);
- AssertEquals ("never find null",
- -1, a.IndexOf (null));
- AssertEquals ("never find null",
- -1, a.IndexOf (null, 0));
- AssertEquals ("never find null",
- -1, a.IndexOf (null, 0, 5));
- AssertEquals ("can't find elem",
- 2, a.IndexOf ('c'));
- AssertEquals ("can't find elem",
- 2, a.IndexOf ('c', 2));
- AssertEquals ("can't find elem",
- 2, a.IndexOf ('c', 2, 2));
- AssertEquals ("shouldn't find elem",
- -1, a.IndexOf ('c', 3, 2));
- AssertEquals ("shouldn't find", -1, a.IndexOf ('?'));
- AssertEquals ("shouldn't find", -1, a.IndexOf (3));
+ Assert.AreEqual (-1, a.IndexOf (null), "never find null");
+ Assert.AreEqual (-1, a.IndexOf (null, 0), "never find null");
+ Assert.AreEqual (-1, a.IndexOf (null, 0, 5), "never find null");
+ Assert.AreEqual (2, a.IndexOf ('c'), "can't find elem");
+ Assert.AreEqual (2, a.IndexOf ('c', 2), "can't find elem");
+ Assert.AreEqual (2, a.IndexOf ('c', 2, 2), "can't find elem");
+ Assert.AreEqual (-1, a.IndexOf ('c', 3, 2), "shouldn't find elem");
+ Assert.AreEqual (-1, a.IndexOf ('?'), "shouldn't find");
+ Assert.AreEqual (-1, a.IndexOf (3), "shouldn't find");
}
}
} catch (NotSupportedException) {
errorThrown = true;
}
- Assert ("insert to fixed size error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "insert to fixed size error not thrown");
}
{
bool errorThrown = false;
} catch (NotSupportedException) {
errorThrown = true;
}
- Assert ("insert to read only error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "insert to read only error not thrown");
}
{
bool errorThrown = false;
} catch (ArgumentOutOfRangeException) {
errorThrown = true;
}
- Assert ("insert to read only error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "insert to read only error not thrown");
}
{
bool errorThrown = false;
} catch (ArgumentOutOfRangeException) {
errorThrown = true;
}
- Assert ("insert to read only error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "insert to read only error not thrown");
}
{
ArrayList al1 = new ArrayList ();
- AssertEquals ("arraylist starts empty", 0, al1.Count);
+ Assert.AreEqual (0, al1.Count, "arraylist starts empty");
al1.Insert (0, 'a');
al1.Insert (1, 'b');
al1.Insert (0, 'c');
- AssertEquals ("arraylist needs stuff", 3, al1.Count);
- AssertEquals ("arraylist got stuff", 'c', al1 [0]);
- AssertEquals ("arraylist got stuff", 'a', al1 [1]);
- AssertEquals ("arraylist got stuff", 'b', al1 [2]);
+ Assert.AreEqual (3, al1.Count, "arraylist needs stuff");
+ Assert.AreEqual ('c', al1 [0], "arraylist got stuff");
+ Assert.AreEqual ('a', al1 [1], "arraylist got stuff");
+ Assert.AreEqual ('b', al1 [2], "arraylist got stuff");
}
}
} catch (NotSupportedException) {
errorThrown = true;
}
- Assert ("insert to fixed size error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "insert to fixed size error not thrown");
}
{
bool errorThrown = false;
} catch (NotSupportedException) {
errorThrown = true;
}
- Assert ("insert to read only error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "insert to read only error not thrown");
}
{
bool errorThrown = false;
} catch (ArgumentOutOfRangeException) {
errorThrown = true;
}
- Assert ("negative index insert error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "negative index insert error not thrown");
}
{
bool errorThrown = false;
} catch (ArgumentOutOfRangeException) {
errorThrown = true;
}
- Assert ("out-of-range insert error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "out-of-range insert error not thrown");
}
{
bool errorThrown = false;
} catch (ArgumentNullException) {
errorThrown = true;
}
- Assert ("null insert error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "null insert error not thrown");
}
{
char [] c = { 'a', 'b', 'c' };
ArrayList a = new ArrayList (c);
a.InsertRange (1, c);
- AssertEquals ("bad insert 1", 'a', a [0]);
- AssertEquals ("bad insert 2", 'a', a [1]);
- AssertEquals ("bad insert 3", 'b', a [2]);
- AssertEquals ("bad insert 4", 'c', a [3]);
- AssertEquals ("bad insert 5", 'b', a [4]);
- AssertEquals ("bad insert 6", 'c', a [5]);
+ Assert.AreEqual ('a', a [0], "bad insert 1");
+ Assert.AreEqual ('a', a [1], "bad insert 2");
+ Assert.AreEqual ('b', a [2], "bad insert 3");
+ Assert.AreEqual ('c', a [3], "bad insert 4");
+ Assert.AreEqual ('b', a [4], "bad insert 5");
+ Assert.AreEqual ('c', a [5], "bad insert 6");
}
}
//} catch (ArgumentOutOfRangeException) {
//errorThrown = true;
//}
- //Assert("first negative lastindexof error not thrown",
- //errorThrown);
+ //Assert.IsTrue (//errorThrown, "first negative lastindexof error not thrown");
//}
{
bool errorThrown = false;
} catch (ArgumentOutOfRangeException) {
errorThrown = true;
}
- Assert ("past-end lastindexof error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "past-end lastindexof error not thrown");
}
//{
//bool errorThrown = false;
//} catch (ArgumentOutOfRangeException) {
//errorThrown = true;
//}
- //Assert("second negative lastindexof error not thrown",
- //errorThrown);
+ //Assert.IsTrue (//errorThrown, "second negative lastindexof error not thrown");
//}
//{
//bool errorThrown = false;
//} catch (ArgumentOutOfRangeException) {
//errorThrown = true;
//}
- //Assert("past-end lastindexof error not thrown",
- //errorThrown);
+ //Assert.IsTrue (//errorThrown, "past-end lastindexof error not thrown");
//}
//{
//bool errorThrown = false;
//} catch (ArgumentOutOfRangeException) {
//errorThrown = true;
//}
- //Assert("past-end lastindexof error not thrown",
- //errorThrown);
+ //Assert.IsTrue (//errorThrown, "past-end lastindexof error not thrown");
//}
int iTest = 0;
try {
char [] c = { 'a', 'b', 'c', 'd', 'e' };
ArrayList a = new ArrayList (c);
- AssertEquals ("never find null",
- -1, a.LastIndexOf (null));
+ Assert.AreEqual (-1, a.LastIndexOf (null), "never find null");
iTest++;
- AssertEquals ("never find null",
- -1, a.LastIndexOf (null, 4));
+ Assert.AreEqual (-1, a.LastIndexOf (null, 4), "never find null");
iTest++;
- AssertEquals ("never find null",
- -1, a.LastIndexOf (null, 4, 5));
+ Assert.AreEqual (-1, a.LastIndexOf (null, 4, 5), "never find null");
iTest++;
- AssertEquals ("can't find elem",
- 2, a.LastIndexOf ('c'));
+ Assert.AreEqual (2, a.LastIndexOf ('c'), "can't find elem");
iTest++;
- AssertEquals ("can't find elem",
- 2, a.LastIndexOf ('c', 4));
+ Assert.AreEqual (2, a.LastIndexOf ('c', 4), "can't find elem");
iTest++;
- AssertEquals ("can't find elem",
- 2, a.LastIndexOf ('c', 3, 2));
+ Assert.AreEqual (2, a.LastIndexOf ('c', 3, 2), "can't find elem");
iTest++;
- AssertEquals ("shouldn't find elem",
- -1, a.LastIndexOf ('c', 4, 2));
+ Assert.AreEqual (-1, a.LastIndexOf ('c', 4, 2), "shouldn't find elem");
iTest++;
- AssertEquals ("shouldn't find", -1, a.LastIndexOf ('?'));
+ Assert.AreEqual (-1, a.LastIndexOf ('?'), "shouldn't find");
iTest++;
- AssertEquals ("shouldn't find", -1, a.LastIndexOf (1));
+ Assert.AreEqual (-1, a.LastIndexOf (1), "shouldn't find");
} catch (Exception e) {
- Fail ("Unexpected exception caught when iTest=" + iTest + ". e=" + e);
+ Assert.Fail ("Unexpected exception caught when iTest=" + iTest + ". e=" + e);
}
}
} catch (ArgumentNullException) {
errorThrown = true;
}
- Assert ("null arg error not thrown", errorThrown);
+ Assert.IsTrue (errorThrown, "null arg error not thrown");
}
{
ArrayList al1 = new ArrayList ();
- AssertEquals ("arrays start writeable.",
- false, al1.IsReadOnly);
+ Assert.AreEqual (false, al1.IsReadOnly, "arrays start writeable.");
ArrayList al2 = ArrayList.ReadOnly (al1);
- AssertEquals ("should be readonly.",
- true, al2.IsReadOnly);
+ Assert.AreEqual (true, al2.IsReadOnly, "should be readonly.");
}
}
} catch (NotSupportedException) {
errorThrown = true;
}
- Assert ("remove fixed size error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "remove fixed size error not thrown");
}
{
bool errorThrown = false;
} catch (NotSupportedException) {
errorThrown = true;
}
- Assert ("remove read only error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "remove read only error not thrown");
}
{
char [] c = { 'a', 'b', 'c' };
ArrayList a = new ArrayList (c);
a.Remove (1);
a.Remove ('?');
- AssertEquals ("should be unchanged", c.Length, a.Count);
+ Assert.AreEqual (c.Length, a.Count, "should be unchanged");
a.Remove ('a');
- AssertEquals ("should be changed", 2, a.Count);
- AssertEquals ("should have shifted", 'b', a [0]);
- AssertEquals ("should have shifted", 'c', a [1]);
+ Assert.AreEqual (2, a.Count, "should be changed");
+ Assert.AreEqual ('b', a [0], "should have shifted");
+ Assert.AreEqual ('c', a [1], "should have shifted");
}
}
} catch (NotSupportedException) {
errorThrown = true;
}
- Assert ("remove from fixed size error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "remove from fixed size error not thrown");
}
{
bool errorThrown = false;
} catch (NotSupportedException) {
errorThrown = true;
}
- Assert ("remove from read only error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "remove from read only error not thrown");
}
{
bool errorThrown = false;
} catch (ArgumentOutOfRangeException) {
errorThrown = true;
}
- Assert ("remove at negative index error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "remove at negative index error not thrown");
}
{
bool errorThrown = false;
} catch (ArgumentOutOfRangeException) {
errorThrown = true;
}
- Assert ("remove at out-of-range index error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "remove at out-of-range index error not thrown");
}
{
char [] c = { 'a', 'b', 'c' };
ArrayList a = new ArrayList (c);
a.RemoveAt (0);
- AssertEquals ("should be changed", 2, a.Count);
- AssertEquals ("should have shifted", 'b', a [0]);
- AssertEquals ("should have shifted", 'c', a [1]);
+ Assert.AreEqual (2, a.Count, "should be changed");
+ Assert.AreEqual ('b', a [0], "should have shifted");
+ Assert.AreEqual ('c', a [1], "should have shifted");
}
}
} catch (NotSupportedException) {
errorThrown = true;
}
- Assert ("removerange from fixed size error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "removerange from fixed size error not thrown");
}
{
bool errorThrown = false;
} catch (NotSupportedException) {
errorThrown = true;
}
- Assert ("removerange from read only error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "removerange from read only error not thrown");
}
{
bool errorThrown = false;
} catch (ArgumentOutOfRangeException) {
errorThrown = true;
}
- Assert ("removerange at negative index error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "removerange at negative index error not thrown");
}
{
bool errorThrown = false;
} catch (ArgumentOutOfRangeException) {
errorThrown = true;
}
- Assert ("removerange at negative index error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "removerange at negative index error not thrown");
}
{
bool errorThrown = false;
} catch (ArgumentException) {
errorThrown = true;
}
- Assert ("removerange at bad range error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "removerange at bad range error not thrown");
}
{
char [] c = { 'a', 'b', 'c' };
ArrayList a = new ArrayList (c);
a.RemoveRange (1, 2);
- AssertEquals ("should be changed", 1, a.Count);
- AssertEquals ("should have shifted", 'a', a [0]);
+ Assert.AreEqual (1, a.Count, "should be changed");
+ Assert.AreEqual ('a', a [0], "should have shifted");
}
}
} catch (ArgumentOutOfRangeException) {
errorThrown = true;
}
- Assert ("repeat negative copies error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "repeat negative copies error not thrown");
}
{
ArrayList al1 = ArrayList.Repeat ("huh?", 0);
- AssertEquals ("should be nothing in array",
- 0, al1.Count);
+ Assert.AreEqual (0, al1.Count, "should be nothing in array");
}
{
ArrayList al1 = ArrayList.Repeat ("huh?", 3);
- AssertEquals ("should be something in array",
- 3, al1.Count);
- AssertEquals ("array elem doesn't check",
- "huh?", al1 [0]);
- AssertEquals ("array elem doesn't check",
- "huh?", al1 [1]);
- AssertEquals ("array elem doesn't check",
- "huh?", al1 [2]);
+ Assert.AreEqual (3, al1.Count, "should be something in array");
+ Assert.AreEqual ("huh?", al1 [0], "array elem doesn't check");
+ Assert.AreEqual ("huh?", al1 [1], "array elem doesn't check");
+ Assert.AreEqual ("huh?", al1 [2], "array elem doesn't check");
}
}
} catch (NotSupportedException) {
errorThrown = true;
}
- Assert ("reverse on read only error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "reverse on read only error not thrown");
}
{
bool errorThrown = false;
} catch (ArgumentException) {
errorThrown = true;
}
- Assert ("error not thrown", errorThrown);
+ Assert.IsTrue (errorThrown, "error not thrown");
}
{
bool errorThrown = false;
} catch (ArgumentException) {
errorThrown = true;
}
- Assert ("error not thrown", errorThrown);
+ Assert.IsTrue (errorThrown, "error not thrown");
}
{
char [] c = { 'a', 'b', 'c', 'd', 'e' };
ArrayList al1 = new ArrayList (c);
al1.Reverse (2, 1);
for (int i = 0; i < al1.Count; i++) {
- AssertEquals ("Should be no change yet",
- c [i], al1 [i]);
+ Assert.AreEqual (c [i], al1 [i], "Should be no change yet");
}
al1.Reverse ();
for (int i = 0; i < al1.Count; i++) {
- AssertEquals ("Should be reversed",
- c [i], al1 [4 - i]);
+ Assert.AreEqual (c [i], al1 [4 - i], "Should be reversed");
}
al1.Reverse ();
for (int i = 0; i < al1.Count; i++) {
- AssertEquals ("Should be back to normal",
- c [i], al1 [i]);
+ Assert.AreEqual (c [i], al1 [i], "Should be back to normal");
}
al1.Reverse (1, 3);
- AssertEquals ("Should be back to normal", c [0], al1 [0]);
- AssertEquals ("Should be back to normal", c [3], al1 [1]);
- AssertEquals ("Should be back to normal", c [2], al1 [2]);
- AssertEquals ("Should be back to normal", c [1], al1 [3]);
- AssertEquals ("Should be back to normal", c [4], al1 [4]);
+ Assert.AreEqual (c [0], al1 [0], "Should be back to normal");
+ Assert.AreEqual (c [3], al1 [1], "Should be back to normal");
+ Assert.AreEqual (c [2], al1 [2], "Should be back to normal");
+ Assert.AreEqual (c [1], al1 [3], "Should be back to normal");
+ Assert.AreEqual (c [4], al1 [4], "Should be back to normal");
}
}
} catch (NotSupportedException) {
errorThrown = true;
} catch (Exception e) {
- Fail ("Incorrect exception thrown at 1: " + e.ToString ());
+ Assert.Fail ("Incorrect exception thrown at 1: " + e.ToString ());
}
- Assert ("setrange on read only error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "setrange on read only error not thrown");
}
{
bool errorThrown = false;
} catch (ArgumentOutOfRangeException) {
errorThrown = true;
} catch (Exception e) {
- Fail ("Incorrect exception thrown at 2: " + e.ToString ());
+ Assert.Fail ("Incorrect exception thrown at 2: " + e.ToString ());
}
- Assert ("setrange with null error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "setrange with null error not thrown");
}
{
bool errorThrown = false;
} catch (ArgumentOutOfRangeException) {
errorThrown = true;
} catch (Exception e) {
- Fail ("Incorrect exception thrown at 3: " + e.ToString ());
+ Assert.Fail ("Incorrect exception thrown at 3: " + e.ToString ());
}
- Assert ("setrange with negative index error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "setrange with negative index error not thrown");
}
{
bool errorThrown = false;
} catch (ArgumentOutOfRangeException) {
errorThrown = true;
} catch (Exception e) {
- Fail ("Incorrect exception thrown at 4: " + e.ToString ());
+ Assert.Fail ("Incorrect exception thrown at 4: " + e.ToString ());
}
- Assert ("setrange with too much error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "setrange with too much error not thrown");
}
{
char [] c = { 'a', 'b', 'c' };
ArrayList al1 = ArrayList.Repeat ('?', 3);
- Assert ("no match yet", c [0] != (char) al1 [0]);
- Assert ("no match yet", c [1] != (char) al1 [1]);
- Assert ("no match yet", c [2] != (char) al1 [2]);
+ Assert.IsTrue (c [0] != (char) al1 [0], "no match yet");
+ Assert.IsTrue (c [1] != (char) al1 [1], "no match yet");
+ Assert.IsTrue (c [2] != (char) al1 [2], "no match yet");
al1.SetRange (0, c);
- AssertEquals ("should match", c [0], al1 [0]);
- AssertEquals ("should match", c [1], al1 [1]);
- AssertEquals ("should match", c [2], al1 [2]);
+ Assert.AreEqual (c [0], al1 [0], "should match");
+ Assert.AreEqual (c [1], al1 [1], "should match");
+ Assert.AreEqual (c [2], al1 [2], "should match");
}
}
al.InsertRange (2, al);
String [] s2 = { "this", "is", "this", "is", "a", "test", "a", "test" };
for (int i = 0; i < al.Count; i++) {
- AssertEquals ("at i=" + i, s2 [i], al [i]);
+ Assert.AreEqual (s2 [i], al [i], "at i=" + i);
}
}
} catch (NotSupportedException) {
errorThrown = true;
}
- Assert ("sort on read only error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "sort on read only error not thrown");
}
{
char [] starter = { 'd', 'b', 'f', 'e', 'a', 'c' };
ArrayList al1 = new ArrayList (starter);
al1.Sort ();
- AssertEquals ("Should be sorted", 'a', al1 [0]);
- AssertEquals ("Should be sorted", 'b', al1 [1]);
- AssertEquals ("Should be sorted", 'c', al1 [2]);
- AssertEquals ("Should be sorted", 'd', al1 [3]);
- AssertEquals ("Should be sorted", 'e', al1 [4]);
- AssertEquals ("Should be sorted", 'f', al1 [5]);
+ Assert.AreEqual ('a', al1 [0], "Should be sorted");
+ Assert.AreEqual ('b', al1 [1], "Should be sorted");
+ Assert.AreEqual ('c', al1 [2], "Should be sorted");
+ Assert.AreEqual ('d', al1 [3], "Should be sorted");
+ Assert.AreEqual ('e', al1 [4], "Should be sorted");
+ Assert.AreEqual ('f', al1 [5], "Should be sorted");
}
{
ArrayList al1 = new ArrayList ();
al1.Add (null);
al1.Sort ();
- AssertEquals ("Should be null", null, al1 [0]);
- AssertEquals ("Should be 2. null", null, al1 [1]);
- AssertEquals ("Should be 3. null", null, al1 [2]);
- AssertEquals ("Should be 4. null", null, al1 [3]);
- AssertEquals ("Should be 32", 32, al1 [4]);
- AssertEquals ("Should be 33", 33, al1 [5]);
+ Assert.AreEqual (null, al1 [0], "Should be null");
+ Assert.AreEqual (null, al1 [1], "Should be 2. null");
+ Assert.AreEqual (null, al1 [2], "Should be 3. null");
+ Assert.AreEqual (null, al1 [3], "Should be 4. null");
+ Assert.AreEqual (32, al1 [4], "Should be 32");
+ Assert.AreEqual (33, al1 [5], "Should be 33");
}
}
} catch (ArgumentNullException) {
errorThrown = true;
}
- Assert ("toarray with null error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "toarray with null error not thrown");
}
{
bool errorThrown = false;
} catch (InvalidCastException) {
errorThrown = true;
}
- Assert ("toarray with bad type error not thrown",
- errorThrown);
+ Assert.IsTrue (errorThrown, "toarray with bad type error not thrown");
}
{
char [] c1 = { 'a', 'b', 'c', 'd', 'e' };
ArrayList al1 = new ArrayList (c1);
object [] o2 = al1.ToArray ();
for (int i = 0; i < c1.Length; i++) {
- AssertEquals ("should be copy", c1 [i], o2 [i]);
+ Assert.AreEqual (c1 [i], o2 [i], "should be copy");
}
Array c2 = al1.ToArray (c1 [0].GetType ());
for (int i = 0; i < c1.Length; i++) {
- AssertEquals ("should be copy",
- c1 [i], c2.GetValue (i));
+ Assert.AreEqual (c1 [i], c2.GetValue (i), "should be copy");
}
}
}
}
al1.RemoveAt (0);
al1.TrimToSize ();
- AssertEquals ("no capacity match", size - 1, al1.Capacity);
+ Assert.AreEqual (size - 1, al1.Capacity, "no capacity match");
al1.Clear ();
al1.TrimToSize ();
- AssertEquals ("no default capacity", capacity, al1.Capacity);
+ Assert.AreEqual (capacity, al1.Capacity, "no default capacity");
}
class Comparer : IComparer
public void BinarySearch1_EmptyList ()
{
ArrayList list = new ArrayList ();
- AssertEquals ("BinarySearch", -1, list.BinarySearch (0));
+ Assert.AreEqual (-1, list.BinarySearch (0), "BinarySearch");
}
[Test]
{
Comparer comparer = new Comparer ();
ArrayList list = new ArrayList ();
- AssertEquals ("BinarySearch", -1, list.BinarySearch (0, comparer));
+ Assert.AreEqual (-1, list.BinarySearch (0, comparer), "BinarySearch");
// bug 77030 - the comparer isn't called for an empty array/list
- Assert ("Called", !comparer.Called);
+ Assert.IsTrue (!comparer.Called, "Called");
}
[Test]
{
Comparer comparer = new Comparer ();
ArrayList list = new ArrayList ();
- AssertEquals ("BinarySearch", -1, list.BinarySearch (0, 0, 0, comparer));
+ Assert.AreEqual (-1, list.BinarySearch (0, 0, 0, comparer), "BinarySearch");
// bug 77030 - the comparer isn't called for an empty array/list
- Assert ("Called", !comparer.Called);
+ Assert.IsTrue (!comparer.Called, "Called");
}
[Test]
public void AddRange_GetRange ()
{
ArrayList source = ArrayList.Adapter (new object [] { "1", "2" });
- AssertEquals ("#1", 2, source.Count);
- AssertEquals ("#2", "1", source [0]);
- AssertEquals ("#3", "2", source [1]);
+ Assert.AreEqual (2, source.Count, "#1");
+ Assert.AreEqual ("1", source [0], "#2");
+ Assert.AreEqual ("2", source [1], "#3");
ArrayList range = source.GetRange (1, 1);
- AssertEquals ("#4", 1, range.Count);
- AssertEquals ("#5", "2", range [0]);
+ Assert.AreEqual (1, range.Count, "#4");
+ Assert.AreEqual ("2", range [0], "#5");
ArrayList target = new ArrayList ();
target.AddRange (range);
- AssertEquals ("#6", 1, target.Count);
- AssertEquals ("#7", "2", target [0]);
+ Assert.AreEqual (1, target.Count, "#6");
+ Assert.AreEqual ("2", target [0], "#7");
}
[Test]
ArrayList list = new ArrayList ();
list.Add (list);
IEnumerator enumerator = list.GetEnumerator ();
- Assert ("#1", enumerator.MoveNext ());
- Assert ("#2", object.ReferenceEquals (list, enumerator.Current));
- Assert ("#3", !enumerator.MoveNext ());
+ Assert.IsTrue (enumerator.MoveNext (), "#1");
+ Assert.IsTrue (object.ReferenceEquals (list, enumerator.Current), "#2");
+ Assert.IsTrue (!enumerator.MoveNext (), "#3");
}
}
}
\r
/// <summary>Hashtable test.</summary>\r
[TestFixture]\r
-public class HashtableTest : Assertion {\r
+public class HashtableTest {\r
\r
[Test]\r
public void TestCtor1() {\r
Hashtable h = new Hashtable();\r
- AssertNotNull("No hash table", h);\r
+ Assert.IsNotNull (h, "No hash table");\r
}\r
\r
[Test]\r
} catch (ArgumentNullException) {\r
errorThrown = true;\r
}\r
- Assert("null hashtable error not thrown", \r
- errorThrown);\r
+ Assert.IsTrue (errorThrown, "null hashtable error not thrown");\r
}\r
{\r
string[] keys = {"this", "is", "a", "test"};\r
}\r
Hashtable h2 = new Hashtable(h1);\r
for (int i = 0; i < keys.Length; i++) {\r
- AssertEquals("No match for key " + keys[i],\r
- values[i], h2[keys[i]]);\r
+ Assert.AreEqual (values[i], h2[keys[i]], "No match for key " + keys[i]);\r
}\r
}\r
}\r
// tests if negative capacity throws exception\r
try {\r
Hashtable ht = new Hashtable (-10, 0.1f, null, null);\r
- Assert("must throw ArgumentOutOfRange exception, param: capacity", false);\r
+ Assert.Fail ("must throw ArgumentOutOfRange exception, param: capacity");\r
} catch (ArgumentOutOfRangeException e) {\r
- Assert("ParamName is not capacity", e.ParamName == "capacity");\r
+ Assert.IsTrue (e.ParamName == "capacity", "ParamName is not capacity");\r
}\r
\r
// tests if loadFactor out of range throws exception (low)\r
try {\r
Hashtable ht = new Hashtable (100, 0.01f, null, null);\r
- Assert("must throw ArgumentOutOfRange exception, param: loadFactor, too low value", false);\r
+ Assert.Fail ("must throw ArgumentOutOfRange exception, param: loadFactor, too low value");\r
} catch (ArgumentOutOfRangeException e) \r
{\r
- Assert("ParamName is not loadFactor",e.ParamName == "loadFactor");\r
+ Assert.IsTrue (e.ParamName == "loadFactor", "ParamName is not loadFactor");\r
}\r
\r
// tests if loadFactor out of range throws exception (high)\r
try \r
{\r
Hashtable ht = new Hashtable (100, 2f, null, null);\r
- Assert("must throw ArgumentOutOfRange exception, param: loadFactor, too high value", false);\r
+ Assert.Fail ("must throw ArgumentOutOfRange exception, param: loadFactor, too high value");\r
} \r
catch (ArgumentOutOfRangeException e) \r
{\r
- Assert("ParamName is not loadFactor", e.ParamName == "loadFactor");\r
+ Assert.IsTrue (e.ParamName == "loadFactor", "ParamName is not loadFactor");\r
}\r
\r
}\r
[Test] \r
public void TestCount() {\r
Hashtable h = new Hashtable();\r
- AssertEquals("new table - count zero", 0, h.Count);\r
+ Assert.AreEqual (0, h.Count, "new table - count zero");\r
int max = 100;\r
for (int i = 1; i <= max; i++) {\r
h[i] = i;\r
- AssertEquals("Count wrong for " + i,\r
- i, h.Count);\r
+ Assert.AreEqual (i, h.Count, "Count wrong for " + i);\r
}\r
for (int i = 1; i <= max; i++) {\r
h[i] = i * 2;\r
- AssertEquals("Count shouldn't change at " + i,\r
- max, h.Count);\r
+ Assert.AreEqual (max, h.Count, "Count shouldn't change at " + i);\r
}\r
}\r
\r
[Test] \r
public void TestIsFixedSize() {\r
Hashtable h = new Hashtable();\r
- AssertEquals("hashtable not fixed by default",\r
- false, h.IsFixedSize);\r
+ Assert.AreEqual (false, h.IsFixedSize, "hashtable not fixed by default");\r
// TODO - any way to get a fixed-size hashtable?\r
}\r
\r
public void TestIsReadOnly() {\r
Hashtable h = new Hashtable();\r
- AssertEquals("hashtable not read-only by default",\r
- false, h.IsReadOnly);\r
+ Assert.AreEqual (false, h.IsReadOnly, "hashtable not read-only by default");\r
// TODO - any way to get a read-only hashtable?\r
}\r
\r
public void TestIsSynchronized ()\r
{\r
Hashtable h = new Hashtable ();\r
- Assert ("hashtable not synched by default", !h.IsSynchronized);\r
+ Assert.IsTrue (!h.IsSynchronized, "hashtable not synched by default");\r
\r
Hashtable h2 = Hashtable.Synchronized (h);\r
- Assert ("hashtable should by synched", h2.IsSynchronized);\r
+ Assert.IsTrue (h2.IsSynchronized, "hashtable should by synched");\r
\r
Hashtable h3 = (Hashtable) h2.Clone ();\r
- Assert ("Cloned Hashtable should by synched", h3.IsSynchronized);\r
+ Assert.IsTrue (h3.IsSynchronized, "Cloned Hashtable should by synched");\r
}\r
\r
[Test]\r
Object o = h[null];\r
} catch (ArgumentNullException e) {\r
errorThrown = true;\r
- AssertEquals("ParamName is not \"key\"", "key", e.ParamName);\r
+ Assert.AreEqual ("key", e.ParamName, "ParamName is not \"key\"");\r
}\r
- Assert("null hashtable error not thrown", \r
- errorThrown);\r
+ Assert.IsTrue (errorThrown, "null hashtable error not thrown");\r
}\r
// TODO - if read-only and/or fixed-size is possible,\r
// test 'NotSupportedException' here\r
int max = 100;\r
for (int i = 1; i <= max; i++) {\r
h[i] = i;\r
- AssertEquals("value wrong for " + i,\r
- i, h[i]);\r
+ Assert.AreEqual (i, h[i], "value wrong for " + i);\r
}\r
}\r
}\r
for (int i = 0; i < keys.Length; i++) {\r
h1[keys[i]] = values1[i];\r
}\r
- AssertEquals("keys wrong size",\r
- keys.Length, h1.Keys.Count);\r
+ Assert.AreEqual (keys.Length, h1.Keys.Count, "keys wrong size");\r
for (int i = 0; i < keys.Length; i++) {\r
h1[keys[i]] = values2[i];\r
}\r
- AssertEquals("keys wrong size 2",\r
- keys.Length, h1.Keys.Count);\r
+ Assert.AreEqual (keys.Length, h1.Keys.Count, "keys wrong size 2");\r
\r
// MS .NET Always returns the same reference when calling Keys property\r
keysReference = h1.Keys;\r
keysReference2 = h1.Keys;\r
- AssertEquals("keys references differ", keysReference, keysReference2);\r
+ Assert.AreEqual (keysReference, keysReference2, "keys references differ");\r
\r
for (int i = 0; i < keys2.Length; i++) \r
{\r
h1[keys2[i]] = values2[i];\r
}\r
- AssertEquals("keys wrong size 3",\r
- keys.Length+keys2.Length, h1.Keys.Count);\r
- AssertEquals("keys wrong size 4",\r
- keys.Length+keys2.Length, keysReference.Count);\r
+ Assert.AreEqual (keys.Length+keys2.Length, h1.Keys.Count, "keys wrong size 3");\r
+ Assert.AreEqual (keys.Length+keys2.Length, keysReference.Count, "keys wrong size 4");\r
}\r
\r
// TODO - SyncRoot\r
for (int i = 0; i < keys.Length; i++) {\r
h1[keys[i]] = values1[i];\r
}\r
- AssertEquals("values wrong size",\r
- keys.Length, h1.Values.Count);\r
+ Assert.AreEqual (keys.Length, h1.Values.Count, "values wrong size");\r
for (int i = 0; i < keys.Length; i++) {\r
h1[keys[i]] = values2[i];\r
}\r
- AssertEquals("values wrong size 2",\r
- keys.Length, h1.Values.Count);\r
+ Assert.AreEqual (keys.Length, h1.Values.Count, "values wrong size 2");\r
\r
// MS .NET Always returns the same reference when calling Values property\r
ICollection valuesReference1 = h1.Values;\r
ICollection valuesReference2 = h1.Values;\r
- AssertEquals("values references differ", valuesReference1, valuesReference2);\r
+ Assert.AreEqual (valuesReference1, valuesReference2, "values references differ");\r
}\r
\r
[Test]\r
h.Add(null, "huh?");\r
} catch (ArgumentNullException e) {\r
errorThrown = true;\r
- AssertEquals("ParamName is not 'key'", "key", e.ParamName);\r
+ Assert.AreEqual ("key", e.ParamName, "ParamName is not 'key'");\r
}\r
- Assert("null add error not thrown", \r
- errorThrown);\r
+ Assert.IsTrue (errorThrown, "null add error not thrown");\r
}\r
{\r
bool errorThrown = false;\r
} catch (ArgumentException) {\r
errorThrown = true;\r
}\r
- Assert("re-add error not thrown", \r
- errorThrown);\r
+ Assert.IsTrue (errorThrown, "re-add error not thrown");\r
}\r
// TODO - hit NotSupportedException\r
{\r
int max = 100;\r
for (int i = 1; i <= max; i++) {\r
h.Add(i, i);\r
- AssertEquals("value wrong for " + i,\r
- i, h[i]);\r
+ Assert.AreEqual (i, h[i], "value wrong for " + i);\r
}\r
}\r
}\r
public void TestClear() {\r
// TODO - hit NotSupportedException\r
Hashtable h = new Hashtable();\r
- AssertEquals("new table - count zero", 0, h.Count);\r
+ Assert.AreEqual (0, h.Count, "new table - count zero");\r
int max = 100;\r
for (int i = 1; i <= max; i++) {\r
h[i] = i;\r
}\r
- Assert("table don't gots stuff", h.Count > 0);\r
+ Assert.IsTrue (h.Count > 0, "table don't gots stuff");\r
h.Clear();\r
- AssertEquals("Table should be cleared",\r
- 0, h.Count);\r
+ Assert.AreEqual (0, h.Count, "Table should be cleared");\r
}\r
\r
#if NET_2_0\r
h1[c1[i]] = c2[i];\r
}\r
Hashtable h2 = (Hashtable)h1.Clone();\r
- AssertNotNull("got no clone!", h2);\r
- AssertNotNull("clone's got nothing!", h2[c1[0]]);\r
+ Assert.IsNotNull (h2, "got no clone!");\r
+ Assert.IsNotNull (h2[c1[0]], "clone's got nothing!");\r
for (int i = 0; i < c1.Length; i++) {\r
- AssertEquals("Hashtable match", \r
- h1[c1[i]], h2[c1[i]]);\r
+ Assert.AreEqual (h1[c1[i]], h2[c1[i]], "Hashtable match");\r
}\r
}\r
{\r
h1[c1[i]] = c2[i];\r
}\r
Hashtable h2 = (Hashtable)h1.Clone();\r
- AssertNotNull("got no clone!", h2);\r
- AssertNotNull("clone's got nothing!", h2[c1[0]]);\r
+ Assert.IsNotNull (h2, "got no clone!");\r
+ Assert.IsNotNull (h2[c1[0]], "clone's got nothing!");\r
for (int i = 0; i < c1.Length; i++) {\r
- AssertEquals("Hashtable match", \r
- h1[c1[i]], h2[c1[i]]);\r
+ Assert.AreEqual (h1[c1[i]], h2[c1[i]], "Hashtable match");\r
}\r
\r
((char[])h1[c1[0]])[0] = 'z';\r
- AssertEquals("shallow copy", h1[c1[0]], h2[c1[0]]);\r
+ Assert.AreEqual (h1[c1[0]], h2[c1[0]], "shallow copy");\r
\r
#if NET_2_0\r
// NET 2.0 stuff\r
Hashtable mh1clone = (Hashtable) mh1.Clone ();\r
\r
// warning, depends on the field name.\r
- AssertEquals ("EqualityComparer",\r
- GetEqualityComparer (mh1),\r
- GetEqualityComparer (mh1clone));\r
+ Assert.AreEqual (GetEqualityComparer (mh1), GetEqualityComparer (mh1clone), "EqualityComparer");\r
#endif\r
}\r
}\r
bool result = h.Contains(null);\r
} catch (ArgumentNullException e) {\r
errorThrown = true;\r
- AssertEquals("ParamName is not 'key'", "key", e.ParamName);\r
+ Assert.AreEqual ("key", e.ParamName, "ParamName is not 'key'");\r
}\r
- Assert("null add error not thrown", \r
- errorThrown);\r
+ Assert.IsTrue (errorThrown, "null add error not thrown");\r
}\r
{\r
Hashtable h = new Hashtable();\r
}\r
for (int i = 0; i < 10000; i += 2) \r
{\r
- Assert("hashtable must contain"+i.ToString(), h.Contains(i));\r
- Assert("hashtable does not contain "+((int)(i+1)).ToString(), !h.Contains(i+1));\r
+ Assert.IsTrue (h.Contains(i), "hashtable must contain"+i.ToString());\r
+ Assert.IsTrue (!h.Contains(i+1), "hashtable does not contain "+((int)(i+1)).ToString());\r
}\r
}\r
}\r
catch (ArgumentNullException e) \r
{\r
errorThrown = true;\r
- AssertEquals("ParamName is not 'key'", "key", e.ParamName);\r
+ Assert.AreEqual ("key", e.ParamName, "ParamName is not 'key'");\r
}\r
- Assert("null add error not thrown", \r
- errorThrown);\r
+ Assert.IsTrue (errorThrown, "null add error not thrown");\r
}\r
{\r
Hashtable h = new Hashtable();\r
}\r
for (int i = 0; i < 1000; i += 2) \r
{\r
- Assert("hashtable must contain"+i.ToString(), h.Contains(i));\r
- Assert("hashtable does not contain "+((int)(i+1)).ToString(), !h.Contains(i+1));\r
+ Assert.IsTrue (h.Contains(i), "hashtable must contain"+i.ToString());\r
+ Assert.IsTrue (!h.Contains(i+1), "hashtable does not contain "+((int)(i+1)).ToString());\r
}\r
}\r
\r
{\r
Hashtable h = new Hashtable();\r
h['a'] = "blue";\r
- Assert("blue? it's in there!", \r
- h.ContainsValue("blue"));\r
- Assert("green? no way!", \r
- !h.ContainsValue("green"));\r
- Assert("null? no way!", \r
- !h.ContainsValue(null));\r
+ Assert.IsTrue (h.ContainsValue("blue"), "blue? it's in there!");\r
+ Assert.IsTrue (!h.ContainsValue("green"), "green? no way!");\r
+ Assert.IsTrue (!h.ContainsValue(null), "null? no way!");\r
h['b'] = null;\r
- Assert("null? it's in there!", \r
- h.ContainsValue(null));\r
+ Assert.IsTrue (h.ContainsValue(null), "null? it's in there!");\r
\r
}\r
}\r
h.CopyTo(null, 0);\r
} catch (ArgumentNullException e) {\r
errorThrown = true;\r
- AssertEquals("ParamName is not \"array\"", "array", e.ParamName); \r
+ Assert.AreEqual ("array", e.ParamName, "ParamName is not \"array\""); \r
}\r
- Assert("null hashtable error not thrown", \r
- errorThrown);\r
+ Assert.IsTrue (errorThrown, "null hashtable error not thrown");\r
}\r
{\r
bool errorThrown = false;\r
h.CopyTo(o, -1);\r
} catch (ArgumentOutOfRangeException e) {\r
errorThrown = true;\r
- AssertEquals("ParamName is not \"arrayIndex\"", "arrayIndex", e.ParamName);\r
+ Assert.AreEqual ("arrayIndex", e.ParamName, "ParamName is not \"arrayIndex\"");\r
}\r
- Assert("out of range error not thrown", \r
- errorThrown);\r
+ Assert.IsTrue (errorThrown, "out of range error not thrown");\r
}\r
{\r
bool errorThrown = false;\r
} catch (ArgumentException) {\r
errorThrown = true;\r
}\r
- Assert("multi-dim array error not thrown", \r
- errorThrown);\r
+ Assert.IsTrue (errorThrown, "multi-dim array error not thrown");\r
}\r
{\r
bool errorThrown = false;\r
} catch (ArgumentException) {\r
errorThrown = true;\r
}\r
- Assert("no room in array error not thrown", \r
- errorThrown);\r
+ Assert.IsTrue (errorThrown, "no room in array error not thrown");\r
}\r
{\r
bool errorThrown = false;\r
} catch (ArgumentException) {\r
errorThrown = true;\r
}\r
- Assert("table too big error not thrown", \r
- errorThrown);\r
+ Assert.IsTrue (errorThrown, "table too big error not thrown");\r
}\r
{\r
bool errorThrown = false;\r
} catch (InvalidCastException) {\r
errorThrown = true;\r
}\r
- Assert("invalid cast error not thrown", \r
- errorThrown);\r
+ Assert.IsTrue (errorThrown, "invalid cast error not thrown");\r
}\r
\r
{\r
o[1] = v;\r
}\r
#endif // TARGET_JVM\r
- AssertEquals("first copy fine.", 'a', o[0].Key);\r
- AssertEquals("first copy fine.", 1, o[0].Value);\r
- AssertEquals("second copy fine.", 'b', o[1].Key);\r
- AssertEquals("second copy fine.", 2, o[1].Value);\r
+ Assert.AreEqual ('a', o[0].Key, "first copy fine.");\r
+ Assert.AreEqual (1, o[0].Value, "first copy fine.");\r
+ Assert.AreEqual ('b', o[1].Key, "second copy fine.");\r
+ Assert.AreEqual (2, o[1].Value, "second copy fine.");\r
}\r
}\r
\r
h1[s1[i]] = c1[i];\r
}\r
IDictionaryEnumerator en = h1.GetEnumerator();\r
- AssertNotNull("No enumerator", en);\r
+ Assert.IsNotNull (en, "No enumerator");\r
\r
for (int i = 0; i < s1.Length; i++) {\r
en.MoveNext();\r
- Assert("Not enumerating for " + en.Key, \r
- Array.IndexOf(s1, en.Key) >= 0);\r
- Assert("Not enumerating for " + en.Value, \r
- Array.IndexOf(c1, en.Value) >= 0);\r
+ Assert.IsTrue (Array.IndexOf(s1, en.Key) >= 0, "Not enumerating for " + en.Key);\r
+ Assert.IsTrue (Array.IndexOf(c1, en.Value) >= 0, "Not enumerating for " + en.Value);\r
}\r
}\r
\r
\r
bool result;\r
foreach (DictionaryEntry de in table1)\r
- AssertEquals (de.Value, table2 [de.Key]);\r
+ Assert.AreEqual (table2 [de.Key], de.Value);\r
}\r
\r
[Test]\r
formatter.Serialize(stream, table);\r
stream.Position = 0;\r
table = (Hashtable) formatter.Deserialize(stream);\r
- AssertEquals ("#1", 1, table.Count);\r
+ Assert.AreEqual (1, table.Count, "#1");\r
}\r
\r
[Test] \r
h.Remove(null);\r
} catch (ArgumentNullException e) {\r
errorThrown = true;\r
- AssertEquals("ParamName is not \"key\"", "key", e.ParamName);\r
+ Assert.AreEqual ("key", e.ParamName, "ParamName is not \"key\"");\r
}\r
- Assert("null hashtable error not thrown", \r
- errorThrown);\r
+ Assert.IsTrue (errorThrown, "null hashtable error not thrown");\r
}\r
{\r
string[] keys = {"this", "is", "a", "test"};\r
for (int i = 0; i < keys.Length; i++) {\r
h[keys[i]] = values[i];\r
}\r
- AssertEquals("not enough in table",\r
- 4, h.Count);\r
+ Assert.AreEqual (4, h.Count, "not enough in table");\r
h.Remove("huh?");\r
- AssertEquals("not enough in table",\r
- 4, h.Count);\r
+ Assert.AreEqual (4, h.Count, "not enough in table");\r
h.Remove("this");\r
- AssertEquals("Wrong count in table",\r
- 3, h.Count);\r
+ Assert.AreEqual (3, h.Count, "Wrong count in table");\r
h.Remove("this");\r
- AssertEquals("Wrong count in table",\r
- 3, h.Count);\r
+ Assert.AreEqual (3, h.Count, "Wrong count in table");\r
}\r
}\r
\r
Hashtable h = Hashtable.Synchronized(null);\r
} catch (ArgumentNullException e) {\r
errorThrown = true;\r
- AssertEquals("ParamName is not \"table\"", "table", e.ParamName);\r
+ Assert.AreEqual ("table", e.ParamName, "ParamName is not \"table\"");\r
}\r
- Assert("null hashtable error not thrown", \r
- errorThrown);\r
+ Assert.IsTrue (errorThrown, "null hashtable error not thrown");\r
}\r
{\r
Hashtable h = new Hashtable();\r
- Assert("hashtable not synced by default", \r
- !h.IsSynchronized);\r
+ Assert.IsTrue (!h.IsSynchronized, "hashtable not synced by default");\r
Hashtable h2 = Hashtable.Synchronized(h);\r
- Assert("hashtable should by synced", \r
- h2.IsSynchronized);\r
+ Assert.IsTrue (h2.IsSynchronized, "hashtable should by synced");\r
}\r
}\r
\r
[Test]\r
public void TestAddRemoveClear() {\r
ht.Clear();\r
- Assert(ht.Count==0);\r
+ Assert.IsTrue (ht.Count==0);\r
\r
SetDefaultData();\r
- Assert(ht.Count==3);\r
+ Assert.IsTrue (ht.Count==3);\r
\r
bool thrown=false;\r
try {\r
ht.Add("k2","cool");\r
} catch (ArgumentException) {thrown=true;}\r
- Assert("Must throw ArgumentException!",thrown);\r
+ Assert.IsTrue (thrown, "Must throw ArgumentException!");\r
\r
ht["k2"]="cool";\r
- Assert(ht.Count==3);\r
- Assert(ht["k2"].Equals("cool"));\r
+ Assert.IsTrue (ht.Count==3);\r
+ Assert.IsTrue (ht["k2"].Equals("cool"));\r
\r
}\r
\r
SetDefaultData();\r
Object[] entries=new Object[ht.Count];\r
ht.CopyTo(entries,0);\r
- Assert("Not an entry.",entries[0] is DictionaryEntry);\r
+ Assert.IsTrue (entries[0] is DictionaryEntry, "Not an entry.");\r
}\r
\r
[Test]\r
public void CopyTo_Empty ()\r
{\r
Hashtable ht = new Hashtable ();\r
- AssertEquals ("Count", 0, ht.Count);\r
+ Assert.AreEqual (0, ht.Count, "Count");\r
object[] array = new object [ht.Count];\r
ht.CopyTo (array, 0);\r
}\r
}\r
}\r
\r
- Assert(ht.Count==n);\r
+ Assert.IsTrue (ht.Count==n);\r
\r
for (int i=0;i<n;i++) {\r
String key=cache[i];\r
String val=ht[key] as String;\r
String err="ht[\""+key+"\"]=\""+val+\r
"\", expected \""+cache[i+max]+"\"";\r
- Assert(err,val!=null && val.Equals(cache[i+max]));\r
+ Assert.IsTrue (val!=null && val.Equals(cache[i+max]), err);\r
}\r
\r
int r1=(n/3);\r
\r
for (int i=0;i<n;i++) {\r
if (i>=r1 && i<r2) {\r
- Assert(ht[cache[i]]==null);\r
+ Assert.IsTrue (ht[cache[i]]==null);\r
} else {\r
String key=cache[i];\r
String val=ht[key] as String;\r
String err="ht[\""+key+"\"]=\""+val+\r
"\", expected \""+cache[i+max]+"\"";\r
- Assert(err,val!=null && val.Equals(cache[i+max]));\r
+ Assert.IsTrue (val!=null && val.Equals(cache[i+max]), err);\r
}\r
}\r
\r
ICollection keys=ht.Keys;\r
int nKeys=0;\r
foreach (Object key in keys) {\r
- Assert((key as String) != null);\r
+ Assert.IsTrue ((key as String) != null);\r
nKeys++;\r
}\r
- Assert(nKeys==ht.Count);\r
+ Assert.IsTrue (nKeys==ht.Count);\r
\r
\r
ICollection vals=ht.Values;\r
int nVals=0;\r
foreach (Object val in vals) {\r
- Assert((val as String) != null);\r
+ Assert.IsTrue ((val as String) != null);\r
nVals++;\r
}\r
- Assert(nVals==ht.Count);\r
+ Assert.IsTrue (nVals==ht.Count);\r
\r
}\r
\r
Hashtable ciHashtable = new Hashtable(11,1.0f,CaseInsensitiveHashCodeProvider.Default,CaseInsensitiveComparer.Default);\r
ciHashtable ["key1"] = "value";\r
ciHashtable ["key2"] = "VALUE";\r
- Assert(ciHashtable ["key1"].Equals ("value"));\r
- Assert(ciHashtable ["key2"].Equals ("VALUE"));\r
+ Assert.IsTrue (ciHashtable ["key1"].Equals ("value"));\r
+ Assert.IsTrue (ciHashtable ["key2"].Equals ("VALUE"));\r
\r
ciHashtable ["KEY1"] = "new_value";\r
- Assert(ciHashtable ["key1"].Equals ("new_value"));\r
+ Assert.IsTrue (ciHashtable ["key1"].Equals ("new_value"));\r
\r
}\r
\r
\r
Hashtable htCopy = new Hashtable (ht);\r
\r
- Assert(ht.Count == htCopy.Count);\r
+ Assert.IsTrue (ht.Count == htCopy.Count);\r
}\r
\r
[Test]\r
\r
while (e.MoveNext ()) {}\r
\r
- Assert (!e.MoveNext ());\r
+ Assert.IsTrue (!e.MoveNext ());\r
\r
}\r
\r
{\r
Hashtable ht = new Hashtable ();\r
// see bug #76300\r
- Assert ("Keys.IsSerializable", ht.Keys.GetType ().IsSerializable);\r
- Assert ("Values.IsSerializable", ht.Values.GetType ().IsSerializable);\r
- Assert ("GetEnumerator.IsSerializable", ht.GetEnumerator ().GetType ().IsSerializable);\r
- Assert ("Synchronized.IsSerializable", Hashtable.Synchronized (ht).GetType ().IsSerializable);\r
+ Assert.IsTrue (ht.Keys.GetType ().IsSerializable, "Keys.IsSerializable");\r
+ Assert.IsTrue (ht.Values.GetType ().IsSerializable, "Values.IsSerializable");\r
+ Assert.IsTrue (ht.GetEnumerator ().GetType ().IsSerializable, "GetEnumerator.IsSerializable");\r
+ Assert.IsTrue (Hashtable.Synchronized (ht).GetType ().IsSerializable, "Synchronized.IsSerializable");\r
}\r
\r
[Test]\r
namespace MonoTests.System.Collections {
[TestFixture]
- public class QueueTest : Assertion {
+ public class QueueTest {
protected Queue q1;
protected Queue q2;
emptyQueue = new Queue ();
}
+ [Test]
public void TestConstructorException1 ()
{
try
{
Queue q = new Queue(-1, 2);
- Fail("Should throw an exception");
+ Assert.Fail ("Should throw an exception");
} catch (ArgumentOutOfRangeException e) {
- AssertEquals("Exception's ParamName must be \"capacity\"", "capacity", e.ParamName);
+ Assert.AreEqual ("capacity", e.ParamName, "Exception's ParamName must be \"capacity\"");
}
}
+ [Test]
public void TestConstructorException2 ()
{
try
{
Queue q = new Queue(10, 0);
- Fail("Should throw an exception because growFactor < 1");
+ Assert.Fail ("Should throw an exception because growFactor < 1");
}
catch (ArgumentOutOfRangeException e)
{
- AssertEquals("Exception's ParamName must be \"growFactor\"", "growFactor", e.ParamName);
+ Assert.AreEqual ("growFactor", e.ParamName, "Exception's ParamName must be \"growFactor\"");
}
}
+ [Test]
public void TestConstructorException3 ()
{
try
{
Queue q = new Queue(10, 11);
- Fail("Should throw an exception because growFactor > 10");
+ Assert.Fail ("Should throw an exception because growFactor > 10");
}
catch (ArgumentOutOfRangeException e)
{
- AssertEquals("Exception's ParamName must be \"growFactor\"", "growFactor", e.ParamName);
+ Assert.AreEqual ("growFactor", e.ParamName, "Exception's ParamName must be \"growFactor\"");
}
}
+ [Test]
public void TestConstructorException4 ()
{
try
{
Queue q = new Queue(null);
- Fail("Should throw an exception because col == null");
+ Assert.Fail ("Should throw an exception because col == null");
}
catch (ArgumentNullException e)
{
- AssertEquals("Exception's ParamName must be \"col\"", "col", e.ParamName);
+ Assert.AreEqual ("col", e.ParamName, "Exception's ParamName must be \"col\"");
}
}
+ [Test]
public void TestICollectionConstructor ()
{
Queue q = new Queue(new int[] {1, 2, 3, 4, 5});
- AssertEquals("count", 5, q.Count);
+ Assert.AreEqual (5, q.Count, "count");
for (int i=1; i <=5; i++)
{
- AssertEquals(i, q.Dequeue());
+ Assert.AreEqual (q.Dequeue(), i);
}
}
+ [Test]
public void TestConstructors ()
{
- SetUp();
- Assert (q1.Count == 100);
- Assert (q2.Count == 50);
- Assert (emptyQueue.Count == 0);
+ Assert.IsTrue (q1.Count == 100);
+ Assert.IsTrue (q2.Count == 50);
+ Assert.IsTrue (emptyQueue.Count == 0);
}
+ [Test]
public void TestCount()
{
- SetUp();
-
- AssertEquals("Count #1", 100, q1.Count);
+ Assert.AreEqual (100, q1.Count, "Count #1");
for (int i = 1; i <=50; i ++)
{
q1.Dequeue();
}
- AssertEquals("Count #2", 50, q1.Count);
+ Assert.AreEqual (50, q1.Count, "Count #2");
for (int i = 1; i <=50; i ++)
{
q1.Enqueue(i);
}
- AssertEquals("Count #3", 100, q1.Count);
+ Assert.AreEqual (100, q1.Count, "Count #3");
- AssertEquals("Count #4", 50, q2.Count);
+ Assert.AreEqual (50, q2.Count, "Count #4");
- AssertEquals("Count #5", 0, emptyQueue.Count);
+ Assert.AreEqual (0, emptyQueue.Count, "Count #5");
}
+ [Test]
public void TestIsSynchronized()
{
- SetUp();
- Assert("IsSynchronized should be false", !q1.IsSynchronized);
- Assert("IsSynchronized should be false", !q2.IsSynchronized);
- Assert("IsSynchronized should be false", !emptyQueue.IsSynchronized);
+ Assert.IsTrue (!q1.IsSynchronized, "IsSynchronized should be false");
+ Assert.IsTrue (!q2.IsSynchronized, "IsSynchronized should be false");
+ Assert.IsTrue (!emptyQueue.IsSynchronized, "IsSynchronized should be false");
}
+ [Test]
public void TestSyncRoot()
{
- SetUp();
#if !NET_2_0 // umm, why on earth do you expect SyncRoot is the Queue itself?
- AssertEquals("SyncRoot q1", q1, q1.SyncRoot);
- AssertEquals("SyncRoot q2", q2, q2.SyncRoot);
- AssertEquals("SyncRoot emptyQueue", emptyQueue, emptyQueue.SyncRoot);
+ Assert.AreEqual (q1, q1.SyncRoot, "SyncRoot q1");
+ Assert.AreEqual (q2, q2.SyncRoot, "SyncRoot q2");
+ Assert.AreEqual (emptyQueue, emptyQueue.SyncRoot, "SyncRoot emptyQueue");
#endif
Queue q1sync = Queue.Synchronized(q1);
- AssertEquals("SyncRoot value of a synchronized queue", q1, q1sync.SyncRoot);
+ Assert.AreEqual (q1, q1sync.SyncRoot, "SyncRoot value of a synchronized queue");
}
+ [Test]
public void TestCopyToException1 ()
{
- SetUp();
try
{
q1.CopyTo(null, 1);
- Fail("must throw ArgumentNullException");
+ Assert.Fail ("must throw ArgumentNullException");
} catch (ArgumentNullException e) {
- AssertEquals("Exception's ParamName must be \"array\"", "array", e.ParamName);
+ Assert.AreEqual ("array", e.ParamName, "Exception's ParamName must be \"array\"");
}
}
+ [Test]
public void TestCopyToException2 ()
{
- SetUp();
try
{
q1.CopyTo(new int[2,2], 1);
- Fail("must throw ArgumentException");
+ Assert.Fail ("must throw ArgumentException");
}
catch (ArgumentException)
{
}
}
+ [Test]
public void TestCopyToException3 ()
{
- SetUp();
try
{
q1.CopyTo(new int[3], -1);
- Fail("must throw ArgumentOutOfRangeException");
+ Assert.Fail ("must throw ArgumentOutOfRangeException");
}
catch (ArgumentOutOfRangeException e)
{
- AssertEquals("Exception's ParamName must be \"index\"", "index", e.ParamName);
+ Assert.AreEqual ("index", e.ParamName, "Exception's ParamName must be \"index\"");
}
}
+ [Test]
public void TestCopyToException4 ()
{
- SetUp();
try
{
q1.CopyTo(new int[3], 1);
- Fail("must throw ArgumentException");
+ Assert.Fail ("must throw ArgumentException");
}
catch (ArgumentException) {}
}
+ [Test]
public void TestCopyTo ()
{
- SetUp();
-
int[] a1 = new int[100];
int[] a2 = new int[60];
progress_marker = "before first CopyTo";
q1.CopyTo (a1, 0);
for (int i = 0; i < 100; i++)
- AssertEquals (i, a1[i]);
+ Assert.AreEqual (a1[i], i);
// Remove some items from q2 and add other
// items, to avoid having an "easy" just created
// Queue
for (int i = 50; i < 60; i++)
- Assert (i == (int) q2.Dequeue ());
+ Assert.IsTrue (i == (int) q2.Dequeue ());
for (int i = 100; i < 110; i++)
q2.Enqueue (i);
progress_marker = "before second CopyTo";
q2.CopyTo (a2, 10);
for (int i = 60; i < 110; i++)
- Assert (i == a2[i - 60 + 10]);
+ Assert.IsTrue (i == a2[i - 60 + 10]);
// Copying an empty Queue should not modify the array
progress_marker = "before third CopyTo";
emptyQueue.CopyTo (a2, 10);
for (int i = 60; i < 110; i++)
- Assert (i == a2[i - 60 + 10]);
+ Assert.IsTrue (i == a2[i - 60 + 10]);
} catch (Exception e) {
- Fail ("Unexpected exception at marker <" + progress_marker + ">: e = " + e);
+ Assert.Fail ("Unexpected exception at marker <" + progress_marker + ">: e = " + e);
}
}
+ [Test]
public void TestEnumerator () {
- SetUp();
int i;
IEnumerator e;
e = q1.GetEnumerator ();
i = 0;
while (e.MoveNext ()) {
- AssertEquals ("q1 at i=" + i, i, ((int) e.Current));
+ Assert.AreEqual (i, ((int) e.Current), "q1 at i=" + i);
i++;
}
e = q2.GetEnumerator ();
i = 50;
while (e.MoveNext ()) {
- AssertEquals (i, ((int) e.Current));
+ Assert.AreEqual (((int) e.Current), i);
i++;
}
e = emptyQueue.GetEnumerator ();
if (e.MoveNext ())
- Fail ("Empty Queue enumerator returning elements!");
+ Assert.Fail ("Empty Queue enumerator returning elements!");
e = q1.GetEnumerator ();
try {
e.MoveNext ();
q1.Enqueue (0);
e.MoveNext ();
- Fail ("#1 Should have thrown InvalidOperationException");
+ Assert.Fail ("#1 Should have thrown InvalidOperationException");
} catch (InvalidOperationException) { }
e = q1.GetEnumerator ();
}
+ [Test]
public void TestEnumeratorException1 ()
{
- SetUp();
IEnumerator e;
e = q1.GetEnumerator();
q1.Enqueue(6);
try {
e.MoveNext();
- Fail("MoveNext must throw InvalidOperationException after Enqueue");
+ Assert.Fail ("MoveNext must throw InvalidOperationException after Enqueue");
} catch (InvalidOperationException) {}
try
{
e.Reset();
- Fail("Reset must throw InvalidOperationException after Enqueue");
+ Assert.Fail ("Reset must throw InvalidOperationException after Enqueue");
}
catch (InvalidOperationException) {}
try
{
e.Reset();
- Fail("Reset must throw InvalidOperationException after TrimToSize");
+ Assert.Fail ("Reset must throw InvalidOperationException after TrimToSize");
}
catch (InvalidOperationException) {}
IEnumerator e = q1.GetEnumerator();
while (e.MoveNext ()) {
}
- AssertNotNull (e.Current);
+ Assert.IsNotNull (e.Current);
}
[Test]
IEnumerator e = q1.GetEnumerator();
while (e.MoveNext ()) {
}
- Assert (!e.MoveNext ());
+ Assert.IsTrue (!e.MoveNext ());
}
+ [Test]
public void TestClone () {
- SetUp();
Queue q3 = (Queue) q2.Clone ();
- Assert (q3.Count == q2.Count);
+ Assert.IsTrue (q3.Count == q2.Count);
for (int i = 0; i < 50; i++)
- Assert (q2.Dequeue ().Equals (q3.Dequeue ()));
- Assert (q3.Count == 0);
- Assert (q2.Count == 0);
+ Assert.IsTrue (q2.Dequeue ().Equals (q3.Dequeue ()));
+ Assert.IsTrue (q3.Count == 0);
+ Assert.IsTrue (q2.Count == 0);
}
+ [Test]
public void TestClear () {
- SetUp();
q1.Clear ();
- Assert (q1.Count == 0);
+ Assert.IsTrue (q1.Count == 0);
q2.Clear ();
- Assert (q2.Count == 0);
+ Assert.IsTrue (q2.Count == 0);
emptyQueue.Clear ();
- Assert (emptyQueue.Count == 0);
+ Assert.IsTrue (emptyQueue.Count == 0);
}
+ [Test]
public void TestContains () {
- SetUp();
for (int i = 0; i < 100; i++) {
- Assert (q1.Contains (i));
- Assert (!emptyQueue.Contains (i));
+ Assert.IsTrue (q1.Contains (i));
+ Assert.IsTrue (!emptyQueue.Contains (i));
if (i < 50)
- Assert (!q2.Contains (i));
+ Assert.IsTrue (!q2.Contains (i));
else
- Assert (q2.Contains (i));
+ Assert.IsTrue (q2.Contains (i));
}
- Assert("q1 does not contain null", !q1.Contains(null));
+ Assert.IsTrue (!q1.Contains(null), "q1 does not contain null");
q1.Enqueue(null);
- Assert("q1 contains null", q1.Contains(null));
+ Assert.IsTrue (q1.Contains(null), "q1 contains null");
}
+ [Test]
public void TestEnqueueDequeuePeek () {
- SetUp();
int q1size = q1.Count;
int q2size = q2.Count;
q2.Enqueue (null);
- Assert (q2.Count == ++q2size);
+ Assert.IsTrue (q2.Count == ++q2size);
for (int i = 0; i < 50; i++) {
int k = (int) q1.Peek ();
- Assert (q1.Count == q1size);
+ Assert.IsTrue (q1.Count == q1size);
int j = (int) q1.Dequeue ();
- Assert (q1.Count == --q1size);
- Assert (i == j);
- Assert (j == k);
+ Assert.IsTrue (q1.Count == --q1size);
+ Assert.IsTrue (i == j);
+ Assert.IsTrue (j == k);
q2.Enqueue (j);
- Assert (q2.Count == ++q2size);
+ Assert.IsTrue (q2.Count == ++q2size);
}
for (int i = 50; i < 100; i++) {
- Assert (((int) q2.Dequeue ()) == i);
- Assert (q2.Count == --q2size);
+ Assert.IsTrue (((int) q2.Dequeue ()) == i);
+ Assert.IsTrue (q2.Count == --q2size);
}
- Assert (q2.Peek () == null);
- Assert (q2.Dequeue () == null);
- Assert (q2.Count == --q2size);
+ Assert.IsTrue (q2.Peek () == null);
+ Assert.IsTrue (q2.Dequeue () == null);
+ Assert.IsTrue (q2.Count == --q2size);
for (int i = 0; i < 50; i++) {
- Assert (((int) q2.Dequeue ()) == i);
- Assert (q2.Count == --q2size);
+ Assert.IsTrue (((int) q2.Dequeue ()) == i);
+ Assert.IsTrue (q2.Count == --q2size);
}
}
+ [Test]
public void TestDequeue() {
Queue queue = new Queue();
string[] tmp = new string[50];
i = 0;
while(queue.Count>0){
string z = (string) queue.Dequeue();
- AssertEquals (tmp[i], tmp[i], z);
+ Assert.AreEqual (tmp[i], z, tmp[i]);
i++;
}
}
+ [Test]
[ExpectedException(typeof(InvalidOperationException))]
public void TestDequeueEmpty()
{
q.Dequeue();
}
+ [Test]
public void TestToArray()
{
- SetUp();
object[] a = q1.ToArray();
for (int i = 0; i < 100; i++)
{
- AssertEquals("Queue-Array mismatch",q1.Dequeue(),(int) a[i]);
+ Assert.AreEqual (q1.Dequeue(), (int) a[i], "Queue-Array mismatch");
}
object[] b = emptyQueue.ToArray();
- AssertEquals("b should be a zero-lenght array", 0, b.Length);
+ Assert.AreEqual (0, b.Length, "b should be a zero-lenght array");
}
+ [Test]
public void TestTrimToSize()
{
- SetUp();
for (int i=0; i < 50; i++)
{
q1.Dequeue();
// TODO: test Syncronized operation
+ [Test]
public void TestSynchronizedException()
{
try
{
Queue.Synchronized(null);
- Fail("Must throw ArgumentNullException");
+ Assert.Fail ("Must throw ArgumentNullException");
}
catch (ArgumentNullException e)
{
- AssertEquals("Exception's ParamName must be \"queue\"", "queue", e.ParamName);
+ Assert.AreEqual ("queue", e.ParamName, "Exception's ParamName must be \"queue\"");
}
}
public void SynchronizedClone ()
{
Queue q1sync = Queue.Synchronized (q1);
- Assert ("q1sync.IsSyncronized", q1sync.IsSynchronized);
- AssertEquals ("q1sync.Count", q1.Count, q1sync.Count);
+ Assert.IsTrue (q1sync.IsSynchronized, "q1sync.IsSyncronized");
+ Assert.AreEqual (q1.Count, q1sync.Count, "q1sync.Count");
Queue q1syncsync = Queue.Synchronized (q1sync);
- Assert ("q1syncsync must be synchronized too", q1syncsync.IsSynchronized);
- AssertEquals ("q1syncsync.Count", q1.Count, q1syncsync.Count);
+ Assert.IsTrue (q1syncsync.IsSynchronized, "q1syncsync must be synchronized too");
+ Assert.AreEqual (q1.Count, q1syncsync.Count, "q1syncsync.Count");
Queue q1syncclone = (Queue) q1sync.Clone();
- Assert ("clone must be synchronized too", q1syncclone.IsSynchronized);
- AssertEquals ("q1syncclone.Count", q1.Count, q1syncclone.Count);
+ Assert.IsTrue (q1syncclone.IsSynchronized, "clone must be synchronized too");
+ Assert.AreEqual (q1.Count, q1syncclone.Count, "q1syncclone.Count");
}
[Test]
queue.Enqueue (i);
queue.TrimToSize ();
- AssertEquals ("0", 0, queue.Dequeue ());
+ Assert.AreEqual (0, queue.Dequeue (), "0");
queue.Enqueue (411);
- AssertEquals ("Count-1", 31, queue.Count);
+ Assert.AreEqual (31, queue.Count, "Count-1");
for (int i = 1; i < 31; i++) {
- AssertEquals ("Peek" + i.ToString (), i, queue.Peek ());
- AssertEquals ("Dequeue" + i.ToString (), i, queue.Dequeue ());
+ Assert.AreEqual (i, queue.Peek (), "Peek" + i.ToString ());
+ Assert.AreEqual (i, queue.Dequeue (), "Dequeue" + i.ToString ());
}
- AssertEquals ("Count-2", 1, queue.Count);
- AssertEquals ("411", 411, queue.Dequeue ());
+ Assert.AreEqual (1, queue.Count, "Count-2");
+ Assert.AreEqual (411, queue.Dequeue (), "411");
}
[Test]
queue.TrimToSize ();
queue.Enqueue (411);
- AssertEquals ("Count-1", 32, queue.Count);
- AssertEquals ("0", 0, queue.Dequeue ());
+ Assert.AreEqual (32, queue.Count, "Count-1");
+ Assert.AreEqual (0, queue.Dequeue (), "0");
}
}
}