Example #1
0
        public void run_to_completion_within_the_time()
        {
            var timeout = new JobTimeout(5.Seconds());
            var job = new FakeJob(1.Seconds());

            var task = timeout.Execute(job);
            task.Wait();

            task.IsCanceled.ShouldBeFalse();
            task.IsFaulted.ShouldBeFalse();
            task.Exception.ShouldBeNull();

            job.Finished.ShouldBeTrue();
        }
Example #2
0
        public void run_over_the_allowed_time()
        {
            var timeout = new JobTimeout(1.Seconds());
            var job = new FakeJob(10.Seconds());

            var task = timeout.Execute(job);

            Exception<AggregateException>.ShouldBeThrownBy(() => {
                task.Wait();
            });

            task.Exception.InnerException.ShouldBeOfType<TimeoutException>();
            job.Finished.ShouldBeFalse();
        }