diff --git a/SubSonic.Core.Extensions.Testing/UtilityTests.cs b/SubSonic.Core.Extensions.Testing/UtilityTests.cs new file mode 100644 index 0000000..7d6aede --- /dev/null +++ b/SubSonic.Core.Extensions.Testing/UtilityTests.cs @@ -0,0 +1,22 @@ +using FluentAssertions; +using NUnit.Framework; +using System; +using System.Collections.Generic; +using System.Text; + +namespace SubSonic.Core.Extensions.Testing +{ + [TestFixture] + public class UtilityTests + { + [Test] + [TestCase("netcoreapp3.1", 2.1)] + [TestCase("netcoreapp3.0", 2.1)] + [TestCase("netcoreapp2.1", 2.0)] + [TestCase("net472", 2.0)] + public void GetNetStandardVersionTests(string framework, decimal expectedVersion) + { + Utilities.GetNetStandardVersion(framework).Should().Be(expectedVersion); + } + } +} diff --git a/SubSonic.Core.Extensions/Utilities/Path.cs b/SubSonic.Core.Extensions/Utilities/Path.cs index 405d428..0a1545e 100644 --- a/SubSonic.Core.Extensions/Utilities/Path.cs +++ b/SubSonic.Core.Extensions/Utilities/Path.cs @@ -3,11 +3,14 @@ using System.Collections.Generic; using System.IO; using System.Text; +using System.Text.RegularExpressions; namespace SubSonic.Core { - public partial class Utilities - { + public static partial class Utilities + { + private static readonly Regex s_frameworkRegex = new Regex("(?[a-z]*)(?[0-9]*).(?[0-9]*)", RegexOptions.Compiled); + public static string FindHighestVersionedDirectory(string parentFolder, Func validate) { string bestMatch = null; @@ -26,5 +29,21 @@ public static string FindHighestVersionedDirectory(string parentFolder, Func= 3) + { + return 2.1M; + } + } + return 2.0M; + } } }