当前位置: 首页>>代码示例>>C#>>正文


C# TestScheduler.AdvanceMinimal方法代码示例

本文整理汇总了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);
        }
开发者ID:gregjones60,项目名称:WorkoutWotch,代码行数:30,代码来源:ExerciseProgramsViewModelFixture.cs

示例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);
        }
开发者ID:gregjones60,项目名称:WorkoutWotch,代码行数:18,代码来源:ExerciseProgramsViewModelFixture.cs

示例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]);
        }
开发者ID:gregjones60,项目名称:WorkoutWotch,代码行数:20,代码来源:ExerciseProgramViewModelFixture.cs

示例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);
        }
开发者ID:gregjones60,项目名称:WorkoutWotch,代码行数:10,代码来源:ExerciseProgramViewModelFixture.cs

示例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);
        }
开发者ID:gregjones60,项目名称:WorkoutWotch,代码行数:24,代码来源:ExerciseProgramViewModelFixture.cs

示例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);
        }
开发者ID:gregjones60,项目名称:WorkoutWotch,代码行数:25,代码来源:ExerciseViewModelFixture.cs

示例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);
        }
开发者ID:gregjones60,项目名称:WorkoutWotch,代码行数:27,代码来源:ExerciseViewModelFixture.cs

示例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]);
        }
开发者ID:gregjones60,项目名称:WorkoutWotch,代码行数:36,代码来源:ExerciseProgramViewModelFixture.cs

示例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]);
        }
开发者ID:gregjones60,项目名称:WorkoutWotch,代码行数:55,代码来源:ExerciseProgramViewModelFixture.cs

示例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);
        }
开发者ID:gregjones60,项目名称:WorkoutWotch,代码行数:17,代码来源:ExerciseProgramsViewModelFixture.cs

示例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]);
        }
开发者ID:gregjones60,项目名称:WorkoutWotch,代码行数:41,代码来源:ExerciseProgramViewModelFixture.cs

示例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);
        }
开发者ID:gregjones60,项目名称:WorkoutWotch,代码行数:17,代码来源:ExerciseProgramsViewModelFixture.cs

示例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);
        }
开发者ID:gregjones60,项目名称:WorkoutWotch,代码行数:13,代码来源:ExerciseProgramsViewModelFixture.cs

示例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);
        }
开发者ID:gregjones60,项目名称:WorkoutWotch,代码行数:36,代码来源:ExerciseProgramsViewModelFixture.cs

示例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);
        }
开发者ID:gregjones60,项目名称:WorkoutWotch,代码行数:18,代码来源:ExerciseProgramsViewModelFixture.cs


注:本文中的TestScheduler.AdvanceMinimal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。