Exemple #1
0
                private void singlePeriodShouldBeStoredAndReterned()
                {
                    var period = MIDDAY.NewPeriod().Active();
                    var merged = timeTableSUT.AddPeriod(period);

                    Assert.AreEqual(period, merged);
                    CollectionAssert.AreEquivalent(new[] { merged }, periodStorage.GetAll());
                }
Exemple #2
0
                public void twoCloseActivePeriodShouldBeMerged()
                {
                    var period1 = MIDDAY.NewPeriod().Active();
                    var period2 = period1.NewPeriodAfter(LESS_THAN_IDLE_TIMEOUT).Active();

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

                    var periodMerged = new ActivePeriod(period1.Start, period2.End);

                    Assert.AreEqual(periodMerged, periodStorage.GetAll().First());
                    CollectionAssert.AreEquivalent(new[] { periodMerged }, periodStorage.GetAll());
                }
Exemple #3
0
                public void twoDistantIdlePeriodShouldNotBeMerged()
                {
                    var period1 = MIDDAY.NewPeriod().Active();
                    var period2 = period1.NewPeriodAfter().Idle();
                    var period3 = period2.NewPeriodAfter(MORE_THAN_IDLE_TIMEOUT).Idle();

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

                    var periodMerged = new IdlePeriod(period2.Start, period3.End);

                    CollectionAssert.AreEquivalent(new ActivityPeriod[] { period1, period2, period3 }, periodStorage.GetAll());
                }
Exemple #4
0
                private void twoCloseIdlePeriodShouldBeMerged(TimeSpan periodBetweenIdle)
                {
                    var period1 = MIDDAY.NewPeriod().Active();
                    var period2 = period1.NewPeriodAfter().Idle();
                    var period3 = period2.NewPeriodAfter(periodBetweenIdle).Idle();

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

                    var periodMerged = new IdlePeriod(period2.Start, period3.End);

                    CollectionAssert.AreEquivalent(new ActivityPeriod[] { period1, periodMerged }, periodStorage.GetAll());
                }
Exemple #5
0
                public void twoCloseIdlePeriodEnclosingActivePeriodShouldNotBeMerged()
                {
                    var period1a = MIDDAY.NewPeriod().Active();
                    var period2i = period1a.NewPeriodAfter().Length(MORE_THAN_IDLE_TIMEOUT).Idle();
                    var period3a = period2i.NewPeriodAfter().Active();
                    var peroid4i = period3a.NewPeriodAfter().Idle();

                    timeTableSUT.AddPeriod(period1a);
                    timeTableSUT.AddPeriod(period2i);
                    timeTableSUT.AddPeriod(period3a);
                    timeTableSUT.AddPeriod(peroid4i);

                    CollectionAssert.AreEquivalent(periodStorage.GetAll(),
                                                   new ActivityPeriod[] { period1a, period2i, period3a, peroid4i });
                }
Exemple #6
0
                public void twoCloseActivePeriodEnclosingIdlePeriodsShouldBeMerged()
                {
                    var period0i = MIDDAY.NewPeriod().Idle();
                    var period1a = period0i.NewPeriodAfter().Active();
                    var period2i = period1a.NewPeriodAfter().Idle();
                    var period3i = period2i.NewPeriodAfter().Idle();
                    var period4a = period3i.NewPeriodAfter().Active();

                    timeTableSUT.AddPeriod(period0i);
                    timeTableSUT.AddPeriod(period1a);
                    timeTableSUT.AddPeriod(period2i);
                    timeTableSUT.AddPeriod(period3i);
                    timeTableSUT.AddPeriod(period4a);

                    var mergedPeriod = new ActivePeriod(period1a.Start, period4a.End);

                    CollectionAssert.AreEquivalent(periodStorage.GetAll(), new ActivityPeriod[] { period0i, mergedPeriod });
                }
Exemple #7
0
                public void mergingActivePeriodsShouldNotDeletePartialIdlePeriods()
                {
                    var period0i = MIDDAY.NewPeriod().Idle();
                    var period1a = period0i.NewPeriodAfter(-1.ms()).Active();
                    var period2i = period1a.NewPeriodAfter().Idle();
                    var period3a = period2i.NewPeriodAfter().Active();
                    var period4i = period3a.NewPeriodAfter(-1.ms()).Idle();

                    timeTableSUT.AddPeriod(period0i);
                    timeTableSUT.AddPeriod(period1a);
                    timeTableSUT.AddPeriod(period2i);
                    timeTableSUT.AddPeriod(period3a);
                    timeTableSUT.AddPeriod(period4i);

                    var mergedPeriod = new ActivePeriod(period1a.Start, period3a.End);

                    CollectionAssert.AreEquivalent(periodStorage.GetAll(), new ActivityPeriod[] { period0i, mergedPeriod, period4i });
                }