Skip to content

Commit c563471

Browse files
committed
Refactor unit-tests to use TestProject apis
1 parent a865492 commit c563471

File tree

1 file changed

+48
-26
lines changed

1 file changed

+48
-26
lines changed

src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildADesktopExe.cs

Lines changed: 48 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -830,69 +830,91 @@ public void It_places_package_satellites_correctly(bool crossTarget)
830830
outputDirectory.Should().HaveFile(@"fr\FluentValidation.resources.dll");
831831
}
832832

833-
[WindowsOnlyFact]
834-
public void It_places_package_pdb_file_correctly()
833+
[WindowsOnlyFact(Skip = "https://github.com/NuGet/Home/issues/6823")]
834+
public void It_allows_TargetFrameworkVersion_to_be_capitalized()
835835
{
836-
var testAsset = _testAssetsManager
837-
.CopyTestAsset(
838-
"DesktopUsingPackageWithPdb")
839-
.WithSource();
836+
var testProject = new TestProject()
837+
{
838+
Name = "UppercaseTargetFrameworkVersion",
839+
IsSdkProject = false,
840+
IsExe = true,
841+
TargetFrameworkVersion = "V4.6.2"
842+
};
840843

841-
testAsset.Restore(Log);
844+
var testAsset = _testAssetsManager.CreateTestProject(testProject);
845+
846+
var buildCommand = new BuildCommand(testAsset);
842847

843-
var buildCommand = new BuildCommand(Log, testAsset.TestRoot);
844848
buildCommand
845849
.Execute()
846850
.Should()
847851
.Pass();
848-
849-
var outputDirectory = buildCommand.GetOutputDirectory("net46");
850-
outputDirectory.Should().HaveFile("NServiceBus.Core.dll");
851-
outputDirectory.Should().HaveFile("NServiceBus.Core.pdb");
852-
outputDirectory.Should().HaveFile("NServiceBus.Core.xml");
853852
}
854853

855854
[WindowsOnlyFact]
856-
public void It_places_package_pdb_without_xml_file_correctly()
855+
public void It_places_package_pdb_and_xml_files_correctly()
857856
{
858-
var testAsset = _testAssetsManager
859-
.CopyTestAsset(
860-
"DesktopUsingPackageWithPdbAndXml")
861-
.WithSource();
857+
var testProject = new TestProject()
858+
{
859+
Name = "DesktopUsingPackageWithPdbAndXml",
860+
TargetFrameworks = ToolsetInfo.CurrentTargetFramework,
861+
IsSdkProject = true, // open the project in the new project system
862+
IsExe = true,
863+
};
864+
865+
testProject.PackageReferences.Add(new TestPackageReference("NServiceBus", "6.4.0"));
866+
867+
// Copy xml files to output directory
868+
testProject.AdditionalProperties.Add("PublishReferencesDocumentationFiles", "true");
869+
870+
var testAsset = _testAssetsManager.CreateTestProject(testProject);
862871

863872
testAsset.Restore(Log);
864873

865874
var buildCommand = new BuildCommand(Log, testAsset.TestRoot);
875+
866876
buildCommand
867877
.Execute()
868878
.Should()
869879
.Pass();
870880

871-
var outputDirectory = buildCommand.GetOutputDirectory("net46");
881+
var outputDirectory = buildCommand.GetOutputDirectory(ToolsetInfo.CurrentTargetFramework);
872882
outputDirectory.Should().HaveFile("NServiceBus.Core.dll");
873883
outputDirectory.Should().HaveFile("NServiceBus.Core.pdb");
874-
outputDirectory.Should().NotHaveFile("NServiceBus.Core.xml");
884+
outputDirectory.Should().HaveFile("NServiceBus.Core.xml");
875885
}
876886

877-
[WindowsOnlyFact(Skip = "https://github.com/NuGet/Home/issues/6823")]
878-
public void It_allows_TargetFrameworkVersion_to_be_capitalized()
887+
[WindowsOnlyFact]
888+
public void It_places_package_pdb_without_xml_file_correctly()
879889
{
880890
var testProject = new TestProject()
881891
{
882-
Name = "UppercaseTargetFrameworkVersion",
883-
IsSdkProject = false,
892+
Name = "DesktopUsingPackageWithPdb",
893+
TargetFrameworks = ToolsetInfo.CurrentTargetFramework,
894+
IsSdkProject = true, // open the project in the new project system
884895
IsExe = true,
885-
TargetFrameworkVersion = "V4.6.2"
886896
};
887897

898+
testProject.PackageReferences.Add(new TestPackageReference("NServiceBus", "6.4.0"));
899+
900+
// Do not copy xml files to output directory
901+
testProject.AdditionalProperties.Add("PublishReferencesDocumentationFiles", "false");
902+
888903
var testAsset = _testAssetsManager.CreateTestProject(testProject);
889904

890-
var buildCommand = new BuildCommand(testAsset);
905+
testAsset.Restore(Log);
906+
907+
var buildCommand = new BuildCommand(Log, testAsset.TestRoot);
891908

892909
buildCommand
893910
.Execute()
894911
.Should()
895912
.Pass();
913+
914+
var outputDirectory = buildCommand.GetOutputDirectory(ToolsetInfo.CurrentTargetFramework);
915+
outputDirectory.Should().HaveFile("NServiceBus.Core.dll");
916+
outputDirectory.Should().HaveFile("NServiceBus.Core.pdb");
917+
outputDirectory.Should().NotHaveFile("NServiceBus.Core.xml");
896918
}
897919
}
898920
}

0 commit comments

Comments
 (0)