public void ADisposableWhichThrowExceptionsWhenDisposed(Type feature, ITestResultMessage[] results) { "Given a step with three disposables which throw exceptions when disposed" .f(() => feature = typeof(StepWithThreeBadDisposables)); "When running the scenario" .f(() => results = this.Run<ITestResultMessage>(feature)); "Then the there should be at least two results" .f(() => results.Length.Should().BeGreaterOrEqualTo(2)); "And the first n-1 results should be passes" .f(() => results.Reverse().Skip(1).Should().ContainItemsAssignableTo<ITestPassed>()); "And the last result should be a failure" .f(() => results.Reverse().First().Should().BeAssignableTo<ITestFailed>()); "And the disposables should be disposed in reverse order" .f(() => typeof(ObjectDisposalFeature).GetTestEvents() .Should().Equal("disposed3", "disposed2", "disposed1")); }
public void ManyDisposablesInASingleStep(Type feature, ITestResultMessage[] results) { "Given {0}" .f(() => { }); "When running the scenario" .f(() => results = this.Run<ITestResultMessage>(feature)); "And there should be no failures" .f(() => results.Should().ContainItemsAssignableTo<ITestPassed>()); #if !V2 "And all but the last result should not be generated by a teardown" .f(() => results.Reverse().Skip(1).Should().NotContain( result => result.Test.DisplayName.IndexOf("(Teardown)", StringComparison.OrdinalIgnoreCase) >= 0)); "And the last result should be generated by a teardown" .f(() => results.Last().Test.DisplayName.Should().Contain("(Teardown)")); #endif "And the disposables should each have been disposed in reverse order" .f(() => typeof(ObjectDisposalFeature).GetTestEvents() .Should().Equal("disposed3", "disposed2", "disposed1")); }
public void DisposablesWhichCreateNewDisposablesWhenDisposed( Type feature, ITestResultMessage[] results) { ("Given a step with disposables which, when disposed," + "throw an exception and add more disposables which throw an exception when disposed") .f(() => feature = typeof(StepWithThreeRecursiveBadDisposables)); "When running the scenario" .f(() => results = this.Run<ITestResultMessage>(feature)); "Then the results should not be empty" .f(() => results.Should().NotBeEmpty()); "And the first n-2 results should not be failures" .f(() => results.Reverse().Skip(2).Should().NotContain(result => result is ITestFailed)); "And the last 2 results should be failures" .f(() => results.Reverse().Take(2).Should().ContainItemsAssignableTo<ITestFailed>()); "And the disposables should be disposed in reverse order" .f(() => typeof(ObjectDisposalFeature).GetTestEvents() .Should().Equal("disposed3", "disposed2", "disposed1")); }