Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

42 lines (36 sloc) 1.29 kB
using System;
using Fixie.Conventions;
namespace Fixie.Behaviors
{
public class CreateInstancePerCase : TypeBehavior
{
readonly Func<Type, object> construct;
public CreateInstancePerCase(Func<Type, object> construct)
{
this.construct = construct;
}
public void Execute(Type testClass, Convention convention, Case[] cases)
{
foreach (var @case in cases)
{
var exceptions = @case.Exceptions;
try
{
var instance = construct(testClass);
var fixture = new Fixture(testClass, instance, convention.CaseExecution.Behavior, new[] { @case });
convention.InstanceExecution.Behavior.Execute(fixture);
Lifecycle.Dispose(instance);
}
catch (PreservedException preservedException)
{
var constructionException = preservedException.OriginalException;
exceptions.Add(constructionException);
}
catch (Exception constructionException)
{
exceptions.Add(constructionException);
}
}
}
}
}
Jump to Line
Something went wrong with that request. Please try again.