SemanticVersion.Equals C# (CSharp) Method

Equals() public method

public Equals ( SemanticVersion, obj ) : bool
obj SemanticVersion,
return bool
    public bool Equals(SemanticVersion obj)
    {
        if (obj == null)
        {
            return false;
        }
        return Major == obj.Major &&
               Minor == obj.Minor &&
               Patch == obj.Patch;
    }

Usage Example

Esempio n. 1
0
        public void Should_override_equality_operators()
        {
            var a = new SemanticVersion(0, 0, 1);
            var b = new SemanticVersion(1, 2, 3);
            var c = new SemanticVersion(0, 0, 1);

            // Equality

            (a == c).ShouldBeTrue();
            (a == b).ShouldBeFalse();
            (a != b).ShouldBeTrue();

            a.Equals(c).ShouldBeTrue();
            a.Equals(0).ShouldBeFalse();
            a.Equals(null).ShouldBeFalse();

            a.GetHashCode().ShouldBe(c.GetHashCode());
            a.GetHashCode().ShouldNotBe(b.GetHashCode());

            // Comparison
            (a < b).ShouldBeTrue();
            (b < a).ShouldBeFalse();

            (a <= c).ShouldBeTrue();
            (b <= a).ShouldBeFalse();

            (b > a).ShouldBeTrue();
            (a > b).ShouldBeFalse();

            (a >= c).ShouldBeTrue();
            (a >= b).ShouldBeFalse();
        }
All Usage Examples Of SemanticVersion::Equals