A number of new assertions classes have been added to MbUnit since the latest post on this topic. The new helper classes involve Arrays, collection, compiler, serialization, web...
ArrayAssert
This helper class contains method to compare arrays:
byte[] expected = ...; byte[] actual = ...; ArrayAssert.AreEqual(expected,actual);
The method compares the rank, the length and makes element-wize comparaison.
ColAssert
This class provides several methods to compare two ICollection instance:
ICollection
ICollection expected = ...; ICollection actual = ...; ColAssert.IsSynchronized(actual); ColAssert.AreCountEqual(expected,actual); ColAssert.AreEqual(expected,actual);
The class also provides method to test the collection count, syncroot, synchronization, etc...
SerialAssert
This class contains various methods to test the "serializability" of objects.
SerialAssert.IsXmlSerializable(typeof(MyClass));
WebAssert
This class contains assertions on the properties of web control and web pages.
CompilerAssert
This class contains assertions to check that snippets are compilable:
String source = ...; // C# code to compile // verify that source compiles CompilerAssert.Compiles(CompilerAssert.CSharpCompiler, source);
What about your assertions ?
There is also a CodeSmith template that can let you build "strongly-typed" assertion classes out of existing types. See in the templates directory.
Page rendered at Thursday, July 24, 2008 5:10:21 AM UTC
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.