Exemplo n.º 1
0
        public void IsMomentTest()
        {
            var now   = ClockProxy.Clock.Now;
            var chain = new TimePeriodChain();

            chain.IsMoment.Should().Be.False();

            chain.Add(new TimeBlock(now));

            chain.Count.Should().Be(1);
            chain.HasStart.Should().Be.True();
            chain.HasEnd.Should().Be.True();
            chain.HasPeriod.Should().Be.True();
            chain.IsMoment.Should().Be.True();
            chain.IsAnytime.Should().Be.False();

            chain.Add(new TimeBlock(now.AddDays(1)));

            chain.Count.Should().Be(2);
            chain.HasStart.Should().Be.True();
            chain.HasEnd.Should().Be.True();
            chain.HasPeriod.Should().Be.True();
            chain.IsMoment.Should().Be.True();
            chain.IsAnytime.Should().Be.False();

            chain.Add(new TimeBlock(now, TimeSpan.FromDays(1)));

            chain.Count.Should().Be(3);
            chain.HasStart.Should().Be.True();
            chain.HasEnd.Should().Be.True();
            chain.HasPeriod.Should().Be.True();
            chain.IsMoment.Should().Be.False();
            chain.IsAnytime.Should().Be.False();
        }
Exemplo n.º 2
0
        // ----------------------------------------------------------------------
        public void TimePeriodChainSample()
        {
            TimePeriodChain timePeriods = new TimePeriodChain();

            DateTime now     = ClockProxy.Clock.Now;
            DateTime testDay = new DateTime(2010, 7, 23);

            // --- add ---
            timePeriods.Add(new TimeBlock(TimeTrim.Hour(testDay, 8), Duration.Hours(2)));
            timePeriods.Add(new TimeBlock(now, Duration.Hours(1, 30)));
            timePeriods.Add(new TimeBlock(now, Duration.Hour));
            Console.WriteLine("TimePeriodChain.Add(): " + timePeriods);
            // > TimePeriodChain.Add(): Count = 3; 23.07.2010 08:00:00 - 12:30:00 | 0.04:30
            foreach (ITimePeriod timePeriod in timePeriods)
            {
                Console.WriteLine("Item: " + timePeriod);
            }
            // > Item: 23.07.2010 08:00:00 - 10:00:00 | 02:00:00
            // > Item: 23.07.2010 10:00:00 - 11:30:00 | 01:30:00
            // > Item: 23.07.2010 11:30:00 - 12:30:00 | 01:00:00

            // --- insert ---
            timePeriods.Insert(2, new TimeBlock(now, Duration.Minutes(45)));
            Console.WriteLine("TimePeriodChain.Insert(): " + timePeriods);
            // > TimePeriodChain.Insert(): Count = 4; 23.07.2010 08:00:00 - 13:15:00 | 0.05:15
            foreach (ITimePeriod timePeriod in timePeriods)
            {
                Console.WriteLine("Item: " + timePeriod);
            }
            // > Item: 23.07.2010 08:00:00 - 10:00:00 | 02:00:00
            // > Item: 23.07.2010 10:00:00 - 11:30:00 | 01:30:00
            // > Item: 23.07.2010 11:30:00 - 12:15:00 | 00:45:00
            // > Item: 23.07.2010 12:15:00 - 13:15:00 | 01:00:00
        }         // TimePeriodChainSample
Exemplo n.º 3
0
        public void HasStartTest()
        {
            TimePeriodChain timePeriods = new TimePeriodChain();

            Assert.False(timePeriods.HasStart);

            timePeriods.Add(new TimeBlock(TimeSpec.MinPeriodDate, Duration.Hour));
            Assert.False(timePeriods.HasStart);

            timePeriods.Clear();
            timePeriods.Add(new TimeBlock(ClockProxy.Clock.Now, Duration.Hour));
            Assert.True(timePeriods.HasStart);
        }         // HasStartTest
Exemplo n.º 4
0
        public void IsAnytimeTest()
        {
            DateTime        now         = ClockProxy.Clock.Now;
            TimePeriodChain timePeriods = new TimePeriodChain();

            Assert.True(timePeriods.IsAnytime);

            timePeriods.Add(new TimeBlock(TimeSpec.MinPeriodDate, now));
            Assert.False(timePeriods.IsAnytime);

            timePeriods.Add(new TimeBlock(now, TimeSpec.MaxPeriodDate));
            Assert.True(timePeriods.IsAnytime);
        }         // IsAnytimeTest
Exemplo n.º 5
0
        public void IsAnyTimeTest() {
            var now = ClockProxy.Clock.Now;
            var chain = new TimePeriodChain();

            chain.IsAnytime.Should().Be.True();

            chain.Add(new TimeBlock(TimeSpec.MinPeriodTime, now));

            chain.IsAnytime.Should().Be.False();

            chain.Add(new TimeBlock(now, TimeSpec.MaxPeriodTime));

            chain.IsAnytime.Should().Be.True();
        }
Exemplo n.º 6
0
        public void HasEndTest()
        {
            DateTime        now         = ClockProxy.Clock.Now;
            TimePeriodChain timePeriods = new TimePeriodChain();

            Assert.False(timePeriods.HasEnd);

            timePeriods.Add(new TimeBlock(Duration.Hour, TimeSpec.MaxPeriodDate));
            Assert.False(timePeriods.HasEnd);

            timePeriods.Clear();
            timePeriods.Add(new TimeBlock(now, Duration.Hour));
            Assert.True(timePeriods.HasEnd);
        }         // HasEndTest
Exemplo n.º 7
0
        public void IsAnyTimeTest()
        {
            var now   = ClockProxy.Clock.Now;
            var chain = new TimePeriodChain();

            chain.IsAnytime.Should().Be.True();

            chain.Add(new TimeBlock(TimeSpec.MinPeriodTime, now));

            chain.IsAnytime.Should().Be.False();

            chain.Add(new TimeBlock(now, TimeSpec.MaxPeriodTime));

            chain.IsAnytime.Should().Be.True();
        }
Exemplo n.º 8
0
        public void AddReadOnlyTest()
        {
            var timePeriods = new TimePeriodChain();

            Assert.Throws <InvalidOperationException>(
                () => timePeriods.Add(new TimeRange(TimeSpec.MinPeriodTime, TimeSpec.MaxPeriodTime, true)));
        }
Exemplo n.º 9
0
        public void AddReadOnlyTest()
        {
            TimePeriodChain timePeriods = new TimePeriodChain();

            Assert.NotNull(Assert.Throws <NotSupportedException>(() =>
                                                                 timePeriods.Add(new TimeRange(TimeSpec.MinPeriodDate, TimeSpec.MaxPeriodDate, true))));
        }         // AddReadOnlyTest
Exemplo n.º 10
0
        public void AddTimeRangeTest()
        {
            var schoolDay = new SchoolDay();
            var chain     = new TimePeriodChain(schoolDay);

            var range = new TimeRange(schoolDay.Lesson1.Start, schoolDay.Lesson1.End);

            chain.Add(range);
            chain.Last.Should().Be(range);
        }
Exemplo n.º 11
0
        public void IsMomentTest()
        {
            DateTime        now         = ClockProxy.Clock.Now;
            TimePeriodChain timePeriods = new TimePeriodChain();

            Assert.False(timePeriods.IsMoment);

            timePeriods.Add(new TimeBlock(now));
            Assert.Equal(1, timePeriods.Count);
            Assert.True(timePeriods.HasStart);
            Assert.True(timePeriods.HasEnd);
            Assert.True(timePeriods.IsMoment);

            timePeriods.Add(new TimeBlock(now));
            Assert.Equal(2, timePeriods.Count);
            Assert.True(timePeriods.HasStart);
            Assert.True(timePeriods.HasEnd);
            Assert.True(timePeriods.IsMoment);
        }         // IsMomentTest
Exemplo n.º 12
0
        public void InsertTimeRangeTest()
        {
            DateTime        now         = ClockProxy.Clock.Now;
            SchoolDay       schoolDay   = new SchoolDay(now);
            TimePeriodChain timePeriods = new TimePeriodChain(schoolDay);

            TimeRange timeRange = new TimeRange(schoolDay.Lesson1.Start, schoolDay.Lesson1.End);

            timePeriods.Add(timeRange);
            Assert.Equal(timePeriods.Last, timeRange);
        }         // InsertTimeRangeTest
Exemplo n.º 13
0
        public void DurationTest()
        {
            TimePeriodChain timePeriods = new TimePeriodChain();

            Assert.Equal(timePeriods.Duration, TimeSpec.MaxPeriodDuration);

            TimeSpan duration = Duration.Hour;

            timePeriods.Add(new TimeBlock(ClockProxy.Clock.Now, duration));
            Assert.Equal <TimeSpan>(timePeriods.Duration, duration);
        }         // DurationTest
Exemplo n.º 14
0
        public void EndTest()
        {
            DateTime        now         = ClockProxy.Clock.Now;
            TimePeriodChain timePeriods = new TimePeriodChain();

            Assert.Equal(timePeriods.End, TimeSpec.MaxPeriodDate);

            timePeriods.Add(new TimeBlock(Duration.Hour, now));
            Assert.Equal <DateTime>(timePeriods.End, now);

            timePeriods.Clear();
            Assert.Equal(timePeriods.End, TimeSpec.MaxPeriodDate);
        }         // EndTest
Exemplo n.º 15
0
        public void StartTest()
        {
            DateTime        now         = ClockProxy.Clock.Now;
            TimePeriodChain timePeriods = new TimePeriodChain();

            Assert.Equal(timePeriods.Start, TimeSpec.MinPeriodDate);

            timePeriods.Add(new TimeBlock(now, Duration.Hour));
            Assert.Equal <DateTime>(timePeriods.Start, now);

            timePeriods.Clear();
            Assert.Equal(timePeriods.Start, TimeSpec.MinPeriodDate);
        }         // StartTest
Exemplo n.º 16
0
        public void DurationTest()
        {
            var chain = new TimePeriodChain();

            chain.Duration.Should().Be(TimeSpec.MaxPeriodDuration);

            chain.Add(new TimeBlock(ClockProxy.Clock.Now, DurationUtil.Hour));
            chain.Duration.Should().Be(DurationUtil.Hour);

            chain.HasPeriod.Should().Be.True();
            chain.IsMoment.Should().Be.False();
            chain.IsAnytime.Should().Be.False();
        }
Exemplo n.º 17
0
        public void EndTest()
        {
            var now   = ClockProxy.Clock.Now;
            var chain = new TimePeriodChain();

            chain.End.Should().Be(TimeSpec.MaxPeriodTime);

            chain.Add(new TimeBlock(DurationUtil.Hour, now));
            chain.End.Should().Be(now);

            chain.Clear();
            chain.End.Should().Be(TimeSpec.MaxPeriodTime);
        }
Exemplo n.º 18
0
        public void StartTest()
        {
            var now   = ClockProxy.Clock.Now;
            var chain = new TimePeriodChain();

            chain.Start.Should().Be(TimeSpec.MinPeriodTime);

            chain.Add(new TimeBlock(now, DurationUtil.Hour));
            chain.Start.Should().Be(now);

            chain.Clear();
            chain.Start.Should().Be(TimeSpec.MinPeriodTime);
        }
Exemplo n.º 19
0
        public void StartTest() {
            var now = ClockProxy.Clock.Now;
            var chain = new TimePeriodChain();

            chain.Start.Should().Be(TimeSpec.MinPeriodTime);

            chain.Add(new TimeBlock(now, DurationUtil.Hour));
            chain.Start.Should().Be(now);

            chain.Clear();
            chain.Start.Should().Be(TimeSpec.MinPeriodTime);
        }
Exemplo n.º 20
0
        public void DurationTest() {
            var chain = new TimePeriodChain();
            chain.Duration.Should().Be(TimeSpec.MaxPeriodDuration);

            chain.Add(new TimeBlock(ClockProxy.Clock.Now, DurationUtil.Hour));
            chain.Duration.Should().Be(DurationUtil.Hour);

            chain.HasPeriod.Should().Be.True();
            chain.IsMoment.Should().Be.False();
            chain.IsAnytime.Should().Be.False();
        }
Exemplo n.º 21
0
        public void AddTimeRangeTest() {
            var schoolDay = new SchoolDay();
            var chain = new TimePeriodChain(schoolDay);

            var range = new TimeRange(schoolDay.Lesson1.Start, schoolDay.Lesson1.End);

            chain.Add(range);
            chain.Last.Should().Be(range);
        }
Exemplo n.º 22
0
 public void AddReadOnlyTest() {
     var timePeriods = new TimePeriodChain();
     Assert.Throws<InvalidOperationException>(
         () => timePeriods.Add(new TimeRange(TimeSpec.MinPeriodTime, TimeSpec.MaxPeriodTime, true)));
 }
Exemplo n.º 23
0
        public void InsertTimeRangeTest() {
            DateTime now = ClockProxy.Clock.Now;
            SchoolDay schoolDay = new SchoolDay(now);
            TimePeriodChain timePeriods = new TimePeriodChain(schoolDay);

            TimeRange timeRange = new TimeRange(schoolDay.Lesson1.Start, schoolDay.Lesson1.End);

            timePeriods.Add(timeRange);
            Assert.AreEqual(timePeriods.Last, timeRange);
        }
Exemplo n.º 24
0
        public void IsMomentTest() {
            var now = ClockProxy.Clock.Now;
            var chain = new TimePeriodChain();

            chain.IsMoment.Should().Be.False();

            chain.Add(new TimeBlock(now));

            chain.Count.Should().Be(1);
            chain.HasStart.Should().Be.True();
            chain.HasEnd.Should().Be.True();
            chain.HasPeriod.Should().Be.True();
            chain.IsMoment.Should().Be.True();
            chain.IsAnytime.Should().Be.False();

            chain.Add(new TimeBlock(now.AddDays(1)));

            chain.Count.Should().Be(2);
            chain.HasStart.Should().Be.True();
            chain.HasEnd.Should().Be.True();
            chain.HasPeriod.Should().Be.True();
            chain.IsMoment.Should().Be.True();
            chain.IsAnytime.Should().Be.False();

            chain.Add(new TimeBlock(now, TimeSpan.FromDays(1)));

            chain.Count.Should().Be(3);
            chain.HasStart.Should().Be.True();
            chain.HasEnd.Should().Be.True();
            chain.HasPeriod.Should().Be.True();
            chain.IsMoment.Should().Be.False();
            chain.IsAnytime.Should().Be.False();
        }
        public void AddReadOnlyTest()
        {
            TimePeriodChain timePeriods = new TimePeriodChain();

            timePeriods.Add(new TimeRange(TimeSpec.MinPeriodDate, TimeSpec.MaxPeriodDate, true));
        }         // AddReadOnlyTest
Exemplo n.º 26
0
        public void EndTest() {
            var now = ClockProxy.Clock.Now;
            var chain = new TimePeriodChain();

            chain.End.Should().Be(TimeSpec.MaxPeriodTime);

            chain.Add(new TimeBlock(DurationUtil.Hour, now));
            chain.End.Should().Be(now);

            chain.Clear();
            chain.End.Should().Be(TimeSpec.MaxPeriodTime);
        }