Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

added ObjectDisposalFeature.RegisteringManyDisposableObjectsInASingleSte... #137

Merged
merged 1 commit into from

1 participant

@adamralph
Owner

...pWithATimeout

closes #135

@adamralph adamralph merged commit 8255437 into from
@adamralph adamralph deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 3, 2014
  1. @adamralph
This page is out of date. Refresh to see the latest.
Showing with 52 additions and 0 deletions.
  1. +52 −0 src/test/Xbehave.Features.Net40/ObjectDisposalFeature.cs
View
52 src/test/Xbehave.Features.Net40/ObjectDisposalFeature.cs
@@ -9,6 +9,7 @@ namespace Xbehave.Test.Acceptance
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
+ using System.Threading;
using System.Threading.Tasks;
using FluentAssertions;
using Xbehave.Test.Acceptance.Infrastructure;
@@ -49,6 +50,29 @@ public static void RegisteringManyDisposableObjectsInASingleStep()
}
[Scenario]
+ public static void RegisteringManyDisposableObjectsInASingleStepWithATimeout()
+ {
+ var feature = default(Type);
+ var results = default(MethodResult[]);
+
+ "Given a step which registers many disposable objects followed by a step which uses the objects"
+ .Given(() => feature = typeof(SingleStepWithATimeout));
+
+ "When running the scenario"
+ .When(() => results = TestRunner.Run(feature).ToArray())
+ .Teardown(Disposable.ClearRecordedEvents);
+
+ "Then there should be no failures"
+ .Then(() => results.Should().NotContain(result => result is FailedResult));
+
+ "And some disposable objects should have been created"
+ .And(() => SomeDisposableObjectsShouldHaveBeenCreated());
+
+ "And the disposable objects should each have been disposed once in reverse order"
+ .And(() => DisposableObjectsShouldEachHaveBeenDisposedOnceInReverseOrder());
+ }
+
+ [Scenario]
public static void RegisteringDisposableObjectWhichThrowExceptionsWhenDisposed()
{
var feature = default(Type);
@@ -288,6 +312,34 @@ public static void Scenario()
});
}
}
+
+ private static class SingleStepWithATimeout
+ {
+ [Scenario]
+ public static void Scenario()
+ {
+ var disposable0 = default(Disposable);
+ var disposable1 = default(Disposable);
+ var disposable2 = default(Disposable);
+
+ "Given some disposables"
+ .Given(c =>
+ {
+ disposable0 = new Disposable().Using(c);
+ disposable1 = new Disposable().Using(c);
+ disposable2 = new Disposable().Using(c);
+ })
+ .WithTimeout(Timeout.Infinite);
+
+ "When using the disposables"
+ .When(() =>
+ {
+ disposable0.Use();
+ disposable1.Use();
+ disposable2.Use();
+ });
+ }
+ }
private static class SingleStepWithBadDisposables
{
Something went wrong with that request. Please try again.