Esempio n. 1
0
 public void SetUp()
 {
     _runner1 = new StubbedTaskRunner();
     _runner2 = new StubbedTaskRunner();
     _runners = new ITaskRunner[]
     {
         _runner1,
         _runner2
     };
     _sut = new TasksRunner(
         new ReadOnlyCollection <ITaskRunner>(
             _runners));
 }
Esempio n. 2
0
        public void RunCompletesAfterTimeoutEvenIfTaskNeverEnds()
        {
            var runner      = new NeverEndingTaskRunner();
            var tasksRunner = new TasksRunner(new List <ITaskRunner> {
                runner
            });
            var sut         = new BlockingTaskHost(tasksRunner, TimeSpan.FromSeconds(0.5));
            var tokenSource = new CancellationTokenSource();

            using (new Timer(
                       state => tokenSource.Cancel(),
                       null,
                       TimeSpan.FromSeconds(0.5),
                       TimeSpan.FromTicks(-1)))
            {
                sut.Run(tokenSource.Token);
            }
            Assert.That(runner.CallCount, Is.EqualTo(1));
        }
Esempio n. 3
0
        public void RunHasExpectedBehavior()
        {
            var runner      = new StubbedTaskRunner();
            var tasksRunner = new TasksRunner(new List <ITaskRunner> {
                runner
            });
            var sut         = new BlockingTaskHost(tasksRunner, TimeSpan.Zero);
            var tokenSource = new CancellationTokenSource();

            using (new Timer(
                       state => tokenSource.Cancel(),
                       null,
                       TimeSpan.FromSeconds(0.5),
                       TimeSpan.FromTicks(-1)))
            {
                sut.Run(tokenSource.Token);
            }
            Assert.That(runner.CallCount, Is.EqualTo(1));
        }