public void TestEquality() { Duration first = new Duration(5, 565.0); Duration second = new Duration(5, 565.0); Assert.AreEqual(first, second); Assert.IsTrue(first.Equals(second)); Assert.IsTrue(second.Equals(first)); Assert.IsTrue(first == second); Assert.IsTrue(second == first); Assert.IsFalse(first != second); Assert.IsFalse(second != first); Assert.AreEqual(0, first.CompareTo(second)); Assert.AreEqual(0, second.CompareTo(first)); first = new Duration(5, 0.00001); second = new Duration(4, 86399.99999); Assert.AreNotEqual(first, second); Assert.IsFalse(first.Equals(second)); Assert.IsFalse(second.Equals(first)); Assert.IsFalse(first == second); Assert.IsFalse(second == first); Assert.IsTrue(first != second); Assert.IsTrue(second != first); Assert.AreNotEqual(0, first.CompareTo(second)); Assert.AreNotEqual(0, second.CompareTo(first)); Assert.IsTrue(first.EqualsEpsilon(second, 1e-4)); Assert.IsTrue(second.EqualsEpsilon(first, 1e-4)); // Make sure a Duration compared with a non-Duration returns false Assert.IsFalse(first.Equals(5)); }
public void EqualsIsImplemented() { Duration v = Duration.FromSeconds(1); Assert.IsTrue(v.Equals(Duration.FromSeconds(1))); Assert.IsFalse(v.Equals(Duration.Zero)); }
public void EqualsIsImplemented() { Duration v = Duration.FromSeconds(1); Assert.True(v.Equals(Duration.FromSeconds(1), Duration.FromSeconds(SecondsTolerance))); Assert.False(v.Equals(Duration.Zero, Duration.FromSeconds(SecondsTolerance))); }
public void TestDurationClass() { var firstDuration = new Duration(200, TimeUnit.Minutes); var secondDuration = new Duration(200, TimeUnit.Minutes); Check.That(firstDuration.RawDuration).IsEqualTo(200); Check.That(firstDuration.Unit).IsEqualTo(TimeUnit.Minutes); Check.That(firstDuration.ToString()).IsEqualTo("200 Minutes"); Check.That(firstDuration > new Duration(100, TimeUnit.Seconds)).IsTrue(); Check.That(firstDuration < new Duration(100, TimeUnit.Hours)).IsTrue(); Check.That(firstDuration < secondDuration).IsFalse(); Check.That(firstDuration <= secondDuration).IsTrue(); Check.That(firstDuration > secondDuration).IsFalse(); Check.That(firstDuration >= secondDuration).IsTrue(); var anotherDurationWithSameValue = new Duration(200, TimeUnit.Minutes); // test objects override Check.That(firstDuration.GetHashCode()).IsEqualTo(anotherDurationWithSameValue.GetHashCode()); Check.That(firstDuration).IsEqualTo(anotherDurationWithSameValue); Check.That(anotherDurationWithSameValue.Equals(firstDuration)).IsTrue(); Check.That(anotherDurationWithSameValue == firstDuration).IsTrue(); Check.That(anotherDurationWithSameValue.Equals(null)).IsFalse(); // ReSharper disable once SuspiciousTypeConversion.Global Check.That(anotherDurationWithSameValue.Equals(20)).IsFalse(); Check.That(anotherDurationWithSameValue.Equals((object)firstDuration)).IsTrue(); Check.That(firstDuration.GetHashCode()).IsEqualTo(-259084257); }
public void Equals_Object_ReturnsExpected(Duration duration, object other, int expected) { Assert.Equal(expected == 0, duration.Equals(other)); if (other is Duration otherDuration) { Assert.Equal(expected == 0, Duration.Equals(duration, otherDuration)); Assert.Equal(expected == 0, duration.Equals(otherDuration)); Assert.Equal(expected == 0, duration.GetHashCode().Equals(otherDuration.GetHashCode())); } }
public void ShouldNotBeEqualToNull() { var duration = new Duration(15, 32, 785, 789215800); var other = (object)null; duration.Equals(other).Should().BeFalse(); }
/// <summary> /// Returns true if ResponseDiscoveryOutageListData instances are equal /// </summary> /// <param name="other">Instance of ResponseDiscoveryOutageListData to be compared</param> /// <returns>Boolean</returns> public bool Equals(ResponseDiscoveryOutageListData other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( OutageTime == other.OutageTime || OutageTime != null && OutageTime.Equals(other.OutageTime) ) && ( Duration == other.Duration || Duration != null && Duration.Equals(other.Duration) ) && ( IsPartial == other.IsPartial || IsPartial != null && IsPartial.Equals(other.IsPartial) ) && ( Explanation == other.Explanation || Explanation != null && Explanation.Equals(other.Explanation) )); }
/// <summary> /// Returns true if Stop instances are equal /// </summary> /// <param name="input">Instance of Stop to be compared</param> /// <returns>Boolean</returns> public bool Equals(Stop input) { if (input == null) { return(false); } return (( Address == input.Address || (Address != null && Address.Equals(input.Address)) ) && ( Duration == input.Duration || (Duration != null && Duration.Equals(input.Duration)) ) && ( PreparationTime == input.PreparationTime || (PreparationTime != null && PreparationTime.Equals(input.PreparationTime)) ) && ( TimeWindows == input.TimeWindows || TimeWindows != null && TimeWindows.SequenceEqual(input.TimeWindows) )); }
public void ShouldNotBeEqualToAnotherType() { var duration = new Duration(15, 32, 785, 789215800); var other = "some string"; duration.Equals(other).Should().BeFalse(); }
/// <summary> /// Indicates whether the current object is equal to another object of type <see cref="PeriodicSchedule"/>. /// </summary> /// <param name="other">An object to compare with this object.</param> /// <returns> /// true if the current object is equal to the <paramref name="other" /> parameter; otherwise, false. /// </returns> public bool Equals(PeriodicSchedule other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(Options == other.Options && Day == other.Day && FirstDayOfWeek == other.FirstDayOfWeek && Hour == other.Hour && Minute == other.Minute && Month == other.Month && Second == other.Second && Week == other.Week && WeekDay == other.WeekDay && MinimumGap.Equals(other.MinimumGap) && string.Equals(Name, other.Name) && CalendarSystem.Equals(other.CalendarSystem) && DateTimeZone.Equals(other.DateTimeZone)); }
public void ShouldNotBeEqual() { var duration1 = new Duration(15, 32, 785, 789215800); var duration2 = new Duration(15, 32, 786, 789215800); duration1.Equals(duration2).Should().BeFalse(); }
public void TestDNO() { string description = "This is a fast rotation plan that uses 3 teams and two 12-hr shifts to provide 24/7 coverage. " + "Each team rotates through the following sequence every three days: 1 day shift, 1 night shift, and 1 day off."; schedule = new WorkSchedule("DNO Plan", description); // Day shift, starts at 07:00 for 12 hours Shift day = schedule.CreateShift("Day", "Day shift", new LocalTime(7, 0, 0), Duration.FromHours(12)); // Night shift, starts at 19:00 for 12 hours Shift night = schedule.CreateShift("Night", "Night shift", new LocalTime(19, 0, 0), Duration.FromHours(12)); // rotation Rotation rotation = schedule.CreateRotation("DNO", "DNO"); rotation.AddSegment(day, 1, 0); rotation.AddSegment(night, 1, 1); schedule.CreateTeam("Team 1", "First team", rotation, referenceDate); schedule.CreateTeam("Team 2", "Second team", rotation, referenceDate.PlusDays(-1)); schedule.CreateTeam("Team 3", "Third team", rotation, referenceDate.PlusDays(-2)); // rotation working time LocalDateTime from = referenceDate.PlusDays(rotation.GetDayCount()).At(new LocalTime(7, 0, 0)); Duration duration = schedule.CalculateWorkingTime(from, from.PlusDays(3)); Assert.IsTrue(duration.Equals(Duration.FromHours(72))); RunBaseTest(schedule, Duration.FromHours(24), Duration.FromDays(3), referenceDate); }
/// <inheritdoc /> public bool Equals([AllowNull] Transition other) { if (other == null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Duration == other.Duration || Duration != null && Duration.Equals(other.Duration) ) && ( Easing == other.Easing || Easing != null && Easing.Equals(other.Easing) ) && ( Ordering == other.Ordering || Ordering != null && Ordering.Equals(other.Ordering) )); }
private static void EqualsTest(Duration a, Duration b) { Assert.AreEqual(a, b); Assert.True(a == b); Assert.AreEqual(a.GetHashCode(), b.GetHashCode()); Assert.False(a.Equals(null)); }
public bool Equals(LogItemViewModel other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(RepresentedTimeEntriesIds.SequenceEqual(other.RepresentedTimeEntriesIds) && IsBillable == other.IsBillable && IsActive == other.IsActive && string.Equals(Description, other.Description) && string.Equals(ProjectName, other.ProjectName) && string.Equals(ProjectColor, other.ProjectColor) && string.Equals(ClientName, other.ClientName) && string.Equals(TaskName, other.TaskName) && Duration.Equals(other.Duration) && HasProject == other.HasProject && HasTags == other.HasTags && NeedsSync == other.NeedsSync && CanContinue == other.CanContinue && VisualizationIntent == other.VisualizationIntent); }
private bool Equals(IDEEvent other) { return(string.Equals(Id, other.Id) && string.Equals(IDESessionUUID, other.IDESessionUUID) && string.Equals(KaVEVersion, other.KaVEVersion) && TriggeredAt.Equals(other.TriggeredAt) && TriggeredBy == other.TriggeredBy && Duration.Equals(other.Duration) && Equals(ActiveWindow, other.ActiveWindow) && Equals(ActiveDocument, other.ActiveDocument)); }
private bool Equals(PeformanceCounterSetting other) { return(Duration.Equals(other.Duration) && string.Equals(ValidationExpression, other.ValidationExpression) && string.Equals(Instance, other.Instance) && string.Equals(Name, other.Name) && string.Equals(Category, other.Category) && string.Equals(MachineName, other.MachineName)); }
public override bool Equals(Object obj) { if (obj is OffsetClock) { OffsetClock other = (OffsetClock)obj; return(BaseClock.Equals(other.BaseClock) && Offset.Equals(other.Offset)); } return(false); }
public T Update(GameTime gameTime, T start, T end, float duration, bool reverse = false, bool reset = false) { if (!Start.Equals(start) || !End.Equals(end) || !Duration.Equals(duration)) { Init(start, end, duration, reset); } return(Update(gameTime, reverse)); }
public bool Equals(SongInfo other) { return(Title.Equals(other.Title) && Id.Equals(other.Id) && Duration.Equals(other.Duration) && DetailsLoaded == other.DetailsLoaded && LiveStream == other.LiveStream ); }
public void Equals_ShouldNotBeEqual() { // arrange var a = new Duration(1, "some unit"); var b = new Duration(2, "some other unit"); // act & assert Assert.False(a.Equals(b)); }
public void Equals_ShouldBeEqual() { // arrange var a = new Duration(1, "some unit"); var b = new Duration(1, "some unit"); // act & assert Assert.True(a.Equals(b)); }
protected bool Equals(BuildTarget other) { return(string.Equals(Project, other.Project) && string.Equals(ProjectConfiguration, other.ProjectConfiguration) && string.Equals(Platform, other.Platform) && string.Equals(SolutionConfiguration, other.SolutionConfiguration) && StartedAt.Equals(other.StartedAt) && Duration.Equals(other.Duration) && Successful.Equals(other.Successful)); }
public T UpdateBySpeed(GameTime gameTime, T start, T end, float meanSpeed, bool reverse = false, bool reset = false) { if (!Start.Equals(start) || !End.Equals(end) || !Duration.Equals(MeanSpeedToDuration(meanSpeed))) { InitBySpeed(start, end, meanSpeed, reset); } return(Update(gameTime, reverse)); }
protected bool Equals(LogEntry other) { return(IssueNumber == other.IssueNumber && Duration.Equals(other.Duration) && string.Equals(Description, other.Description) && string.Equals(Label, other.Label) && string.Equals(Activity, other.Activity) && string.Equals(Account, other.Account) && CreateDate.Equals(other.CreateDate)); }
//------------------------------------------------------------------------- /// <summary> /// Obtains a clock that returns instants from the specified clock with the /// specified duration added /// <para> /// This clock wraps another clock, returning instants that are later by the /// specified duration. If the duration is negative, the instants will be /// earlier than the current date and time. /// The main use case for this is to simulate running in the future or in the past. /// </para> /// <para> /// A duration of zero would have no offsetting effect. /// Passing zero will return the underlying clock. /// </para> /// <para> /// The returned implementation is immutable, thread-safe and {@code Serializable} /// providing that the base clock is. /// /// </para> /// </summary> /// <param name="baseClock"> the base clock to add the duration to, not null </param> /// <param name="offsetDuration"> the duration to add, not null </param> /// <returns> a clock based on the base clock with the duration added, not null </returns> public static Clock Offset(Clock baseClock, Duration offsetDuration) { Objects.RequireNonNull(baseClock, "baseClock"); Objects.RequireNonNull(offsetDuration, "offsetDuration"); if (offsetDuration.Equals(Duration.ZERO)) { return(baseClock); } return(new OffsetClock(baseClock, offsetDuration)); }
public void TestDurationClass() { var firstDuration = new Duration(200, TimeUnit.Minutes); Check.That(firstDuration.RawDuration).IsEqualTo(200); Check.That(firstDuration.Unit).IsEqualTo(TimeUnit.Minutes); Check.That(firstDuration.ToString()).IsEqualTo("200 Minutes"); Check.That(firstDuration > new Duration(100, TimeUnit.Seconds)).IsTrue(); Check.That(firstDuration < new Duration(100, TimeUnit.Hours)).IsTrue(); var anotherDurationWithSameValue = new Duration(200, TimeUnit.Minutes); // test objects override Check.That(firstDuration.GetHashCode()).IsEqualTo(anotherDurationWithSameValue.GetHashCode()); Check.That(firstDuration).IsEqualTo(anotherDurationWithSameValue); Check.That(anotherDurationWithSameValue.Equals(firstDuration)).IsTrue(); Check.That(anotherDurationWithSameValue == firstDuration).IsTrue(); Check.That(anotherDurationWithSameValue.Equals(null)).IsFalse(); Check.That(anotherDurationWithSameValue.Equals(20)).IsFalse(); Check.That(anotherDurationWithSameValue.Equals((object)firstDuration)).IsTrue(); }
public void TestDurationClass() { var firstDuration = new Duration(200, TimeUnit.Minutes); Check.That(firstDuration.RawDuration).IsEqualTo(200); Check.That(firstDuration.Unit).IsEqualTo(TimeUnit.Minutes); Check.That(firstDuration.ToString()).IsEqualTo("200 Minutes"); Check.That(firstDuration > new Duration(100, TimeUnit.Seconds)).IsTrue(); Check.That(firstDuration < new Duration(100, TimeUnit.Hours)).IsTrue(); var anotherDurationWithSameValue = new Duration(200, TimeUnit.Minutes); // test objects override Check.That(firstDuration.GetHashCode()).IsEqualTo(anotherDurationWithSameValue.GetHashCode()); Check.That(firstDuration).IsEqualTo(anotherDurationWithSameValue); Check.That(anotherDurationWithSameValue.Equals(firstDuration)).IsTrue(); Check.That(anotherDurationWithSameValue == firstDuration).IsTrue(); Check.That(anotherDurationWithSameValue.Equals(null)).IsFalse(); Check.That(anotherDurationWithSameValue.Equals(20)).IsFalse(); Check.That(anotherDurationWithSameValue.Equals((object)firstDuration)).IsTrue(); }
public bool Equals(Song song) { if (Path.Equals(song.Path) && Title.Equals(song.Title) && Artist.Equals(song.Artist) && Album.Equals(song.Album) && Duration.Equals(song.Duration)) { return(true); } return(false); }
public override bool Equals(object obj) { if (obj == null || obj.GetType() != this.GetType()) { return(false); } Operation operationTmp = (Operation)obj; return(Id.Equals(operationTmp.Id) && Description.Equals(operationTmp.Description) && Duration.Equals(operationTmp.Duration) && Tool.Equals(operationTmp.Tool)); }
public bool Equals(TimerMessage?other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(_id.Equals(other._id) && Text == other.Text && Duration.Equals(other.Duration) && Expiration.Equals(other.Expiration) && ShowFullScreen == other.ShowFullScreen); }
public void TestDurationClass() { var test = new Duration(200, TimeUnit.Minutes); Assert.AreEqual(200, test.RawDuration); Assert.AreEqual(TimeUnit.Minutes, test.Unit); Assert.AreEqual("200 Minutes", test.ToString()); Assert.IsTrue(test > new Duration(100, TimeUnit.Seconds)); Assert.IsTrue(test < new Duration(100, TimeUnit.Hours)); var altDuration = new Duration(200, TimeUnit.Minutes); // test objects override Assert.AreEqual(altDuration.GetHashCode(), test.GetHashCode()); Assert.AreEqual(altDuration, test); Assert.IsTrue(altDuration.Equals(test)); Assert.IsTrue(altDuration == test); Assert.IsFalse(altDuration.Equals(null)); Assert.IsFalse(altDuration.Equals(20)); Assert.IsTrue(altDuration.Equals((object)test)); }
public static bool Equals(Duration t1, Duration t2) { return t1.Equals(t2); }
//===================================================================== /// <summary> /// Returns a value indicating whether two specified instances of <c>Duration</c> are equal /// </summary> /// <param name="d1">The first duration to compare</param> /// <param name="d2">The second duration to compare</param> /// <returns>Returns true if the durations are equal, false if they are not</returns> public static bool Equals(Duration d1, Duration d2) { if((object)d1 == null && (object)d2 == null) return true; if((object)d1 == null) return false; return d1.Equals(d2); }