diff --git a/SharpSnmpLib/ObjectIdentifier.cs b/SharpSnmpLib/ObjectIdentifier.cs index c4edba05..db53e8de 100644 --- a/SharpSnmpLib/ObjectIdentifier.cs +++ b/SharpSnmpLib/ObjectIdentifier.cs @@ -451,6 +451,17 @@ public override int GetHashCode() { return left.CompareTo(right) > 0; } + + /// + /// Implements the operator >=. + /// + /// The left. + /// The right. + /// The result of the operator. + public static bool operator >=(ObjectIdentifier left, ObjectIdentifier right) + { + return left.CompareTo(right) >= 0; + } /// /// Implements the operator >=. @@ -485,6 +496,17 @@ public override int GetHashCode() return left.CompareTo(right) <= 0; } + /// + /// Implements the operator <=. + /// + /// The left. + /// The right. + /// The result of the operator. + public static bool operator <=(ObjectIdentifier left, ObjectIdentifier right) + { + return left.CompareTo(right) <= 0; + } + /// /// The comparison. /// diff --git a/Tests/CSharpCore/Unit/ObjectIdentifierTestFixture.cs b/Tests/CSharpCore/Unit/ObjectIdentifierTestFixture.cs index 8efa8572..58dd66f0 100644 --- a/Tests/CSharpCore/Unit/ObjectIdentifierTestFixture.cs +++ b/Tests/CSharpCore/Unit/ObjectIdentifierTestFixture.cs @@ -76,6 +76,22 @@ public void TestGreaterThan() Assert.True(new ObjectIdentifier("0.0").Compare(new ObjectIdentifier("1.1")) < 0); } + [Fact] + public void TestGreaterThanOrEqual() + { + Assert.True(new ObjectIdentifier("1.1") >= new ObjectIdentifier("0.0")); + Assert.True(new ObjectIdentifier("1.1") >= new ObjectIdentifier("1.1")); + Assert.True(new ObjectIdentifier("0.0.0") >= new ObjectIdentifier("0.0")); + } + + [Fact] + public void TestLessThanOrEqual() + { + Assert.True(new ObjectIdentifier("0.0") <= new ObjectIdentifier("1.1")); + Assert.True(new ObjectIdentifier("1.1") <= new ObjectIdentifier("1.1")); + Assert.True(new ObjectIdentifier("0.0") <= new ObjectIdentifier("0.0.0")); + } + [Fact] public void TestConversion() {