Exemplo n.º 1
0
 public void NotOverlapping()
 {
     OurTimeSpan span = new OurTimeSpan
     {
         FromTime = new DateTime(2015, 2, 1, 14, 30,0),
         ToTime = new DateTime(2015, 2, 1, 1, 15, 0)
     };
     Assert.IsTrue(OurTime.OverLap(span));
 }
Exemplo n.º 2
0
 public void Test_Overlap5()
 {
     OurTimeSpan our2 = new OurTimeSpan
     {
         FromTime = new DateTime(2015, 1, 1, 13, 0, 0),
         ToTime = new DateTime(2015, 1, 1, 15, 0, 0)
     };
     Boolean result = our1.Overlap(our2);
     Assert.IsFalse(result);
 }
Exemplo n.º 3
0
        public Boolean OverLap(OurTimeSpan span)
        {
            if (span.FromTime > span.ToTime)
            {
                throw new ArgumentException("Not a valid timespan");
            }

            return FromTime >= span.FromTime && FromTime < span.ToTime
                   || ToTime <= span.ToTime && ToTime > span.FromTime
                   || FromTime < span.FromTime && ToTime > span.ToTime;
        }
Exemplo n.º 4
0
        public Boolean Overlap(OurTimeSpan ourTimeSpan)
        {
            return(FromTime >= ourTimeSpan.FromTime && FromTime < ourTimeSpan.ToTime ||
                   ToTime <= ourTimeSpan.ToTime && ToTime > ourTimeSpan.FromTime ||
                   FromTime < ourTimeSpan.FromTime && ToTime > ourTimeSpan.ToTime);

            ;

            //return true is ourTimeSpan overlaps the timespan
            //in this class.
        }
Exemplo n.º 5
0
 public void IsOverlapping()
 {
     OurTimeSpan span = new OurTimeSpan
      {
         //April
         FromTime = new DateTime(2015, 2, 1, 13, 15, 0),
         //Februar
         ToTime = new DateTime(2015, 2, 1, 13, 45, 0)
     };
     Assert.IsFalse(OurTime.OverLap(span));
 }
Exemplo n.º 6
0
        public void TestMethod4()
        {
            OurTimeSpan our2 = new OurTimeSpan
            {
                FromTime = new DateTime(2015, 1, 1, 12, 15, 0),
                ToTime = new DateTime(2015, 1, 1, 13, 15, 0)
            };

            Boolean result = our1.Overlap(our2);

            Assert.IsTrue(result);
        }
Exemplo n.º 7
0
        public void TriggerException()
        {
            OurTimeSpan span = new OurTimeSpan
            {

                FromTime = new DateTime(2015, 2, 1, 14, 30, 0),

                ToTime = new DateTime(2015, 2, 1, 13, 0, 0)

            };
            OurTime.OverLap(span);
        }
Exemplo n.º 8
0
 public Boolean Overlap(OurTimeSpan ourTimeSpan)
 {
     //return true if ourTimeSpan overlaps the timespan in this class
     if (ourTimeSpan.FromTime <= FromTime && ourTimeSpan.ToTime >= ToTime)
         return true;
     else if (ourTimeSpan.FromTime < ToTime && ourTimeSpan.ToTime >= ToTime)
         return true;
     else if (ourTimeSpan.FromTime < FromTime && ourTimeSpan.ToTime > FromTime)
         return true;
     else if(ourTimeSpan.FromTime > FromTime && ourTimeSpan.ToTime < ToTime)
         return true;
     else
     {
         return false;
     }
 }
Exemplo n.º 9
0
 public Boolean Overlap(OurTimeSpan ourTimeSpan)
 {
     //return true if ourTimeSpan overlaps the timespan in this class
     if (ourTimeSpan.FromTime <= FromTime && ourTimeSpan.ToTime >= ToTime)
     {
         return(true);
     }
     else if (ourTimeSpan.FromTime < ToTime && ourTimeSpan.ToTime >= ToTime)
     {
         return(true);
     }
     else if (ourTimeSpan.FromTime < FromTime && ourTimeSpan.ToTime > FromTime)
     {
         return(true);
     }
     else if (ourTimeSpan.FromTime > FromTime && ourTimeSpan.ToTime < ToTime)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }