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); }
public void AdvanceTo_changes_time_to_specified_value() { var clock = new Clock(); clock.AdvanceTo(10); Assert.Equal(10, clock.Time); }
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); }
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); }
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); }
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); }