Skip to content
This repository has been archived by the owner on Jun 12, 2021. It is now read-only.

Commit

Permalink
added ObjectDisposalFeature.RegisteringManyDisposableObjectsInASingle…
Browse files Browse the repository at this point in the history
…StepWithATimeout

closes #135
  • Loading branch information
adamralph committed Mar 3, 2014
1 parent 91c3d32 commit 0733dd4
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions src/test/Xbehave.Features.Net40/ObjectDisposalFeature.cs
Expand Up @@ -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;
Expand Down Expand Up @@ -48,6 +49,29 @@ public static void RegisteringManyDisposableObjectsInASingleStep()
.And(() => DisposableObjectsShouldEachHaveBeenDisposedOnceInReverseOrder());
}

[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()
{
Expand Down Expand Up @@ -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
{
Expand Down

0 comments on commit 0733dd4

Please sign in to comment.