Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Exception handling during test class Disposal no longer relies on dep…

…recated uses of ExceptionList objects.
  • Loading branch information...
commit c9d8abce8cf662c0e394b4b80b76c33e8971a33c 1 parent b78f70c
@plioi plioi authored
View
11 src/Fixie/Behaviors/CreateInstancePerCase.cs
@@ -30,9 +30,14 @@ public void Execute(Type testClass, Convention convention, Case[] cases)
var fixture = new Fixture(testClass, instance, convention.CaseExecution.Behavior, new[] { @case });
convention.InstanceExecution.Behavior.Execute(fixture);
- var disposalExceptions = Lifecycle.Dispose(instance);
- if (disposalExceptions.Any())
- exceptions.Add(disposalExceptions);
+ try
+ {
+ Lifecycle.Dispose(instance);
+ }
+ catch (Exception disposalException)
+ {
+ exceptions.Add(disposalException);
+ }
}
}
}
View
9 src/Fixie/Behaviors/CreateInstancePerTestClass.cs
@@ -27,11 +27,14 @@ public void Execute(Type testClass, Convention convention, Case[] cases)
var fixture = new Fixture(testClass, instance, convention.CaseExecution.Behavior, cases);
convention.InstanceExecution.Behavior.Execute(fixture);
- var disposalExceptions = Lifecycle.Dispose(instance);
- if (disposalExceptions.Any())
+ try
+ {
+ Lifecycle.Dispose(instance);
+ }
+ catch (Exception disposalException)
{
foreach (var @case in cases)
- @case.Exceptions.Add(disposalExceptions);
+ @case.Exceptions.Add(disposalException);
}
}
}
View
19 src/Fixie/Behaviors/Lifecycle.cs
@@ -27,22 +27,11 @@ public static ExceptionList Construct(Type type, out object instance)
return exceptions;
}
- public static ExceptionList Dispose(object instance)
+ public static void Dispose(object instance)
{
- var exceptions = new ExceptionList();
-
- try
- {
- var disposable = instance as IDisposable;
- if (disposable != null)
- disposable.Dispose();
- }
- catch (Exception ex)
- {
- exceptions.Add(ex);
- }
-
- return exceptions;
+ var disposable = instance as IDisposable;
+ if (disposable != null)
+ disposable.Dispose();
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.