public void CanMakeAsync() { var instance = new LongWait(); var interceptor = new DispatchProxyInterceptor(); var proxy = interceptor.Intercept(instance, typeof(ILongWait), new AsyncInterceptionHandler()) as ILongWait; var timer = Stopwatch.StartNew(); proxy.DoLongOperation(); Assert.True(timer.Elapsed < TimeSpan.FromSeconds(5)); }
public void CanEnforceTimeout() { var instance = new LongWait(); var interceptor = new InterfaceInterceptor(); var handler = new TimeoutInterceptionHandler(3); var proxy = this.InstanceInterception(interceptor, instance, handler) as ILongWait; Assert.Throws <TimeoutException>(() => proxy.DoLongOperation()); }
public void CanDoCallback() { var called = false; var instance = new LongWait(); var interceptor = new InterfaceInterceptor(); var handler = new CallbackInterceptionHandler(() => called = true); var proxy = this.InstanceInterception(interceptor, instance, handler) as ILongWait; proxy.DoLongOperation(); Assert.True(called); }