Exemplo n.º 1
0
        public void TestConflictingDurations()
        {
            Time t1 = new Time(DayOfWeek.Tuesday, 10);
            Time t2 = new Time(DayOfWeek.Tuesday, 11);
            Time t3 = new Time(DayOfWeek.Tuesday, 12);
            Time t4 = new Time(DayOfWeek.Tuesday, 13);

            // X-----------------X
            //           X----------------X
            Duration ts1 = new Duration(t1, t3);
            Duration ts2 = new Duration(t2, t4);

            Assert.IsTrue(ts1.ConfilctsWith(ts2));
            Assert.IsTrue(ts2.ConfilctsWith(ts1));

            // X-----------------------------X
            //        X-------------X
            ts1 = new Duration(t1, t4);
            ts2 = new Duration(t2, t3);
            Assert.IsTrue(ts2.ConfilctsWith(ts1));
            Assert.IsTrue(ts1.ConfilctsWith(ts2));

            // X----------------X
            // X--------X
            ts2 = new Duration(t1, t3);
            Assert.IsTrue(ts1.ConfilctsWith(ts2));
            Assert.IsTrue(ts2.ConfilctsWith(ts1));

            // X--------------X
            //          X-----X
            ts2 = new Duration(t3, t4);
            Assert.IsTrue(ts1.ConfilctsWith(ts2));
            Assert.IsTrue(ts2.ConfilctsWith(ts1));

            // X----------X
            // X----------X
            ts2 = new Duration(t1, t4);
            Assert.IsTrue(ts1.ConfilctsWith(ts2));
            Assert.IsTrue(ts2.ConfilctsWith(ts1));

            // X------------X
            //              X----------X
            ts1 = new Duration(t1, t2);
            ts2 = new Duration(t2, t3);
            Assert.IsTrue(ts1.ConfilctsWith(ts2, true));
            Assert.IsTrue(ts2.ConfilctsWith(ts1, true));

            Assert.IsFalse(ts1.ConfilctsWith(ts2));
            Assert.IsFalse(ts2.ConfilctsWith(ts1));

            // X-------X
            //                 X-------X
            ts2 = new Duration(t3, t4);
            Assert.IsFalse(ts1.ConfilctsWith(ts2));
            Assert.IsFalse(ts2.ConfilctsWith(ts1));
        }