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)); }
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); }
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; }
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. }
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)); }
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); }
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); }
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; } }
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); } }