Skip to content

Commit

Permalink
Add a test for #330
Browse files Browse the repository at this point in the history
  • Loading branch information
zijchen committed Feb 9, 2024
1 parent 0e444d0 commit 3c8fff1
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
40 changes: 40 additions & 0 deletions test/Microsoft.Build.Sql.Tests/BuildTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -224,5 +224,45 @@ public void VerifyBuildWithCentralPackageManagement()
Assert.AreEqual(string.Empty, stdError);
this.VerifyDacPackage();
}

[Test]
[TestCase("net46")]
[TestCase("net461")]
[TestCase("net462")]
[TestCase("net47")]
[TestCase("net471")]
[TestCase("net472")]
[TestCase("net48")]
[TestCase("net481")]
[TestCase("netstandard2.1")]
[TestCase("netcoreapp3.1")]
#if NET5_0_OR_GREATER
[TestCase("net5.0")]
#endif
#if NET6_0_OR_GREATER
[TestCase("net6.0")]
#endif
#if NET7_0_OR_GREATER
[TestCase("net7.0")]
#endif
#if NET8_0_OR_GREATER
[TestCase("net8.0")]
#endif
// https://github.com/microsoft/DacFx/issues/330
public void VerifyBuildWithDifferentTargetFrameworks(string targetFramework)
{

ProjectUtils.AddProperties(this.GetProjectFilePath(), new Dictionary<string, string>()
{
{ "TargetFramework", targetFramework }
});

int exitCode = this.RunDotnetCommandOnProject("build", out string stdOutput, out string stdError);

// Verify success
Assert.AreEqual(0, exitCode, "Build failed with error " + stdError);
Assert.AreEqual(string.Empty, stdError);
this.VerifyDacPackage();
}
}
}
4 changes: 2 additions & 2 deletions test/Microsoft.Build.Sql.Tests/DotnetTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public abstract class DotnetTestBase

protected string WorkingDirectory
{
get { return Path.Combine(TestContext.CurrentContext.WorkDirectory, TestContext.CurrentContext.Test.Name); }
get { return Path.Combine(TestContext.CurrentContext.WorkDirectory, TestUtils.EscapeTestName(TestContext.CurrentContext.Test.Name)); }
}

protected string CommonTestDataDirectory
Expand All @@ -33,7 +33,7 @@ protected string CommonTestDataDirectory

protected string CurrentTestDataDirectory
{
get { return Path.Combine(this.CommonTestDataDirectory, TestContext.CurrentContext.Test.Name); }
get { return Path.Combine(this.CommonTestDataDirectory, TestUtils.EscapeTestName(TestContext.CurrentContext.Test.Name)); }
}

[SetUp]
Expand Down
5 changes: 5 additions & 0 deletions test/Microsoft.Build.Sql.Tests/TestUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,10 @@ public static void CopyDirectoryRecursive(string sourceDirectoryPath, string tar
CopyDirectoryRecursive(subDir.FullName, destDirName);
}
}

public static string EscapeTestName(string testName)
{
return testName.Replace("\"", "_");
}
}
}

0 comments on commit 3c8fff1

Please sign in to comment.