本文整理汇总了C#中TestScheduler.AdvanceMinimal方法的典型用法代码示例。如果您正苦于以下问题:C# TestScheduler.AdvanceMinimal方法的具体用法?C# TestScheduler.AdvanceMinimal怎么用?C# TestScheduler.AdvanceMinimal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestScheduler
的用法示例。
在下文中一共展示了TestScheduler.AdvanceMinimal方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: parse_error_message_is_null_if_a_document_is_successfully_parsed_after_one_fails_to_parse
public void parse_error_message_is_null_if_a_document_is_successfully_parsed_after_one_fails_to_parse()
{
var badDocument = @"# First Program
## First Exercise
whatever!";
var goodDocument = "# First Program";
var documents = new Subject<string>();
var exerciseDocumentService = new ExerciseDocumentServiceMock();
var scheduler = new TestScheduler();
exerciseDocumentService
.When(x => x.ExerciseDocument)
.Return(documents);
var sut = new ExerciseProgramsViewModelBuilder()
.WithExerciseDocumentService(exerciseDocumentService)
.WithScheduler(scheduler)
.Build();
documents.OnNext(badDocument);
scheduler.AdvanceMinimal();
Assert.NotNull(sut.ParseErrorMessage);
documents.OnNext(goodDocument);
scheduler.AdvanceMinimal();
Assert.Null(sut.ParseErrorMessage);
}
示例2: parse_error_message_returns_appropriate_message_if_the_document_could_not_be_parsed
public void parse_error_message_returns_appropriate_message_if_the_document_could_not_be_parsed()
{
var document = @"# First Program
## First Exercise
whatever!";
var scheduler = new TestScheduler();
var sut = new ExerciseProgramsViewModelBuilder()
.WithCloudDocument(document)
.WithScheduler(scheduler)
.Build();
scheduler.AdvanceMinimal();
Assert.NotNull(sut.ParseErrorMessage);
Assert.Equal("Parsing failure: unexpected '#'; expected end of input (Line 3, Column 1); recently consumed: rogram\r\n\r\n", sut.ParseErrorMessage);
}
示例3: is_started_cycles_correctly_if_start_command_is_executed
public void is_started_cycles_correctly_if_start_command_is_executed()
{
var scheduler = new TestScheduler();
var sut = new ExerciseProgramViewModelBuilder()
.WithScheduler(scheduler)
.Build();
scheduler.AdvanceMinimal();
var isStarted = sut
.WhenAnyValue(x => x.IsStarted)
.CreateCollection();
sut.StartCommand.ExecuteAsync();
scheduler.AdvanceMinimal();
Assert.Equal(3, isStarted.Count);
Assert.False(isStarted[0]);
Assert.True(isStarted[1]);
Assert.False(isStarted[2]);
}
示例4: is_start_visible_is_true_by_default
public void is_start_visible_is_true_by_default()
{
var scheduler = new TestScheduler();
var sut = new ExerciseProgramViewModelBuilder()
.WithScheduler(scheduler)
.Build();
scheduler.AdvanceMinimal();
Assert.True(sut.IsStartVisible);
}
示例5: is_paused_cycles_correctly_if_pause_command_is_executed
public void is_paused_cycles_correctly_if_pause_command_is_executed()
{
var scheduler = new TestScheduler();
var sut = new ExerciseProgramViewModelBuilder()
.WithModel(new ExerciseProgramBuilder()
.WithExercise(new ExerciseBuilder()
.WithBeforeExerciseAction(
new WaitActionBuilder()
.WithDelayService(new DelayServiceBuilder().Build())
.WithDelay(TimeSpan.FromMinutes(1))
.Build())))
.WithScheduler(scheduler)
.Build();
Assert.False(sut.IsPaused);
sut.StartCommand.ExecuteAsync();
scheduler.AdvanceMinimal();
Assert.False(sut.IsPaused);
sut.PauseCommand.ExecuteAsync();
scheduler.AdvanceMinimal();
Assert.True(sut.IsPaused);
}
示例6: progress_time_span_reflects_any_progression_through_the_exercise
public void progress_time_span_reflects_any_progression_through_the_exercise()
{
var scheduler = new TestScheduler();
var model = new ExerciseBuilder()
.Build();
var executionContext = new ExecutionContext();
var sut = new ExerciseViewModelBuilder()
.WithSchedulerService(scheduler)
.WithExecutionContext(executionContext)
.WithModel(model)
.Build();
executionContext.SetCurrentExercise(model);
scheduler.AdvanceMinimal();
Assert.Equal(TimeSpan.Zero, sut.ProgressTimeSpan);
executionContext.AddProgress(TimeSpan.FromSeconds(3));
scheduler.AdvanceMinimal();
Assert.Equal(TimeSpan.FromSeconds(3), sut.ProgressTimeSpan);
executionContext.AddProgress(TimeSpan.FromSeconds(2));
scheduler.AdvanceMinimal();
Assert.Equal(TimeSpan.FromSeconds(5), sut.ProgressTimeSpan);
}
示例7: progress_is_calculated_based_on_duration_and_progress_time_span
public void progress_is_calculated_based_on_duration_and_progress_time_span(int durationInMs, int progressInMs, double expectedProgress)
{
var scheduler = new TestScheduler();
var action = new ActionMock(MockBehavior.Loose);
action
.When(x => x.Duration)
.Return(TimeSpan.FromMilliseconds(durationInMs));
var model = new ExerciseBuilder()
.WithBeforeExerciseAction(action)
.Build();
var executionContext = new ExecutionContext();
var sut = new ExerciseViewModelBuilder()
.WithSchedulerService(scheduler)
.WithExecutionContext(executionContext)
.WithModel(model)
.Build();
executionContext.SetCurrentExercise(model);
executionContext.AddProgress(TimeSpan.FromMilliseconds(progressInMs));
scheduler.AdvanceMinimal();
Assert.Equal(expectedProgress, sut.Progress);
}
示例8: skip_backwards_command_is_enabled_if_sufficient_progress_has_been_made_through_first_exercise
public void skip_backwards_command_is_enabled_if_sufficient_progress_has_been_made_through_first_exercise()
{
var scheduler = new TestScheduler();
var action = new ActionMock(MockBehavior.Loose);
action
.When(x => x.Execute(It.IsAny<ExecutionContext>()))
.Return<ExecutionContext>(
ec =>
{
ec.AddProgress(TimeSpan.FromSeconds(1));
ec.IsPaused = true;
return ec.WaitWhilePaused();
});
var sut = new ExerciseProgramViewModelBuilder()
.WithModel(new ExerciseProgramBuilder()
.WithExercise(new ExerciseBuilder()
.WithBeforeExerciseAction(action)))
.WithScheduler(scheduler)
.Build();
// TODO: technically, I should just check CanExecute(null) at the end, but without this subscription the RxCommand does not update CanExecute correctly
// try changing this once I'm using new RxCommand
var canExecute = sut
.SkipBackwardsCommand
.CanExecute
.CreateCollection();
sut.StartCommand.ExecuteAsync();
scheduler.AdvanceMinimal();
Assert.Equal(2, canExecute.Count);
Assert.False(canExecute[0]);
Assert.True(canExecute[1]);
}
示例9: TestScheduler
public void skip_backwards_command_restarts_the_execution_context_from_the_start_of_the_previous_exercise_if_the_current_exercise_if_only_recently_started()
{
var scheduler = new TestScheduler();
var action = new ActionMock();
action
.When(x => x.Duration)
.Return(TimeSpan.FromSeconds(10));
action
.When(x => x.Execute(It.IsAny<ExecutionContext>()))
.Return<ExecutionContext>(
ec =>
{
ec.AddProgress(TimeSpan.FromSeconds(0.5));
ec.IsPaused = true;
return ec.WaitWhilePaused();
});
var exercise1 = new ExerciseBuilder()
.WithName("Exercise 1")
.WithBeforeExerciseAction(action)
.Build();
var exercise2 = new ExerciseBuilder()
.WithName("Exercise 2")
.WithBeforeExerciseAction(action)
.Build();
var sut = new ExerciseProgramViewModelBuilder()
.WithModel(new ExerciseProgramBuilder()
.WithExercise(exercise1)
.WithExercise(exercise2))
.WithScheduler(scheduler)
.Build();
var progress = sut
.WhenAnyValue(x => x.ProgressTimeSpan)
.CreateCollection();
// start from the second exercise
sut.StartCommand.ExecuteAsync(exercise1.Duration);
scheduler.AdvanceMinimal();
sut.SkipBackwardsCommand.ExecuteAsync();
scheduler.AdvanceMinimal();
Assert.Equal(5, progress.Count);
Assert.Equal(TimeSpan.Zero, progress[0]);
Assert.Equal(TimeSpan.FromSeconds(10), progress[1]);
Assert.Equal(TimeSpan.FromSeconds(10.5), progress[2]);
Assert.Equal(TimeSpan.Zero, progress[3]);
Assert.Equal(TimeSpan.FromSeconds(10), progress[4]);
}
示例10: status_is_load_failed_if_the_document_fails_to_load_altogether
public void status_is_load_failed_if_the_document_fails_to_load_altogether()
{
var exerciseDocumentService = new ExerciseDocumentServiceMock();
var scheduler = new TestScheduler();
exerciseDocumentService
.When(x => x.ExerciseDocument)
.Return(Observable.Throw<string>(new InvalidOperationException()));
var sut = new ExerciseProgramsViewModelBuilder()
.WithExerciseDocumentService(exerciseDocumentService)
.WithScheduler(scheduler)
.Build();
scheduler.AdvanceMinimal();
Assert.Equal(ExerciseProgramsViewModelStatus.LoadFailed, sut.Status);
}
示例11: progress_is_updated_throughout_execution
public void progress_is_updated_throughout_execution()
{
var scheduler = new TestScheduler();
var action = new ActionMock(MockBehavior.Loose);
action
.When(x => x.Duration)
.Return(TimeSpan.FromMinutes(1));
action
.When(x => x.Execute(It.IsAny<ExecutionContext>()))
.Return<ExecutionContext>(
ec =>
{
ec.AddProgress(TimeSpan.FromSeconds(15));
ec.AddProgress(TimeSpan.FromSeconds(30));
ec.IsPaused = true;
return ec.WaitWhilePaused();
});
var sut = new ExerciseProgramViewModelBuilder()
.WithModel(new ExerciseProgramBuilder()
.WithExercise(new ExerciseBuilder()
.WithBeforeExerciseAction(action)))
.WithScheduler(scheduler)
.Build();
var progress = sut
.WhenAnyValue(x => x.Progress)
.CreateCollection();
sut.StartCommand.ExecuteAsync();
scheduler.AdvanceMinimal();
Assert.Equal(3, progress.Count);
Assert.Equal(0, progress[0]);
Assert.Equal(0.25, progress[1]);
Assert.Equal(0.75, progress[2]);
}
示例12: status_is_parse_failed_if_the_document_could_not_be_parsed
public void status_is_parse_failed_if_the_document_could_not_be_parsed()
{
var document = @"# First Program
## First Exercise
whatever!";
var scheduler = new TestScheduler();
var sut = new ExerciseProgramsViewModelBuilder()
.WithCloudDocument(document)
.WithScheduler(scheduler)
.Build();
scheduler.AdvanceMinimal();
Assert.Equal(ExerciseProgramsViewModelStatus.ParseFailed, sut.Status);
}
示例13: status_is_loaded_from_cloud_if_document_is_successfully_loaded_from_cloud
public void status_is_loaded_from_cloud_if_document_is_successfully_loaded_from_cloud()
{
var document = "# First Program";
var scheduler = new TestScheduler();
var sut = new ExerciseProgramsViewModelBuilder()
.WithCloudDocument(document)
.WithScheduler(scheduler)
.Build();
scheduler.AdvanceMinimal();
Assert.Equal(ExerciseProgramsViewModelStatus.LoadedFromService, sut.Status);
}
示例14: programs_is_populated_from_cache_whilst_document_from_cloud_loads
public void programs_is_populated_from_cache_whilst_document_from_cloud_loads()
{
var cacheDocument = "# First Program";
var cloudDocument = @"
# First Program
# Second Program";
var scheduler = new TestScheduler();
var exerciseDocumentService = new ExerciseDocumentServiceMock(MockBehavior.Loose);
exerciseDocumentService
.When(x => x.ExerciseDocument)
.Return(
Observable
.Return(cloudDocument)
.Delay(TimeSpan.FromSeconds(3), scheduler));
var sut = new ExerciseProgramsViewModelBuilder()
.WithExerciseDocumentService(exerciseDocumentService)
.WithCachedDocument(cacheDocument)
.WithScheduler(scheduler)
.Build();
scheduler.AdvanceMinimal();
Assert.NotNull(sut.Programs);
Assert.Equal(1, sut.Programs.Count);
scheduler.AdvanceBy(TimeSpan.FromSeconds(2));
Assert.NotNull(sut.Programs);
Assert.Equal(1, sut.Programs.Count);
scheduler.AdvanceBy(TimeSpan.FromSeconds(2));
Assert.NotNull(sut.Programs);
Assert.Equal(2, sut.Programs.Count);
}
示例15: programs_is_populated_from_cloud_if_cache_is_populated_and_cloud_is_populated
public void programs_is_populated_from_cloud_if_cache_is_populated_and_cloud_is_populated()
{
var cacheDocument = "# First Program";
var cloudDocument = @"
# First Program
# Second Program";
var scheduler = new TestScheduler();
var sut = new ExerciseProgramsViewModelBuilder()
.WithCloudDocument(cloudDocument)
.WithCachedDocument(cacheDocument)
.WithScheduler(scheduler)
.Build();
scheduler.AdvanceMinimal();
Assert.NotNull(sut.Programs);
Assert.Equal(2, sut.Programs.Count);
}