Skip to content

Commit

Permalink
Respond to feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenaw committed Oct 31, 2023
1 parent 5f9f316 commit ec1f4d4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public void InstancePerTestCaseWithDispose()
var fixture = TestBuilder.MakeFixture(typeof(InstancePerTestCaseWithDisposeTestCase));

ITestResult result = TestBuilder.RunTest(fixture);
Assert.That(InstancePerTestCaseWithDisposeTestCase.DisposeCount, Is.EqualTo(2));
Assert.That(InstancePerTestCaseWithDisposeTestCase.DisposeCount, Is.EqualTo(fixture.TestCaseCount));
Assert.That(result.ResultState.Status, Is.EqualTo(TestStatus.Passed));
}

Expand All @@ -219,7 +219,7 @@ public void InstancePerTestCaseWithAsyncDispose()
var fixture = TestBuilder.MakeFixture(typeof(InstancePerTestCaseWithAsyncDisposeTestCase));

ITestResult result = TestBuilder.RunTest(fixture);
Assert.That(InstancePerTestCaseWithAsyncDisposeTestCase.DisposeCount, Is.EqualTo(2));
Assert.That(InstancePerTestCaseWithAsyncDisposeTestCase.DisposeCount, Is.EqualTo(fixture.TestCaseCount));
Assert.That(result.ResultState.Status, Is.EqualTo(TestStatus.Passed));
}

Expand Down
14 changes: 10 additions & 4 deletions src/NUnitFramework/tests/Attributes/OneTimeSetUpTearDownTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -378,17 +378,23 @@ public void AsyncDisposeCalledOnceWhenFixtureImplementsIAsyncDisposable()
{
var fixture = new AsyncDisposableFixture();
TestBuilder.RunTestFixture(fixture);

var expected = new[] { nameof(AsyncDisposableFixture.OneTimeSetUp), nameof(AsyncDisposableFixture.OneTimeTearDown), nameof(AsyncDisposableFixture.DisposeAsync) };

Assert.That(fixture.DisposeCalled, Is.EqualTo(1));
Assert.That(fixture.Actions, Is.EqualTo(new object[] { "OneTimeSetUp", "OneTimeTearDown", "DisposeAsync" }));
Assert.That(fixture.Actions, Is.EqualTo(expected));
}

[Test]
public void AsyncDisposeCalledOnceWhenFixtureImplementsIAsyncDisposableThroughInheritance()
{
var fixture = new InheritedAsyncDisposableFixture();
TestBuilder.RunTestFixture(fixture);

var expected = new[] { nameof(AsyncDisposableFixture.OneTimeSetUp), nameof(AsyncDisposableFixture.OneTimeTearDown), nameof(AsyncDisposableFixture.DisposeAsync) };

Assert.That(fixture.DisposeCalled, Is.EqualTo(1));
Assert.That(fixture.Actions, Is.EqualTo(new object[] { "OneTimeSetUp", "OneTimeTearDown", "DisposeAsync" }));
Assert.That(fixture.Actions, Is.EqualTo(expected));
}

[Test]
Expand All @@ -397,8 +403,8 @@ public void AsyncDisposePrioritizedWhenSyncAndAsyncDispose()
var fixture = new AsyncAndSyncDisposableFixture();
TestBuilder.RunTestFixture(fixture);
Assert.That(fixture.DisposeCalled, Is.EqualTo(1));
Assert.That(fixture.Actions, Does.Contain("DisposeAsync"));
Assert.That(fixture.Actions, Does.Not.Contain("Dispose"));
Assert.That(fixture.Actions, Does.Contain(nameof(IAsyncDisposable.DisposeAsync)));
Assert.That(fixture.Actions, Does.Not.Contain(nameof(IDisposable.Dispose)));
}
}

Expand Down

0 comments on commit ec1f4d4

Please sign in to comment.