public async Task MatchTest1() { var options = new ServerOptions(); var defaultFrameworkVersion = ServerOptions.Default.FrameworkVersion; Assert.True(defaultFrameworkVersion.EndsWith(RuntimeFrameworkVersionMatcher.GreaterOrEqual.ToString())); var expectedVersion = new Version(defaultFrameworkVersion.Substring(0, defaultFrameworkVersion.Length - 1)); var actualVersion = new Version(await RuntimeFrameworkVersionMatcher.MatchAsync(options)); Assert.True(actualVersion.CompareTo(expectedVersion) >= 0); options.FrameworkVersion = null; Assert.Null(await RuntimeFrameworkVersionMatcher.MatchAsync(options)); options = new ServerOptions(); var frameworkVersion = new RuntimeFrameworkVersionMatcher.RuntimeFrameworkVersion(options.FrameworkVersion) { Patch = null }; options.FrameworkVersion = frameworkVersion.ToString(); var match = await RuntimeFrameworkVersionMatcher.MatchAsync(options); Assert.NotNull(match); var matchFrameworkVersion = new RuntimeFrameworkVersionMatcher.RuntimeFrameworkVersion(match); Assert.True(matchFrameworkVersion.Major.HasValue); Assert.True(matchFrameworkVersion.Minor.HasValue); Assert.True(matchFrameworkVersion.Patch.HasValue); Assert.True(frameworkVersion.Match(matchFrameworkVersion)); options = new ServerOptions { DotNetPath = Path.GetTempFileName(), FrameworkVersion = frameworkVersion.ToString() }; var e = await Assert.ThrowsAsync <InvalidOperationException>(() => RuntimeFrameworkVersionMatcher.MatchAsync(options)); Assert.Contains("Unable to execute dotnet to retrieve list of installed runtimes", e.Message); }
public async Task MatchTest1() { var options = new ServerOptions(); Assert.Equal(ServerOptions.Default.FrameworkVersion, await RuntimeFrameworkVersionMatcher.MatchAsync(options)); options.FrameworkVersion = null; Assert.Null(await RuntimeFrameworkVersionMatcher.MatchAsync(options)); options = new ServerOptions(); var frameworkVersion = new RuntimeFrameworkVersionMatcher.RuntimeFrameworkVersion(options.FrameworkVersion) { Patch = null }; options.FrameworkVersion = frameworkVersion.ToString(); var match = await RuntimeFrameworkVersionMatcher.MatchAsync(options); Assert.NotNull(match); var matchFrameworkVersion = new RuntimeFrameworkVersionMatcher.RuntimeFrameworkVersion(match); Assert.True(matchFrameworkVersion.Major.HasValue); Assert.True(matchFrameworkVersion.Minor.HasValue); Assert.True(matchFrameworkVersion.Patch.HasValue); Assert.True(frameworkVersion.Match(matchFrameworkVersion)); options = new ServerOptions { DotNetPath = Path.GetTempFileName(), FrameworkVersion = frameworkVersion.ToString() }; var e = await Assert.ThrowsAsync <InvalidOperationException>(() => RuntimeFrameworkVersionMatcher.MatchAsync(options)); Assert.Contains("Unable to execute dotnet to retrieve list of installed runtimes", e.Message); }