public void AsyncMethodsCanBeIntercepted() { using (var kernel = this.CreateDefaultInterceptionKernel()) { BeforeAfterCallOrderInterceptor.Reset(); kernel.Bind <AsyncService>().ToSelf().Intercept().With <BeforeAfterCallOrderInterceptor>(); var service = kernel.Get <AsyncService>(); var task = service.DoAsync(); task.Wait(); BeforeAfterCallOrderInterceptor.Order.Should().Be("Before_Action_AfterCompleted_"); } }
public void AsyncMethodsWithReturnValue_InterceptorsCanChangeTheResult() { using (var kernel = this.CreateDefaultInterceptionKernel()) { BeforeAfterCallOrderInterceptor.Reset(); kernel.Bind <AsyncService>().ToSelf().Intercept().With <IncreaseResultInterceptor>(); var service = kernel.Get <AsyncService>(); var task = service.DoAsyncInt(); task.Wait(); BeforeAfterCallOrderInterceptor.Order.Should().Be("Before_Action_AfterCompleted_"); task.Result.Should().Be(43); } }