2017-05-20 03:51:56 +00:00
|
|
|
// 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
|
|
|
|
{
|
2017-05-22 17:28:12 +00:00
|
|
|
public class GivenThatWeWantToCompareFXVersions
|
2017-05-20 03:51:56 +00:00
|
|
|
{
|
|
|
|
[Theory]
|
2017-05-22 17:28:12 +00:00
|
|
|
[InlineData("2.0.0", "1.0.0", 1)]
|
|
|
|
[InlineData("1.1.0", "1.0.0", 1)]
|
|
|
|
[InlineData("1.0.1", "1.0.0", 1)]
|
|
|
|
[InlineData("1.0.0", "1.0.0-pre", 1)]
|
|
|
|
[InlineData("1.0.0-pre+2", "1.0.0-pre+1", 1)]
|
|
|
|
[InlineData("1.0.0", "2.0.0", -1)]
|
|
|
|
[InlineData("1.0.0", "1.1.0", -1)]
|
|
|
|
[InlineData("1.0.0", "1.0.1", -1)]
|
|
|
|
[InlineData("1.0.0-pre", "1.0.0", -1)]
|
|
|
|
[InlineData("1.0.0-pre+1", "1.0.0-pre+2", -1)]
|
|
|
|
[InlineData("1.2.3", "1.2.3", 0)]
|
|
|
|
[InlineData("1.2.3-pre", "1.2.3-pre", 0)]
|
|
|
|
[InlineData("1.2.3-pre+1", "1.2.3-pre+1", 0)]
|
|
|
|
public void OneFXVersionIsBiggerThanTheOther(string s1, string s2, int expectedResult)
|
2017-05-20 03:51:56 +00:00
|
|
|
{
|
2017-05-22 17:28:12 +00:00
|
|
|
FXVersion fxVersion1;
|
|
|
|
FXVersion fxVersion2;
|
|
|
|
FXVersion.TryParse(s1, out fxVersion1);
|
|
|
|
FXVersion.TryParse(s2, out fxVersion2);
|
|
|
|
FXVersion.Compare(fxVersion1, fxVersion2).Should().Be(expectedResult);
|
2017-05-20 03:51:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|