public void TouchingIntervalTest() { TimeInterval timeInterval1 = new TimeInterval( start, end ); TimeInterval timeInterval2 = new TimeInterval( end, end.AddHours( 1 ) ); Assert.AreNotEqual( timeInterval1.GetIntersection( timeInterval2 ), null ); Assert.AreEqual( timeInterval1.IntersectsWith( timeInterval2 ), true ); Assert.AreEqual( timeInterval1.GetRelation( timeInterval2 ), PeriodRelation.EndTouching ); Assert.AreEqual( timeInterval2.GetRelation( timeInterval1 ), PeriodRelation.StartTouching ); timeInterval1.EndEdge = IntervalEdge.Open; Assert.AreEqual( timeInterval1.GetIntersection( timeInterval2 ), null ); Assert.AreEqual( timeInterval1.IntersectsWith( timeInterval2 ), false ); Assert.AreEqual( timeInterval1.GetRelation( timeInterval2 ), PeriodRelation.Before ); Assert.AreEqual( timeInterval2.GetRelation( timeInterval1 ), PeriodRelation.After ); timeInterval1.EndEdge = IntervalEdge.Closed; Assert.AreNotEqual( timeInterval1.GetIntersection( timeInterval2 ), null ); Assert.AreEqual( timeInterval1.IntersectsWith( timeInterval2 ), true ); Assert.AreEqual( timeInterval1.GetRelation( timeInterval2 ), PeriodRelation.EndTouching ); Assert.AreEqual( timeInterval2.GetRelation( timeInterval1 ), PeriodRelation.StartTouching ); timeInterval2.StartEdge = IntervalEdge.Open; Assert.AreEqual( timeInterval1.GetIntersection( timeInterval2 ), null ); Assert.AreEqual( timeInterval1.IntersectsWith( timeInterval2 ), false ); Assert.AreEqual( timeInterval1.GetRelation( timeInterval2 ), PeriodRelation.Before ); Assert.AreEqual( timeInterval2.GetRelation( timeInterval1 ), PeriodRelation.After ); timeInterval2.StartEdge = IntervalEdge.Closed; Assert.AreNotEqual( timeInterval1.GetIntersection( timeInterval2 ), null ); Assert.AreEqual( timeInterval1.IntersectsWith( timeInterval2 ), true ); Assert.AreEqual( timeInterval1.GetRelation( timeInterval2 ), PeriodRelation.EndTouching ); Assert.AreEqual( timeInterval2.GetRelation( timeInterval1 ), PeriodRelation.StartTouching ); }
public void DefaultTest() { TimeInterval timeInterval = new TimeInterval(); Assert.AreNotEqual( timeInterval, TimeInterval.Anytime ); Assert.AreEqual( timeInterval.GetRelation( TimeInterval.Anytime ), PeriodRelation.ExactMatch ); Assert.IsTrue( timeInterval.IsAnytime ); Assert.IsTrue( timeInterval.IsClosed ); Assert.IsFalse( timeInterval.IsOpen ); Assert.IsFalse( timeInterval.IsMoment ); Assert.IsFalse( timeInterval.IsReadOnly ); }
public void IsIntervalEnabledTest() { TimeInterval timeInterval1 = new TimeInterval( start, end ); TimeInterval timeInterval2 = new TimeInterval( end, end.AddHours( 1 ) ); Assert.AreEqual( timeInterval1.GetRelation( timeInterval2 ), PeriodRelation.EndTouching ); timeInterval1.EndEdge = IntervalEdge.Open; Assert.AreEqual( timeInterval1.GetRelation( timeInterval2 ), PeriodRelation.Before ); timeInterval1.IsIntervalEnabled = false; Assert.AreEqual( timeInterval1.GetRelation( timeInterval2 ), PeriodRelation.EndTouching ); timeInterval1.IsIntervalEnabled = true; Assert.AreEqual( timeInterval1.GetRelation( timeInterval2 ), PeriodRelation.Before ); timeInterval1.EndEdge = IntervalEdge.Closed; Assert.AreEqual( timeInterval1.GetRelation( timeInterval2 ), PeriodRelation.EndTouching ); }
public void TimeIntervalSample() { // --- time interval 1 --- TimeInterval timeInterval1 = new TimeInterval( new DateTime( 2011, 5, 8 ), new DateTime( 2011, 5, 9 ) ); Console.WriteLine( "TimeInterval1: " + timeInterval1 ); // > TimeInterval1: [08.05.2011 - 09.05.2011] | 1.00:00 // --- time interval 2 --- TimeInterval timeInterval2 = new TimeInterval( timeInterval1.End, timeInterval1.End.AddDays( 1 ) ); Console.WriteLine( "TimeInterval2: " + timeInterval2 ); // > TimeInterval2: [09.05.2011 - 10.05.2011] | 1.00:00 // --- relation --- Console.WriteLine( "Relation: " + timeInterval1.GetRelation( timeInterval2 ) ); // > Relation: EndTouching Console.WriteLine( "Intersection: " + timeInterval1.GetIntersection( timeInterval2 ) ); // > Intersection: [09.05.2011] timeInterval1.EndEdge = IntervalEdge.Open; Console.WriteLine( "TimeInterval1: " + timeInterval1 ); // > TimeInterval1: [08.05.2011 - 09.05.2011) | 1.00:00 timeInterval2.StartEdge = IntervalEdge.Open; Console.WriteLine( "TimeInterval2: " + timeInterval2 ); // > TimeInterval2: (09.05.2011 - 10.05.2011] | 1.00:00 // --- relation --- Console.WriteLine( "Relation: " + timeInterval1.GetRelation( timeInterval2 ) ); // > Relation: Before Console.WriteLine( "Intersection: " + timeInterval1.GetIntersection( timeInterval2 ) ); // > Intersection: }