584d3f0502
Add ExeutablePackageObtainer Given a tools package id, it can create a fake project and restore to correct folder - DI, aka no circular dependency of commands - Parser of config XML - I try to create test nupkg at build time, so I can run test and debug easily with VSCode. The code is in test csproj.
39 lines
1.3 KiB
C#
39 lines
1.3 KiB
C#
// 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 System;
|
|
using System.IO;
|
|
using Microsoft.DotNet.Cli;
|
|
using Microsoft.DotNet.Tools.Test.Utilities;
|
|
using Xunit;
|
|
using FluentAssertions;
|
|
using NuGet.Frameworks;
|
|
|
|
namespace Microsoft.DotNet.Tests
|
|
{
|
|
public class BundledTargetFrameworkTests : TestBase
|
|
{
|
|
[Fact]
|
|
public void VersionCommandDisplaysCorrectVersion()
|
|
{
|
|
var filePath = Path.Combine(
|
|
AppContext.BaseDirectory,
|
|
"ExpectedTargetFrameworkMoniker.txt");
|
|
var targetFrameworkMoniker = GetTargetFrameworkMonikerFromFile(filePath);
|
|
var shortFolderName = NuGetFramework
|
|
.Parse(targetFrameworkMoniker)
|
|
.GetShortFolderName();
|
|
BundledTargetFramework
|
|
.GetTargetFrameworkMoniker()
|
|
.Should().Be(shortFolderName);
|
|
}
|
|
|
|
private static string GetTargetFrameworkMonikerFromFile(string versionFilePath)
|
|
{
|
|
using (var reader = new StreamReader(File.OpenRead(versionFilePath)))
|
|
{
|
|
return reader.ReadLine();
|
|
}
|
|
}
|
|
}
|
|
}
|