示例#1
0
        public void Should_Resume_After_Stopped()
        {
            // Given
            var            testScheduler     = new TestScheduler();
            var            schedulerProvider = new SchedulerProviderFixture().WithTestScheduler(testScheduler);
            IncrementTimer sut   = new IncrementTimerFixture().WithProvider(schedulerProvider);
            var            timer = TimeSpan.Zero;

            sut.Subscribe(x =>
            {
                timer = x;
            });

            sut.Start();
            testScheduler.AdvanceByMs(InitialMilliseconds);
            sut.Stop();
            testScheduler.AdvanceByMs(OneThousandMilliseconds);

            // When
            sut.Start();
            testScheduler.AdvanceByMs(OneThousandMilliseconds);

            // Then
            timer.Should().Be(TimeSpan.FromSeconds(2));
        }
示例#2
0
        public void Should_Be_Running_When_Started()
        {
            // Given
            var testScheduler = new TestScheduler();
            SchedulerProvider schedulerProvider = new SchedulerProviderFixture().WithTestScheduler(testScheduler);
            IncrementTimer    sut = new IncrementTimerFixture().WithProvider(schedulerProvider);

            // When
            sut.Start(TimeSpan.FromMinutes(25));
            testScheduler.AdvanceByMs(InitialMilliseconds);

            // Then
            sut.IsRunning.Should().BeTrue();
        }