Exemplo n.º 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));
        }
Exemplo n.º 2
0
        public void Should_Not_Be_Running_When_Constructed()
        {
            // Given, When
            IncrementTimer sut = new IncrementTimerFixture();

            // Then
            sut.IsRunning.Should().BeFalse();
        }
Exemplo n.º 3
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();
        }