Skip to content
Browse files

Change async behavior when there is no inner behavior

  • Loading branch information...
1 parent d32c0a4 commit c7014d7bf2603b063c7f2ec23e063e7d4b8b1378 @CoreyKaylor CoreyKaylor committed
View
14 src/FubuMVC.Core/Behaviors/AsyncContinueWithBehavior.cs
@@ -6,7 +6,7 @@ namespace FubuMVC.Core.Behaviors
{
public class AsyncContinueWithBehavior<T> : AsyncContinueWithBehavior where T : class
{
- public AsyncContinueWithBehavior(IFubuRequest fubuRequest, IActionBehavior inner) : base(fubuRequest, inner)
+ public AsyncContinueWithBehavior(IFubuRequest fubuRequest) : base(fubuRequest)
{
}
@@ -16,7 +16,7 @@ protected override void InnerInvoke(Action<IActionBehavior> behaviorAction)
task.ContinueWith(x =>
{
FubuRequest.Set(task.Result);
- behaviorAction(Inner);
+ behaviorAction(InsideBehavior);
}, TaskContinuationOptions.NotOnFaulted | TaskContinuationOptions.AttachedToParent);
}
}
@@ -24,16 +24,14 @@ protected override void InnerInvoke(Action<IActionBehavior> behaviorAction)
public class AsyncContinueWithBehavior : IActionBehavior
{
private readonly IFubuRequest _fubuRequest;
- private readonly IActionBehavior _inner;
- public AsyncContinueWithBehavior(IFubuRequest fubuRequest, IActionBehavior inner)
+ public AsyncContinueWithBehavior(IFubuRequest fubuRequest)
{
_fubuRequest = fubuRequest;
- _inner = inner;
}
public IFubuRequest FubuRequest { get { return _fubuRequest; } }
- public IActionBehavior Inner { get { return _inner; } }
+ public IActionBehavior InsideBehavior { get; set; }
public void Invoke()
{
@@ -50,8 +48,8 @@ protected virtual void InnerInvoke(Action<IActionBehavior> behaviorAction)
var task = FubuRequest.Get<Task>();
task.ContinueWith(x =>
{
- if (Inner != null)
- behaviorAction(Inner);
+ if (InsideBehavior != null)
+ behaviorAction(InsideBehavior);
}, TaskContinuationOptions.AttachedToParent | TaskContinuationOptions.NotOnFaulted);
}
}
View
6 src/FubuMVC.Tests/Behaviors/AsyncContinueWithBehaviorTests.cs
@@ -22,6 +22,8 @@ protected override void beforeEach()
task.RunSynchronously();
MockFor<IFubuRequest>().Expect(x => x.Get<Task<Output>>()).Return(task);
+ var innerBehavior = MockFor<IActionBehavior>();
+ ClassUnderTest.InsideBehavior = innerBehavior;
ClassUnderTest.Invoke();
});
@@ -58,6 +60,8 @@ protected override void beforeEach()
});
MockFor<IFubuRequest>().Expect(x => x.Get<Task<Output>>()).Return(task);
+ var innerBehavior = MockFor<IActionBehavior>();
+ ClassUnderTest.InsideBehavior = innerBehavior;
typeof (AggregateException).ShouldBeThrownBy(task.Wait);
ClassUnderTest.Invoke();
@@ -115,6 +119,8 @@ protected override void beforeEach()
var task = Task.Factory.StartNew(() => { });
MockFor<IFubuRequest>().Expect(x => x.Get<Task>()).Return(task);
+ var innerBehavior = MockFor<IActionBehavior>();
+ ClassUnderTest.InsideBehavior = innerBehavior;
task.Wait();
ClassUnderTest.Invoke();

0 comments on commit c7014d7

Please sign in to comment.
Something went wrong with that request. Please try again.