From aacc233dab1b7c15d518d491f4f0a91a8ae4bb59 Mon Sep 17 00:00:00 2001 From: Marko Lahma Date: Sat, 4 Nov 2023 10:31:15 +0200 Subject: [PATCH] Upgrade NuGet packages (#1670) --- Directory.Packages.props | 10 ++-- Jint.Tests/Runtime/Domain/Dimensional.cs | 58 ++++++++++++++++++++++-- 2 files changed, 59 insertions(+), 9 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 38a847299f..0255e39912 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -4,25 +4,25 @@ false - + - + - + - + - + diff --git a/Jint.Tests/Runtime/Domain/Dimensional.cs b/Jint.Tests/Runtime/Domain/Dimensional.cs index 9c338836f0..7e0069a253 100644 --- a/Jint.Tests/Runtime/Domain/Dimensional.cs +++ b/Jint.Tests/Runtime/Domain/Dimensional.cs @@ -1,6 +1,6 @@ namespace Jint.Tests.Runtime.Domain { - public class Dimensional : IComparable + public class Dimensional : IComparable, IEquatable { private readonly MeasureUnit[] PossibleMeasureUnits = new MeasureUnit[] { new MeasureUnit("Mass", "kg", 1.0), new MeasureUnit("Mass", "gr", 0.001), new MeasureUnit("Count", "piece", 1.0) }; @@ -47,19 +47,69 @@ public override string ToString() { return Value + " " + MeasureUnit.Name; } + + public bool Equals(Dimensional other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + return Value.Equals(other.Value) && Equals(MeasureUnit, other.MeasureUnit); + } + + public override bool Equals(object obj) + { + return Equals(obj as Dimensional); + } + + public override int GetHashCode() + { + return Value.GetHashCode(); + } } - public class MeasureUnit + public class MeasureUnit : IEquatable { public string MeasureType { get; set; } public string Name { get; set; } public double RelativeValue { get; set; } - public MeasureUnit(string measureType, string Name, double relativeValue) + public MeasureUnit(string measureType, string name, double relativeValue) { this.MeasureType = measureType; - this.Name = Name; + this.Name = name; this.RelativeValue = relativeValue; } + + public bool Equals(MeasureUnit other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + return MeasureType == other.MeasureType && Name == other.Name && RelativeValue.Equals(other.RelativeValue); + } + + public override bool Equals(object obj) + { + return Equals(obj as MeasureUnit); + } + + public override int GetHashCode() + { + return MeasureType.GetHashCode() ^ Name.GetHashCode() ^ RelativeValue.GetHashCode(); + } } }