Add disposal of theory data.
This commit is contained in:
Родитель
e14343843e
Коммит
5cabbf3e32
|
@ -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]
|
||||
|
|
Загрузка…
Ссылка в новой задаче