コード例 #1
0
        public void AdvanceTo_argument_is_absolute_time_value_not_relative()
        {
            var clock = new Clock();

            clock.AdvanceTo(1);

            clock.AdvanceTo(10);
            Assert.Equal(10, clock.Time);
        }
コード例 #2
0
        public void AdvanceTo_changes_time_to_specified_value()
        {
            var clock = new Clock();

            clock.AdvanceTo(10);
            Assert.Equal(10, clock.Time);
        }
コード例 #3
0
        public void CreateCompletingTask_task_completes_successfully_when_clock_reaches_later_time()
        {
            var clock = new Clock();
            var task  = clock.TaskFactory.CreateCompletingTask(1);

            clock.AdvanceTo(10);

            Assert.True(task.IsCompletedSuccessfully);
        }
コード例 #4
0
        public void CreateFaultingTask_task_faults_when_clock_reaches_later_time()
        {
            var clock = new Clock();
            var task  = clock.TaskFactory.CreateFaultingTask(1, new Exception("bad"));

            clock.AdvanceTo(10);

            Assert.True(task.IsCompleted);
            Assert.True(task.IsFaulted);
        }
コード例 #5
0
        public void CreateCompletingTask_task_completes_successfully_with_correct_result_when_clock_reaches_later_time()
        {
            var clock = new Clock();
            var task  = clock.TaskFactory.CreateCompletingTask(1, "42");

            clock.AdvanceTo(10);

            Assert.True(task.IsCompletedSuccessfully);
            Assert.Equal("42", task.Result);
        }
コード例 #6
0
        public void CreateFaultingTask_task_faults_with_correct_exception_when_clock_reaches_later_time()
        {
            var clock = new Clock();
            var task  = clock.TaskFactory.CreateFaultingTask(1, new Exception("bad"));

            clock.AdvanceTo(10);

            var exception = Assert.Throws <Exception>(() => task.GetAwaiter().GetResult());

            Assert.Equal("bad", exception.Message);
        }