Add test for consuming .NET Standard 2.0 library from .NET Framework 4.6.1 project
This commit is contained in:
parent
ac8a464450
commit
c19ff8cc13
5 changed files with 98 additions and 0 deletions
|
@ -0,0 +1,15 @@
|
|||
// 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;
|
||||
|
||||
namespace TestApp
|
||||
{
|
||||
class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine(TestLibrary.Helper.GetMessage());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net461</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\TestLibrary\TestLibrary.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -0,0 +1,24 @@
|
|||
// 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;
|
||||
|
||||
namespace TestLibrary
|
||||
{
|
||||
public static class Helper
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the message from the helper. This comment is here to help test XML documentation file generation, please do not remove it.
|
||||
/// </summary>
|
||||
/// <returns>A message</returns>
|
||||
public static string GetMessage()
|
||||
{
|
||||
return "This string came from the test library!";
|
||||
}
|
||||
|
||||
public static void SayHi()
|
||||
{
|
||||
Console.WriteLine("Hello there!");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
40
test/EndToEnd/GivenNetFrameworkSupportsNetStandard2.cs
Normal file
40
test/EndToEnd/GivenNetFrameworkSupportsNetStandard2.cs
Normal file
|
@ -0,0 +1,40 @@
|
|||
using FluentAssertions;
|
||||
using Microsoft.DotNet.TestFramework;
|
||||
using Microsoft.DotNet.Tools.Test.Utilities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace EndToEnd
|
||||
{
|
||||
public class GivenNetFrameworkSupportsNetStandard2 : TestBase
|
||||
{
|
||||
[WindowsOnlyFact]
|
||||
public void ANET461ProjectCanReferenceANETStandardProject()
|
||||
{
|
||||
var _testInstance = TestAssets.Get(TestAssetKinds.DesktopTestProjects, "NETFrameworkReferenceNETStandard20")
|
||||
.CreateInstance()
|
||||
.WithSourceFiles();
|
||||
|
||||
string projectDirectory = Path.Combine(_testInstance.Root.FullName, "TestApp");
|
||||
|
||||
new RestoreCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute()
|
||||
.Should().Pass();
|
||||
|
||||
new BuildCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute()
|
||||
.Should().Pass();
|
||||
|
||||
new RunCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.ExecuteWithCapturedOutput()
|
||||
.Should().Pass()
|
||||
.And.HaveStdOutContaining("This string came from the test library!");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue