This commit is contained in:
Chris Cheetham 2021-06-21 09:00:42 -04:00
Родитель 22d6dd7ad7
Коммит c68aff6433
2 изменённых файлов: 6 добавлений и 30 удалений

Просмотреть файл

@ -116,7 +116,7 @@ namespace Steeltoe.InitializrApi.Models
return false;
}
if (releaseVersion == _start && !_startInclusive)
if (releaseVersion.Equals(_start) && !_startInclusive)
{
return false;
}
@ -131,7 +131,7 @@ namespace Steeltoe.InitializrApi.Models
return false;
}
if (releaseVersion == _stop && !_stopInclusive)
if (releaseVersion.Equals(_stop) && !_stopInclusive)
{
return false;
}
@ -185,7 +185,7 @@ namespace Steeltoe.InitializrApi.Models
/// <summary>
/// Similar to <see cref="Version"/> but with added support for prefixes, e.g. netcoreapp2.1.
/// </summary>
public class ReleaseVersion
public sealed class ReleaseVersion
{
private readonly string _representation;
@ -259,28 +259,6 @@ namespace Steeltoe.InitializrApi.Models
return CompareTo(a, b) > 0;
}
/// <summary>
/// Returns <see cref="CompareTo"/> == 0.
/// </summary>
/// <param name="a">Left operand.</param>
/// <param name="b">Right operand.</param>
/// <returns>a == b.</returns>
public static bool operator ==(ReleaseVersion a, ReleaseVersion b)
{
return CompareTo(a, b) == 0;
}
/// <summary>
/// Returns <see cref="CompareTo"/> != 0.
/// </summary>
/// <param name="a">Left operand.</param>
/// <param name="b">Right operand.</param>
/// <returns>a != b.</returns>
public static bool operator !=(ReleaseVersion a, ReleaseVersion b)
{
return CompareTo(a, b) != 0;
}
/// <summary>
/// Semantically compares 2 <see cref="ReleaseVersion"/>s.
/// </summary>
@ -332,7 +310,7 @@ namespace Steeltoe.InitializrApi.Models
/// </summary>
/// <param name="other">Other version.</param>
/// <returns>this == other.</returns>
protected bool Equals(ReleaseVersion other)
private bool Equals(ReleaseVersion other)
{
return _representation == other._representation;
}

Просмотреть файл

@ -190,8 +190,7 @@ namespace Steeltoe.InitializrApi.Test.Unit.Models
// Act
// Assert
(v1 == v2).Should().Be(true);
(v1 != v2).Should().Be(false);
v1.Equals(v2).Should().Be(true);
}
[Fact]
@ -204,8 +203,7 @@ namespace Steeltoe.InitializrApi.Test.Unit.Models
// Act
// Assert
(v1 != v2).Should().Be(true);
(v1 == v2).Should().Be(false);
v1.Equals(v2).Should().Be(false);
}
[Fact]