This commit is contained in:
Brad Wilson 2014-03-22 14:37:12 -07:00
Родитель e14343843e
Коммит 5cabbf3e32
2 изменённых файлов: 24 добавлений и 1 удалений

Просмотреть файл

@ -154,7 +154,12 @@ namespace Xunit.Sdk
}
/// <inheritdoc/>
public void Dispose() { }
public void Dispose()
{
if (Arguments != null)
foreach (var disposable in Arguments.OfType<IDisposable>())
disposable.Dispose();
}
/// <summary>
/// Gets the <see cref="BeforeAfterTestAttribute"/> instances for a test method.

Просмотреть файл

@ -46,6 +46,24 @@ public class XunitTestCaseTests
Assert.Equal("Skip Reason", testCase.SkipReason);
}
[Fact]
public void DisposesArguments()
{
var disposable1 = Substitute.For<IDisposable>();
var disposable2 = Substitute.For<IDisposable>();
var testCollection = new XunitTestCollection();
var fact = Mocks.FactAttribute();
var method = Mocks.MethodInfo();
var type = Mocks.TypeInfo(methods: new[] { method });
var assmInfo = Mocks.AssemblyInfo(types: new[] { type });
var testCase = new XunitTestCase(testCollection, assmInfo, type, method, fact, new[] { disposable1, disposable2 });
testCase.Dispose();
disposable1.Received(1).Dispose();
disposable2.Received(1).Dispose();
}
public class Traits : AcceptanceTest
{
[Fact]