Example #1
0
                public void closeActiveAndIdlePeriodShouldNotBeMerged()
                {
                    var period1 = PeriodBuilder.New(MIDDAY).Active();
                    var period2 = PeriodBuilder.NewAfter(period1, LESS_THAN_IDLE_TIMEOUT).Idle();

                    timeTableSUT.AddPeriod(period1);
                    timeTableSUT.AddPeriod(period2);

                    CollectionAssert.AreEquivalent(periodStorage.GetAll(), new ActivityPeriod[] { period2, period1 });
                }
Example #2
0
                public void twoDistantActivePeriodShouldNotBeMerged()
                {
                    var period1 = PeriodBuilder.New(MIDDAY).Active();
                    var period2 = PeriodBuilder.NewAfter(period1, MORE_THAN_IDLE_TIMEOUT).Active();

                    var returned1 = timeTableSUT.AddPeriod(period1);
                    var returned2 = timeTableSUT.AddPeriod(period2);

                    Assert.AreEqual(period1, returned1);
                    Assert.AreEqual(period2, returned2);
                    CollectionAssert.AreEquivalent(periodStorage.GetAll(), new[] { period2, period1 });
                }
Example #3
0
                public void shouldNotifyWhenBeforeActiveThereIsLongIdlePeriod()
                {
                    // arrange
                    var idlePeriodLength = IDLE_TIMEOUT + 2.secs();
                    var periodIdleLong   = PeriodBuilder.New(MIDDAY).Length(idlePeriodLength).Idle();
                    var periodActive     = PeriodBuilder.NewAfter(periodIdleLong).Length(1.secs()).Active();

                    // act
                    timeTableSUT.PeriodPassed(periodIdleLong);
                    timeTableSUT.PeriodPassed(periodActive);

                    // assert
                    A.CallTo(() => listenerActivityListnerMock.NotifyActiveAfterBreak(idlePeriodLength))
                    .MustHaveHappened(Repeated.Exactly.Once);
                }
Example #4
0
 public static PeriodBuilder NewPeriodAfter(this ActivityPeriod activityPeriod, TimeSpan gap = default(TimeSpan))
 {
     return(PeriodBuilder.NewAfter(activityPeriod, gap));
 }