public void AddAllTest()
        {
            DateTime currentCalendarYear = Now.CalendarYear;
            DateTime previousCalendarYear = currentCalendarYear.AddYears( -1 );
            DateTime nextCalendarYear = currentCalendarYear.AddYears( 1 );

            List<DateTime> moments = new List<DateTime>();
            moments.Add( nextCalendarYear );
            moments.Add( currentCalendarYear );
            moments.Add( previousCalendarYear );

            DateTimeSet dateTimeSet = new DateTimeSet();

            Assert.AreEqual( dateTimeSet.Count, 0 );
            Assert.AreEqual( dateTimeSet.Min, null );
            Assert.AreEqual( dateTimeSet.Max, null );
            Assert.AreEqual( dateTimeSet.Duration, null );
            Assert.IsTrue( dateTimeSet.IsEmpty );
            Assert.IsFalse( dateTimeSet.IsMoment );
            Assert.IsFalse( dateTimeSet.IsAnytime );

            dateTimeSet.AddAll( moments );

            Assert.AreEqual( dateTimeSet.Count, moments.Count );
            Assert.AreEqual( dateTimeSet.Min, previousCalendarYear );
            Assert.AreEqual( dateTimeSet.Max, nextCalendarYear );
            Assert.AreEqual( dateTimeSet.Duration, nextCalendarYear - previousCalendarYear );
            Assert.IsFalse( dateTimeSet.IsEmpty );
            Assert.IsFalse( dateTimeSet.IsMoment );
            Assert.IsFalse( dateTimeSet.IsAnytime );
        }
Exemple #2
0
        public void AddAllTest()
        {
            DateTime currentCalendarYear  = Now.CalendarYear;
            DateTime previousCalendarYear = currentCalendarYear.AddYears(-1);
            DateTime nextCalendarYear     = currentCalendarYear.AddYears(1);

            List <DateTime> moments = new List <DateTime>();

            moments.Add(nextCalendarYear);
            moments.Add(currentCalendarYear);
            moments.Add(previousCalendarYear);

            DateTimeSet dateTimeSet = new DateTimeSet();

            Assert.Equal(0, dateTimeSet.Count);
            Assert.Null(dateTimeSet.Min);
            Assert.Null(dateTimeSet.Max);
            Assert.Null(dateTimeSet.Duration);
            Assert.True(dateTimeSet.IsEmpty);
            Assert.False(dateTimeSet.IsMoment);
            Assert.False(dateTimeSet.IsAnytime);

            dateTimeSet.AddAll(moments);

            Assert.Equal(dateTimeSet.Count, moments.Count);
            Assert.Equal(dateTimeSet.Min, previousCalendarYear);
            Assert.Equal(dateTimeSet.Max, nextCalendarYear);
            Assert.Equal(dateTimeSet.Duration, nextCalendarYear - previousCalendarYear);
            Assert.False(dateTimeSet.IsEmpty);
            Assert.False(dateTimeSet.IsMoment);
            Assert.False(dateTimeSet.IsAnytime);
        }         // AddAllTest
        public void AddAllTest()
        {
            DateTime currentCalendarYear  = TimeTool.CurrentCalendarYear;
            DateTime previousCalendarYear = currentCalendarYear.AddYears(-1);
            DateTime nextCalendarYear     = currentCalendarYear.AddYears(1);

            List <DateTime> moments = new List <DateTime>
            {
                nextCalendarYear,
                currentCalendarYear,
                previousCalendarYear
            };

            DateTimeSet dateTimeSet = new DateTimeSet();

            Assert.AreEqual(dateTimeSet.Count, 0);
            Assert.AreEqual(dateTimeSet.Min, null);
            Assert.AreEqual(dateTimeSet.Max, null);
            Assert.AreEqual(dateTimeSet.Duration, null);
            Assert.IsTrue(dateTimeSet.IsEmpty);
            Assert.IsFalse(dateTimeSet.IsMoment);
            Assert.IsFalse(dateTimeSet.IsAnytime);

            dateTimeSet.AddAll(moments);

            Assert.AreEqual(dateTimeSet.Count, moments.Count);
            Assert.AreEqual(dateTimeSet.Min, previousCalendarYear);
            Assert.AreEqual(dateTimeSet.Max, nextCalendarYear);
            Assert.AreEqual(dateTimeSet.Duration, nextCalendarYear - previousCalendarYear);
            Assert.IsFalse(dateTimeSet.IsEmpty);
            Assert.IsFalse(dateTimeSet.IsMoment);
            Assert.IsFalse(dateTimeSet.IsAnytime);
        }