Skip to content

Commit 8463821

Browse files
committed
Update tests
1 parent 1963f0c commit 8463821

File tree

6 files changed

+26
-27
lines changed

6 files changed

+26
-27
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ static void Main(string[] args)
119119
.CreateTestProject(testProject)
120120
.WithProjectChanges(doc => doc.Root.Add(new[] { reference1, reference2 }));
121121

122-
var buildCommand = new BuildCommand(Log, Path.Combine(testAsset.TestRoot, testProject.Name));
122+
var buildCommand = new BuildCommand(testAsset);
123123
buildCommand.Execute().Should().Pass();
124124

125125
var outputDirectory = buildCommand.GetOutputDirectory(targetFramework);

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,14 @@ public void It_builds_and_runs()
4040
.Should()
4141
.Pass();
4242

43-
new BuildCommand(testAsset, "CSConsoleApp")
43+
var buildCommand = new BuildCommand(testAsset, "CSConsoleApp");
44+
buildCommand
4445
.Execute(new string[] { "-p:Platform=x64", "-p:BuildProjectReferences=false" })
4546
.Should()
4647
.Pass();
4748

4849
var exe = Path.Combine( //find the platform directory
49-
new DirectoryInfo(Path.Combine(testAsset.TestRoot, "CSConsoleApp", "bin")).GetDirectories().Single().FullName,
50-
"Debug",
51-
ToolsetInfo.CurrentTargetFramework,
50+
buildCommand.GetOutputDirectory().FullName,
5251
"CSConsoleApp.exe");
5352

5453
var runCommand = new RunExeCommand(Log, exe);

src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAComServerLibrary.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public void It_publishes_comhost_to_the_publish_folder()
3131
.Pass();
3232

3333
var publishDirectory = publishCommand.GetOutputDirectory(ToolsetInfo.CurrentTargetFramework);
34-
var outputDirectory = publishDirectory.Parent;
34+
var outputDirectory = new BuildCommand(testAsset).GetOutputDirectory();
3535

3636
var filesPublished = new[] {
3737
"ComServer.dll",

src/Tests/Microsoft.NET.Sdk.BlazorWebAssembly.Tests/WasmPublishIntegrationTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ public void Publish_HostedApp_WithoutTrimming_Works()
719719
buildCommand.Execute().Should().Pass();
720720

721721
// Publish
722-
var publishCommand = new PublishCommand(Log, Path.Combine(testInstance.TestRoot, "blazorhosted"));
722+
var publishCommand = new PublishCommand(testInstance, "blazorhosted");
723723
publishCommand.Execute("/p:BuildDependencies=false /bl").Should().Pass();
724724

725725
var publishDirectory = publishCommand.GetOutputDirectory(DefaultTfm);

src/Tests/Microsoft.NET.Sdk.Razor.Tests/StaticWebAssetsIntegrationTest.cs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,13 +1142,13 @@ public void Pack_MultipleTargetFrameworks_Works()
11421142
tfm.Name = "TargetFrameworks";
11431143
tfm.FirstNode.ReplaceWith(tfm.FirstNode.ToString() + ";netstandard2.1");
11441144

1145-
document.Descendants("AddRazorSupportForMvc").SingleOrDefault()?.Parent.Remove();
1146-
document.Descendants("FrameworkReference").SingleOrDefault()?.Parent.Remove();
1145+
document.Descendants("AddRazorSupportForMvc").SingleOrDefault()?.Remove();
1146+
document.Descendants("FrameworkReference").SingleOrDefault()?.Remove();
11471147
});
11481148

11491149
Directory.Delete(Path.Combine(projectDirectory.Path, "PackageLibraryDirectDependency", "Components"), recursive: true);
11501150

1151-
var pack = new MSBuildCommand(Log, "Pack", projectDirectory.Path, "PackageLibraryDirectDependency");
1151+
var pack = new MSBuildCommand(projectDirectory, "Pack", "PackageLibraryDirectDependency");
11521152
pack.WithWorkingDirectory(projectDirectory.Path);
11531153
var result = pack.Execute("/bl");
11541154

@@ -1183,17 +1183,17 @@ public void Pack_MultipleTargetFrameworks_NoBuild_IncludesStaticWebAssets()
11831183
tfm.Name = "TargetFrameworks";
11841184
tfm.FirstNode.ReplaceWith(tfm.FirstNode.ToString() + ";netstandard2.1");
11851185

1186-
document.Descendants("AddRazorSupportForMvc").SingleOrDefault()?.Parent.Remove();
1187-
document.Descendants("FrameworkReference").SingleOrDefault()?.Parent.Remove();
1186+
document.Descendants("AddRazorSupportForMvc").SingleOrDefault()?.Remove();
1187+
document.Descendants("FrameworkReference").SingleOrDefault()?.Remove();
11881188
});
11891189

11901190
Directory.Delete(Path.Combine(projectDirectory.Path, "PackageLibraryDirectDependency", "Components"), recursive: true);
11911191

1192-
var build = new BuildCommand(Log, projectDirectory.Path, "PackageLibraryDirectDependency");
1192+
var build = new BuildCommand(projectDirectory, "PackageLibraryDirectDependency");
11931193
build.WithWorkingDirectory(projectDirectory.Path);
11941194
var buildResult = build.Execute("/bl");
11951195

1196-
var pack = new MSBuildCommand(Log, "Pack", projectDirectory.Path, "PackageLibraryDirectDependency");
1196+
var pack = new MSBuildCommand(projectDirectory, "Pack", "PackageLibraryDirectDependency");
11971197
pack.WithWorkingDirectory(projectDirectory.Path);
11981198
var result = pack.Execute("/p:NoBuild=true", "/bl");
11991199

@@ -1228,8 +1228,8 @@ public void Pack_MultipleTargetFrameworks_NoBuild_DoesNotIncludeAssetsAsContent(
12281228
tfm.Name = "TargetFrameworks";
12291229
tfm.FirstNode.ReplaceWith(tfm.FirstNode.ToString() + ";netstandard2.1");
12301230

1231-
document.Descendants("AddRazorSupportForMvc").SingleOrDefault()?.Parent.Remove();
1232-
document.Descendants("FrameworkReference").SingleOrDefault()?.Parent.Remove();
1231+
document.Descendants("AddRazorSupportForMvc").SingleOrDefault()?.Remove();
1232+
document.Descendants("FrameworkReference").SingleOrDefault()?.Remove();
12331233
});
12341234

12351235
Directory.Delete(Path.Combine(projectDirectory.Path, "PackageLibraryDirectDependency", "Components"), recursive: true);
@@ -1238,7 +1238,7 @@ public void Pack_MultipleTargetFrameworks_NoBuild_DoesNotIncludeAssetsAsContent(
12381238
build.WithWorkingDirectory(projectDirectory.Path);
12391239
var buildResult = build.Execute("/bl");
12401240

1241-
var pack = new MSBuildCommand(Log, "Pack", projectDirectory.Path, "PackageLibraryDirectDependency");
1241+
var pack = new MSBuildCommand(projectDirectory, "Pack", "PackageLibraryDirectDependency");
12421242
pack.WithWorkingDirectory(projectDirectory.Path);
12431243
var result = pack.Execute("/p:NoBuild=true", "/bl");
12441244

@@ -1271,13 +1271,13 @@ public void Pack_MultipleTargetFrameworks_GeneratePackageOnBuild_IncludesStaticW
12711271
tfm.Name = "TargetFrameworks";
12721272
tfm.FirstNode.ReplaceWith(tfm.FirstNode.ToString() + ";netstandard2.1");
12731273

1274-
document.Descendants("AddRazorSupportForMvc").SingleOrDefault()?.Parent.Remove();
1275-
document.Descendants("FrameworkReference").SingleOrDefault()?.Parent.Remove();
1274+
document.Descendants("AddRazorSupportForMvc").SingleOrDefault()?.Remove();
1275+
document.Descendants("FrameworkReference").SingleOrDefault()?.Remove();
12761276
});
12771277

12781278
Directory.Delete(Path.Combine(projectDirectory.Path, "PackageLibraryDirectDependency", "Components"), recursive: true);
12791279

1280-
var build = new BuildCommand(Log, projectDirectory.Path, "PackageLibraryDirectDependency");
1280+
var build = new BuildCommand(projectDirectory, "PackageLibraryDirectDependency");
12811281
build.WithWorkingDirectory(projectDirectory.Path);
12821282
var result = build.Execute("/p:GeneratePackageOnBuild=true", "/bl");
12831283

@@ -1312,13 +1312,13 @@ public void Pack_MultipleTargetFrameworks_GeneratePackageOnBuild_DoesNotIncludeA
13121312
tfm.Name = "TargetFrameworks";
13131313
tfm.FirstNode.ReplaceWith(tfm.FirstNode.ToString() + ";netstandard2.1");
13141314

1315-
document.Descendants("AddRazorSupportForMvc").SingleOrDefault()?.Parent.Remove();
1316-
document.Descendants("FrameworkReference").SingleOrDefault()?.Parent.Remove();
1315+
document.Descendants("AddRazorSupportForMvc").SingleOrDefault()?.Remove();
1316+
document.Descendants("FrameworkReference").SingleOrDefault()?.Remove();
13171317
});
13181318

13191319
Directory.Delete(Path.Combine(projectDirectory.Path, "PackageLibraryDirectDependency", "Components"), recursive: true);
13201320

1321-
var build = new BuildCommand(Log, projectDirectory.Path, "PackageLibraryDirectDependency");
1321+
var build = new BuildCommand(projectDirectory, "PackageLibraryDirectDependency");
13221322
build.WithWorkingDirectory(projectDirectory.Path);
13231323
var result = build.Execute("/p:GeneratePackageOnBuild=true", "/bl");
13241324

@@ -2421,13 +2421,13 @@ public void Pack_MultipleTargetFrameworks_DoesNotIncludeAssetsAsContent()
24212421
tfm.Name = "TargetFrameworks";
24222422
tfm.FirstNode.ReplaceWith(tfm.FirstNode.ToString() + ";netstandard2.1");
24232423

2424-
document.Descendants("AddRazorSupportForMvc").SingleOrDefault()?.Parent.Remove();
2425-
document.Descendants("FrameworkReference").SingleOrDefault()?.Parent.Remove();
2424+
document.Descendants("AddRazorSupportForMvc").SingleOrDefault()?.Remove();
2425+
document.Descendants("FrameworkReference").SingleOrDefault()?.Remove();
24262426
});
24272427

24282428
Directory.Delete(Path.Combine(projectDirectory.Path, "PackageLibraryDirectDependency", "Components"), recursive: true);
24292429

2430-
var pack = new MSBuildCommand(Log, "Pack", projectDirectory.Path, "PackageLibraryDirectDependency");
2430+
var pack = new MSBuildCommand(projectDirectory, "Pack", "PackageLibraryDirectDependency");
24312431
pack.WithWorkingDirectory(projectDirectory.Path);
24322432
var result = pack.Execute("/bl");
24332433

src/Tests/Microsoft.NET.Sdk.Web.Tests/PublishTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public void TrimmingOptions_Are_Defaulted_Correctly_On_Trimmed_Apps(string targe
3232

3333
var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: projectName + targetFramework);
3434

35-
var publishCommand = new PublishCommand(Log, Path.Combine(testAsset.TestRoot, testProject.Name));
35+
var publishCommand = new PublishCommand(testAsset);
3636
publishCommand.Execute($"/p:RuntimeIdentifier={rid}").Should().Pass();
3737

3838
string outputDirectory = publishCommand.GetOutputDirectory(targetFramework: targetFramework, runtimeIdentifier: rid).FullName;

0 commit comments

Comments
 (0)