Skip to content

Instantly share code, notes, and snippets.

public class CustomConvention : Convention
{
public CustomConvention()
{
Classes
.NameEndsWith("Tests");
Cases
.Where(method => method.IsVoid());
//Matt Howells's Shuffler from http://stackoverflow.com/a/110570
public static void Shuffle<T>(this T[] array, Random random)
{
int n = array.Length;
while (n > 1)
{
int k = random.Next(n--);
T temp = array[n];
array[n] = array[k];
array[k] = temp;
//Jon Skeet's Bubble Sort from http://stackoverflow.com/a/1595310
public void BubbleSort<T>(IList<T> list, IComparer<T> comparer)
{
bool stillGoing = true;
while (stillGoing)
{
stillGoing = false;
for (int i = 0; i < list.Length-1; i++)
{
T x = list[i];
Random rnd=new Random();
string[] shuffled = array.OrderBy(x => rnd.Next()).ToArray();
class SampleTestClass : IDisposable
{
bool disposed;
public SampleTestClass()
{
WhereAmI();
}
public void Pass()
try
{
method.Invoke(instance, null);
}
catch (TargetInvocationException ex)
{
throw new PreservedException(ex.InnerException);
}
ExceptionList DoSomething()
{
// Do the actual work here...
// Return an empty list of exceptions
// to indicate success.
return new ExceptionList();
}
object instance;
var constructionExceptions = Construct(testClass, out instance);
if (constructionExceptions.Any())
{
foreach (var @case in cases)
@case.Exceptions.Add(constructionExceptions);
}
else
{
ExceptionList exceptions = new ExceptionList();
try
{
method.Invoke(instance, null);
}
catch (TargetInvocationException ex)
{
exceptions.Add(ex.InnerException);
}
try
{
method.Invoke(instance, null);
}
catch (TargetInvocationException ex)
{
throw ex.InnerException;
}