Esempio n. 1
0
        public void Should_Divide_TimeSpan_By_Partition(int partition, TimeSpan duration)
        {
            // Given
            DivisibleTimer sut = new DivisibleTimerFixture();

            // When
            sut.Start(partition, duration);

            // Then
            sut.IntervalTime.Should().Be(TimeSpan.FromTicks(Math.DivRem(duration.Ticks, partition, out var remainder)));
        }
Esempio n. 2
0
        public void Should_Run_Correct_Partition_Count()
        {
            // Given
            int            count         = 1;
            var            testScheduler = new TestScheduler();
            DivisibleTimer sut           =
                new DivisibleTimerFixture().WithProvider(new SchedulerProviderFixture().WithTestScheduler(testScheduler));

            sut.Interval.ObserveOn(testScheduler).Subscribe(_ => count++);

            // When
            sut.Start(4, TimeSpan.FromHours(1));
            testScheduler.AdvanceBy(TimeSpan.FromMinutes(30).Ticks);

            // Then
            count.Should().Be(4);
        }