Introduction

#TestsEx (Sharp Tests Extensions) is a set of extensible extensions to work with various unit test frameworks (NUnit, xUnit, MsTests, MbUnit). The main target is write short assertions where the Visual Studio IDE intellisense is your guide.

Assertions

The entry point of each assertion is the method Should() or its override Should(string) where the parameter is the title of the assertion (the message in MsTests terminology). After Should(). the intellisense become "your friend".

In general, each assertion allow negation (Should().Not.) and chain through .And..
Negation and .And. chain are available only where it has sense.

Where the assertion imply a cast, the additional property And.ValueOf. is available to begin a new assertion based on one of the properties of casted original actual value (available in Object instance assertion for example).

Extensibility

#TestsEx is so easy to extend that, the mayor part of its assertions, was implemented using extension points.
For Example:
	public static class ClassConstraintsExtensions
	{
		public static IAndConstraints<IClassConstraints> InstanceOf<T>(this IClassBeConstraints constraint)
		{
			constraint.AssertionInfo.AssertUsing(new Assertion<object, object>(Properties.Resources.PredicateBeInstanceOf,
			                                                                   typeof (T),
			                                                                   a => a != null && typeof (T).IsInstanceOfType(a)));
			return ConstraintsHelper.AndChain(constraint.AssertionParent);
		}
	...
	}

Assertions Syntax

Lambda/LINQ based Assertions
Boolean
Object instance
Value type
Strings
IEnumerable<T>
Actions
System.Type
Static Assertions
Others Extensions

Appendix

How use Version1.0 with Visual Studio 2010

Last edited May 10, 2010 at 9:29 PM by fabiomaulo, version 4

Comments

No comments yet.