Inheritance: ISleepy
        public void SlowSleepMethod_WithoutFireAndForget_BlocksUntilCompletion()
        {
            var instance = new Sleepy();
            var proxy    = CommandInterceptor.CreateProxy <ISleepy>(instance);

            var stopwatch = Stopwatch.StartNew();

            proxy.SleepWithoutFireAndForget(500);
            stopwatch.Stop();

            Assert.True(stopwatch.Elapsed.TotalMilliseconds > 500);
            Assert.True(instance.IsCompleted);
        }
        public void SlowSleepMethod_FireAndForget_ReturnsImmediatelyButStillCompletes()
        {
            var instance = new Sleepy();
            var proxy    = CommandInterceptor.CreateProxy <ISleepy>(instance);

            var stopwatch = Stopwatch.StartNew();

            proxy.SleepWithFireAndForget(500);
            stopwatch.Stop();

            // Should have returned immediately; for sure before the sleep time.
            Assert.True(stopwatch.Elapsed.TotalMilliseconds < 400);
            Assert.False(instance.IsCompleted);

            Thread.Sleep(510);
            Assert.True(instance.IsCompleted);
        }
        public void SlowSleepMethod_WithoutFireAndForget_BlocksUntilCompletion()
        {
            var instance = new Sleepy();
            var proxy = CommandInterceptor.CreateProxy<ISleepy>(instance);

            var stopwatch = Stopwatch.StartNew();
            proxy.SleepWithoutFireAndForget(500);
            stopwatch.Stop();
            
            Assert.True(stopwatch.Elapsed.TotalMilliseconds > 500);
            Assert.True(instance.IsCompleted);
        }
        public void SlowSleepMethod_FireAndForget_ReturnsImmediatelyButStillCompletes()
        {
            var instance = new Sleepy();
            var proxy = CommandInterceptor.CreateProxy<ISleepy>(instance);

            var stopwatch = Stopwatch.StartNew();
            proxy.SleepWithFireAndForget(500);
            stopwatch.Stop();

            // Should have returned immediately; for sure before the sleep time.
            Assert.True(stopwatch.Elapsed.TotalMilliseconds < 400);
            Assert.False(instance.IsCompleted);

            Thread.Sleep(510);
            Assert.True(instance.IsCompleted);
        }