public void TestEquality() { TimeInterval interval1 = new TimeInterval(new JulianDate(1.0), new JulianDate(2.0)); TimeInterval interval2 = new TimeInterval(new JulianDate(1.0), new JulianDate(2.0)); Assert.AreEqual(interval1, interval2); Assert.AreEqual(interval2, interval1); Assert.IsTrue(interval1.Equals(interval2)); Assert.IsTrue(interval2.Equals(interval1)); Assert.IsTrue(interval1 == interval2); Assert.IsTrue(interval2 == interval1); Assert.IsFalse(interval1 != interval2); Assert.IsFalse(interval2 != interval1); interval2 = new TimeInterval(new JulianDate(1.0), new JulianDate(3.0)); Assert.AreNotEqual(interval1, interval2); Assert.AreNotEqual(interval2, interval1); Assert.IsFalse(interval1.Equals(interval2)); Assert.IsFalse(interval2.Equals(interval1)); Assert.IsFalse(interval1 == interval2); Assert.IsFalse(interval2 == interval1); Assert.IsTrue(interval1 != interval2); Assert.IsTrue(interval2 != interval1); Assert.AreNotEqual(interval1, 5); }
public void TestEquality() { TimeInterval interval1 = new TimeInterval(new JulianDate(1.0), new JulianDate(2.0)); TimeInterval interval2 = new TimeInterval(new JulianDate(1.0), new JulianDate(2.0)); Assert.AreEqual(interval1, interval2); Assert.AreEqual(interval2, interval1); Assert.IsTrue(interval1.Equals(interval2)); Assert.IsTrue(interval2.Equals(interval1)); Assert.IsTrue(interval1 == interval2); Assert.IsTrue(interval2 == interval1); Assert.IsFalse(interval1 != interval2); Assert.IsFalse(interval2 != interval1); interval2 = new TimeInterval(new JulianDate(1.0), new JulianDate(3.0)); Assert.AreNotEqual(interval1, interval2); Assert.AreNotEqual(interval2, interval1); Assert.IsFalse(interval1.Equals(interval2)); Assert.IsFalse(interval2.Equals(interval1)); Assert.IsFalse(interval1 == interval2); Assert.IsFalse(interval2 == interval1); Assert.IsTrue(interval1 != interval2); Assert.IsTrue(interval2 != interval1); Assert.AreNotEqual(interval1, 5); }
public void TimeInterval_Equals() { var ti = new TimeInterval<int>(42, TimeSpan.FromSeconds(123.45)); Assert.IsFalse(ti.Equals("x")); Assert.IsTrue(ti.Equals(ti)); var t2 = new TimeInterval<int>(43, TimeSpan.FromSeconds(123.45)); Assert.IsFalse(ti.Equals(t2)); var t3 = new TimeInterval<int>(42, TimeSpan.FromSeconds(123.56)); Assert.IsFalse(ti.Equals(t3)); var t4 = new TimeInterval<int>(42, TimeSpan.FromSeconds(123.45)); Assert.IsTrue(ti.Equals(t4)); }
static void Main(string[] args) { TimeOfDay?early = null; while (early.Equals(null)) { early = getTimeOfDayFromInput("Enter early time: "); } TimeOfDay earlyTime = (TimeOfDay)early; TimeOfDay?late = null; while (late.Equals(null)) { late = getTimeOfDayFromInput("Enter late time: "); } TimeOfDay lateTime = (TimeOfDay)late; TimeInterval result = computeTimeDiff(earlyTime, lateTime); if (result.Equals(errorInterval)) { Console.WriteLine("computeTimeDiff reported an error"); } else { Console.WriteLine("The difference is {0} hours and {1} minutes", result.hours, result.minutes); } // Require the user to press a key to exit window Console.ReadKey(); }
public void TimeInterval_Equals() { var ti = new TimeInterval <int>(42, TimeSpan.FromSeconds(123.45)); Assert.IsFalse(ti.Equals("x")); Assert.IsTrue(ti.Equals(ti)); var t2 = new TimeInterval <int>(43, TimeSpan.FromSeconds(123.45)); Assert.IsFalse(ti.Equals(t2)); var t3 = new TimeInterval <int>(42, TimeSpan.FromSeconds(123.56)); Assert.IsFalse(ti.Equals(t3)); var t4 = new TimeInterval <int>(42, TimeSpan.FromSeconds(123.45)); Assert.IsTrue(ti.Equals(t4)); }
public void Equals_DifferentStart() { // Arrange var(start1, start2) = Fixture.Create <LocalTime>((x, y) => x != y); var end = Fixture.Create <LocalTime>(); var interval1 = new TimeInterval(start1, end); var interval2 = new TimeInterval(start2, end); // Assert interval1.Should().NotBe(interval2); interval1.GetHashCode().Should().NotBe(interval2.GetHashCode()); (interval1 == interval2).Should().BeFalse(); (interval1 != interval2).Should().BeTrue(); interval1.Equals(interval2).Should().BeFalse(); // IEquatable implementation }
private void button1_Click(object sender, EventArgs e) { TimeSpan duration = ((DateTime)slotDuration.EditValue).TimeOfDay; DateTime start = schedulerControl1.ActiveView.SelectedInterval.End; DateTime startOfWeek = DevExpress.XtraScheduler.Native.DateTimeHelper.GetStartOfWeek(start); TimeInterval interval = new TimeInterval(start, startOfWeek.AddDays(7)); TimeInterval freeTime = FindInterval(interval, duration); string text; if (TimeInterval.Equals(freeTime, TimeInterval.Empty)) { text = "Not found"; } else { TimeInterval clientFreeInterval = TimeZoneHelper.ToClientTime(freeTime); text = "Free time interval with duration " + clientFreeInterval.Duration.ToString() + " is found! \n\r It starts on " + clientFreeInterval.Start.Date.ToShortDateString() + " at " + clientFreeInterval.Start.TimeOfDay.ToString() + "."; schedulerControl1.ActiveView.SetSelection(clientFreeInterval, ResourceEmpty.Resource); } MessageBox.Show(text, "Search Result", MessageBoxButtons.OK, MessageBoxIcon.Information); }