Adding a check for the min version in the CLI Resolver.
This commit is contained in:
parent
947c8daabc
commit
f61d1ffbb0
7 changed files with 386 additions and 1 deletions
|
@ -0,0 +1,82 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using Xunit;
|
||||
using Microsoft.DotNet.MSBuildSdkResolver;
|
||||
using FluentAssertions;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Utils.Tests
|
||||
{
|
||||
public class GivenThatWeWantToCompareSemanticVersions
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("2.0.0", "1.0.0")]
|
||||
[InlineData("1.1.0", "1.0.0")]
|
||||
[InlineData("1.0.1", "1.0.0")]
|
||||
[InlineData("1.0.0", "1.0.0-pre")]
|
||||
[InlineData("1.0.0-pre+2", "1.0.0-pre+1")]
|
||||
public void OneSemanticVersionIsBiggerThanTheOther(string s1, string s2)
|
||||
{
|
||||
var biggerThan = SemanticVersion.Parse(s1) > SemanticVersion.Parse(s2);
|
||||
var smallerThan = SemanticVersion.Parse(s1) < SemanticVersion.Parse(s2);
|
||||
biggerThan.Should().BeTrue();
|
||||
smallerThan.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("1.0.0", "2.0.0")]
|
||||
[InlineData("1.0.0", "1.1.0")]
|
||||
[InlineData("1.0.0", "1.0.1")]
|
||||
[InlineData("1.0.0-pre", "1.0.0")]
|
||||
[InlineData("1.0.0-pre+1", "1.0.0-pre+2")]
|
||||
public void OneSemanticVersionIsSmallerThanTheOther(string s1, string s2)
|
||||
{
|
||||
var smallerThan = SemanticVersion.Parse(s1) < SemanticVersion.Parse(s2);
|
||||
var biggerThan = SemanticVersion.Parse(s1) > SemanticVersion.Parse(s2);
|
||||
smallerThan.Should().BeTrue();
|
||||
biggerThan.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("2.0.0", "1.0.0")]
|
||||
[InlineData("1.0.0", "1.0.0")]
|
||||
public void OneSemanticVersionIsBiggerThanOrEqualsTheOther(string s1, string s2)
|
||||
{
|
||||
var biggerThanOrEquals = SemanticVersion.Parse(s1) >= SemanticVersion.Parse(s2);
|
||||
biggerThanOrEquals.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("1.0.0", "2.0.0")]
|
||||
[InlineData("1.0.0", "1.0.0")]
|
||||
public void OneSemanticVersionIsSmallerThanOrEqualsTheOther(string s1, string s2)
|
||||
{
|
||||
var smallerThanOrEquals = SemanticVersion.Parse(s1) <= SemanticVersion.Parse(s2);
|
||||
smallerThanOrEquals.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("1.2.3", "1.2.3")]
|
||||
[InlineData("1.2.3-pre", "1.2.3-pre")]
|
||||
[InlineData("1.2.3-pre+1", "1.2.3-pre+1")]
|
||||
public void SemanticVersionsCanBeEqual(string s1, string s2)
|
||||
{
|
||||
var equals = SemanticVersion.Parse(s1) == SemanticVersion.Parse(s2);
|
||||
var different = SemanticVersion.Parse(s1) != SemanticVersion.Parse(s2);
|
||||
equals.Should().BeTrue();
|
||||
different.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("1.2.3", "1.2.0")]
|
||||
[InlineData("1.2.3-pre", "1.2.3-pra")]
|
||||
[InlineData("1.2.3-pre+1", "1.2.3-pre+2")]
|
||||
public void SemanticVersionsCanBeDifferent(string s1, string s2)
|
||||
{
|
||||
var different = SemanticVersion.Parse(s1) != SemanticVersion.Parse(s2);
|
||||
var equals = SemanticVersion.Parse(s1) == SemanticVersion.Parse(s2);
|
||||
different.Should().BeTrue();
|
||||
equals.Should().BeFalse();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using Xunit;
|
||||
using Microsoft.DotNet.MSBuildSdkResolver;
|
||||
using FluentAssertions;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Utils.Tests
|
||||
{
|
||||
public class GivenThatWeWantToParseSemanticVersions
|
||||
{
|
||||
[Fact]
|
||||
public void ReturnsNullWhenNoMajorSeparatorIsFound()
|
||||
{
|
||||
var semanticVersion = SemanticVersion.Parse("1");
|
||||
|
||||
semanticVersion.Should().BeNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReturnsNullWhenMajorPortionIsNotANumber()
|
||||
{
|
||||
var semanticVersion = SemanticVersion.Parse("a.0.0");
|
||||
|
||||
semanticVersion.Should().BeNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReturnsNullWhenNoMinorSeparatorIsFound()
|
||||
{
|
||||
var semanticVersion = SemanticVersion.Parse("1.0");
|
||||
|
||||
semanticVersion.Should().BeNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReturnsNullWhenMinorPortionIsNotANumber()
|
||||
{
|
||||
var semanticVersion = SemanticVersion.Parse("1.a.0");
|
||||
|
||||
semanticVersion.Should().BeNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReturnsNullWhenPatchPortionIsNotANumber()
|
||||
{
|
||||
var semanticVersion = SemanticVersion.Parse("1.0.a");
|
||||
|
||||
semanticVersion.Should().BeNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReturnsSemanticVersionWhenOnlyMajorMinorPatchIsFound()
|
||||
{
|
||||
var semanticVersion = SemanticVersion.Parse("1.2.3");
|
||||
|
||||
semanticVersion.Should().NotBeNull();
|
||||
semanticVersion.Major.Should().Be(1);
|
||||
semanticVersion.Minor.Should().Be(2);
|
||||
semanticVersion.Patch.Should().Be(3);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReturnsSemanticVersionWhenOnlyMajorMinorPatchAndPreIsFound()
|
||||
{
|
||||
var semanticVersion = SemanticVersion.Parse("1.2.3-pre");
|
||||
|
||||
semanticVersion.Should().NotBeNull();
|
||||
semanticVersion.Major.Should().Be(1);
|
||||
semanticVersion.Minor.Should().Be(2);
|
||||
semanticVersion.Patch.Should().Be(3);
|
||||
semanticVersion.Pre.Should().Be("-pre");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReturnsSemanticVersionWhenMajorMinorPatchAndPreAndBuildIsFound()
|
||||
{
|
||||
var semanticVersion = SemanticVersion.Parse("1.2.3-pre+build");
|
||||
|
||||
semanticVersion.Should().NotBeNull();
|
||||
semanticVersion.Major.Should().Be(1);
|
||||
semanticVersion.Minor.Should().Be(2);
|
||||
semanticVersion.Patch.Should().Be(3);
|
||||
semanticVersion.Pre.Should().Be("-pre");
|
||||
semanticVersion.Build.Should().Be("build");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -21,6 +21,7 @@
|
|||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
|
||||
<PackageReference Include="xunit" Version="2.2.0" />
|
||||
<PackageReference Include="FluentAssertions" Version="4.18.0" />
|
||||
<PackageReference Include="runtime.linux-x64.Microsoft.NETCore.DotNetHostResolver" Version="$(CLI_SharedFrameworkVersion)" />
|
||||
<PackageReference Include="runtime.osx-x64.Microsoft.NETCore.DotNetHostResolver" Version="$(CLI_SharedFrameworkVersion)" />
|
||||
</ItemGroup>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue