Add more tests
This commit is contained in:
parent
150e3c4313
commit
ddf3261a67
14 changed files with 312 additions and 0 deletions
|
@ -0,0 +1,12 @@
|
|||
using System;
|
||||
|
||||
namespace ConsoleApplication
|
||||
{
|
||||
public class HelperBuiltIn1
|
||||
{
|
||||
public static string GetMessage()
|
||||
{
|
||||
return "Hello from HelperBuiltIn1 class!";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
using System;
|
||||
|
||||
namespace ConsoleApplication
|
||||
{
|
||||
public class HelperBuiltIn2
|
||||
{
|
||||
public static string GetMessage()
|
||||
{
|
||||
return "Hello from HelperBuiltIn2 class!";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
using System;
|
||||
|
||||
namespace ConsoleApplication
|
||||
{
|
||||
public class IncludeThis
|
||||
{
|
||||
public static string GetMessage()
|
||||
{
|
||||
return "Hello from IncludeThis class!";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
using System;
|
||||
|
||||
namespace ConsoleApplication
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine(IncludeThis.GetMessage());
|
||||
Console.WriteLine(HelperBuiltIn1.GetMessage());
|
||||
Console.WriteLine(HelperBuiltIn2.GetMessage());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"version": "1.0.0-*",
|
||||
"compileBuiltIn": [ "Program.cs", "IncludeThis.cs", "../HelperBuiltIn1.cs", "../HelperBuiltIn2.cs" ],
|
||||
"buildOptions": {
|
||||
"debugType": "portable",
|
||||
"emitEntryPoint": true
|
||||
},
|
||||
"dependencies": {},
|
||||
"frameworks": {
|
||||
"netcoreapp1.0": {
|
||||
"dependencies": {
|
||||
"Microsoft.NETCore.App": {
|
||||
"type": "platform",
|
||||
"version": "1.0.1"
|
||||
}
|
||||
},
|
||||
"imports": "dnxcore50"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
This does not compile but is used to test compile exclusion.
|
|
@ -0,0 +1,12 @@
|
|||
using System;
|
||||
|
||||
namespace ConsoleApplication
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("Hello World!");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"version": "1.0.0-*",
|
||||
"compileExclude": "ExcludeThis.cs",
|
||||
"buildOptions": {
|
||||
"debugType": "portable",
|
||||
"emitEntryPoint": true
|
||||
},
|
||||
"dependencies": {},
|
||||
"frameworks": {
|
||||
"netcoreapp1.0": {
|
||||
"dependencies": {
|
||||
"Microsoft.NETCore.App": {
|
||||
"type": "platform",
|
||||
"version": "1.0.1"
|
||||
}
|
||||
},
|
||||
"imports": "dnxcore50"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
using System;
|
||||
|
||||
namespace ConsoleApplication
|
||||
{
|
||||
public class Helper1
|
||||
{
|
||||
public static string GetMessage()
|
||||
{
|
||||
return "Hello from Helper1 class!";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
using System;
|
||||
|
||||
namespace ConsoleApplication
|
||||
{
|
||||
public class Helper2
|
||||
{
|
||||
public static string GetMessage()
|
||||
{
|
||||
return "Hello from Helper2 class!";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
using System;
|
||||
|
||||
namespace ConsoleApplication
|
||||
{
|
||||
public class IncludeThis
|
||||
{
|
||||
public static string GetMessage()
|
||||
{
|
||||
return "Hello from IncludeThis class!";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
using System;
|
||||
|
||||
namespace ConsoleApplication
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine(IncludeThis.GetMessage());
|
||||
Console.WriteLine(Helper1.GetMessage());
|
||||
Console.WriteLine(Helper2.GetMessage());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"version": "1.0.0-*",
|
||||
"compile": "../Helper1.cs",
|
||||
"compileFiles": "../Helper2.cs",
|
||||
"buildOptions": {
|
||||
"debugType": "portable",
|
||||
"emitEntryPoint": true
|
||||
},
|
||||
"dependencies": {},
|
||||
"frameworks": {
|
||||
"netcoreapp1.0": {
|
||||
"dependencies": {
|
||||
"Microsoft.NETCore.App": {
|
||||
"type": "platform",
|
||||
"version": "1.0.1"
|
||||
}
|
||||
},
|
||||
"imports": "dnxcore50"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -246,5 +246,143 @@ namespace Microsoft.DotNet.Migration.Tests
|
|||
Directory.Exists(Path.Combine(publishDir.FullName, "IncludeThis2.txt")).Should().BeFalse();
|
||||
Directory.Exists(Path.Combine(publishDir.FullName, "ExcludeThis.txt")).Should().BeFalse();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WhenMigratingAProjectWithDeprecatedCompileOptionsWarningsArePrinted()
|
||||
{
|
||||
var projectDirectory = TestAssets
|
||||
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJAppWithDeprecatedCompileOptions")
|
||||
.CreateInstance()
|
||||
.WithSourceFiles()
|
||||
.Root;
|
||||
|
||||
var cmd = new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.ExecuteWithCapturedOutput("migrate");
|
||||
|
||||
cmd.Should().Pass();
|
||||
|
||||
cmd.StdOut.Should().Contain(
|
||||
"The 'compile' option is deprecated. Use 'compile' in 'buildOptions' instead.");
|
||||
cmd.StdOut.Should().Contain(
|
||||
"The 'compileFiles' option is deprecated. Use 'compile' in 'buildOptions' instead.");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WhenMigratingAProjectWithDeprecatedCompileOptionsItSucceeds()
|
||||
{
|
||||
var projectDirectory = TestAssets
|
||||
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJAppWithDeprecatedCompileOptions")
|
||||
.CreateInstance()
|
||||
.WithSourceFiles()
|
||||
.Root
|
||||
.GetDirectory("project");
|
||||
|
||||
new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute("migrate")
|
||||
.Should().Pass();
|
||||
|
||||
new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute("restore")
|
||||
.Should().Pass();
|
||||
|
||||
new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute("build")
|
||||
.Should().Pass();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WhenMigratingAProjectWithDeprecatedCompileBuiltInOptionsWarningsArePrinted()
|
||||
{
|
||||
var projectDirectory = TestAssets
|
||||
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJAppWithDeprecatedCompileBuiltInOptions")
|
||||
.CreateInstance()
|
||||
.WithSourceFiles()
|
||||
.Root;
|
||||
|
||||
var cmd = new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.ExecuteWithCapturedOutput("migrate");
|
||||
|
||||
cmd.Should().Pass();
|
||||
|
||||
cmd.StdOut.Should().Contain(
|
||||
"The 'compileBuiltIn' option is deprecated. Use 'compile' in 'buildOptions' instead.");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WhenMigratingAProjectWithDeprecatedCompileBuiltInOptionsItSucceeds()
|
||||
{
|
||||
var projectDirectory = TestAssets
|
||||
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJAppWithDeprecatedCompileBuiltInOptions")
|
||||
.CreateInstance()
|
||||
.WithSourceFiles()
|
||||
.Root
|
||||
.GetDirectory("project");
|
||||
|
||||
new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute("migrate")
|
||||
.Should().Pass();
|
||||
|
||||
new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute("restore")
|
||||
.Should().Pass();
|
||||
|
||||
//Issue: https://github.com/dotnet/cli/issues/5467
|
||||
//new DotnetCommand()
|
||||
// .WithWorkingDirectory(projectDirectory)
|
||||
// .Execute("build")
|
||||
// .Should().Pass();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WhenMigratingAProjectWithDeprecatedCompileExcludeOptionsWarningsArePrinted()
|
||||
{
|
||||
var projectDirectory = TestAssets
|
||||
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJAppWithDeprecatedCompileExcludeOptions")
|
||||
.CreateInstance()
|
||||
.WithSourceFiles()
|
||||
.Root;
|
||||
|
||||
var cmd = new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.ExecuteWithCapturedOutput("migrate");
|
||||
|
||||
cmd.Should().Pass();
|
||||
|
||||
cmd.StdOut.Should().Contain(
|
||||
"The 'compileExclude' option is deprecated. Use 'compile' in 'buildOptions' instead.");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WhenMigratingAProjectWithDeprecatedCompileExcludeOptionsItSucceeds()
|
||||
{
|
||||
var projectDirectory = TestAssets
|
||||
.GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJAppWithDeprecatedCompileExcludeOptions")
|
||||
.CreateInstance()
|
||||
.WithSourceFiles()
|
||||
.Root;
|
||||
|
||||
new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute("migrate")
|
||||
.Should().Pass();
|
||||
|
||||
new DotnetCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute("restore")
|
||||
.Should().Pass();
|
||||
|
||||
// Issue: https://github.com/dotnet/cli/issues/5461
|
||||
//new DotnetCommand()
|
||||
// .WithWorkingDirectory(projectDirectory)
|
||||
// .Execute("build")
|
||||
// .Should().Pass();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue