Added top level statement
MODIFY
EssentialCSharp.sln
EssentialCSharp.sln
@@ -121,15 +121,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Chapter23.Tests", "src\Chap
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{22D1D24E-29B7-478D-ADBA-0F4836D3857A}"
ProjectSection(SolutionItems) = preProject
-<<<<<<< RefactorPowerShellTestUtilities
-<<<<<<< RefactorPowerShellTestUtilities
src\Shared\Tests\PowerShellTestUtilities.cs = src\Shared\Tests\PowerShellTestUtilities.cs
-=======
- src\Shared\Tests\PowerShellTestsUtilities.cs = src\Shared\Tests\PowerShellTestsUtilities.cs
->>>>>>> Refactored PowerShellTestsUtilities into a solution shared file.
-=======
- src\Shared\Tests\PowerShellTestUtilities.cs = src\Shared\Tests\PowerShellTestUtilities.cs
->>>>>>> Minor rename of PowerShellTestUtilities
EndProjectSection
EndProject
Global

RENAME
src/Chapter01.Tests/Listing01.01A.Tests.cs
src/Chapter01.Tests/Listing01.01.Tests.cs
@@ -6,7 +6,7 @@ using AddisonWesley.Michaelis.EssentialCSharp.Shared.Tests;
using System.Text.RegularExpressions;
-namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter01.Listing01_01A.Tests
+namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter01.Listing01_01.Tests
{
[TestClass]
public class HelloWorldTests

MODIFY
src/Chapter01/Chapter01.csproj
src/Chapter01/Chapter01.csproj
<Import Project="..\Chapter.props" />
<ItemGroup>
<Compile Remove="HelloWorld\**" />
+ <Compile Remove="Listing01.01.HelloWorldInC#.cs" />
<Compile Remove="Listing01.01A.HelloWorldInC#.cs" />
<Compile Remove="Listing01.02.SampleNETCoreConsoleProjectFile.cs" />
<Compile Remove="Listing01.20.SampleCILOutput.cs" />
</Compile>
</ItemGroup>
<ItemGroup>
- <None Include="Listing01.01A.HelloWorldInC#.cs" />
+ <None Include="Listing01.01.HelloWorldInC#.cs" />
<None Include="Listing01.02.SampleNETCoreConsoleProjectFile.cs" />
<None Include="Listing01.20.SampleCILOutput.cs" />
</ItemGroup>

ADD
src/Chapter01/Listing01.01.HelloWorldInC#.cs
+#region INCLUDE
+System.Console.WriteLine("Hello. My name is Inigo Montoya.");
+#endregion INCLUDE

MODIFY
src/Chapter10.Tests/Chapter10.Tests.csproj
src/Chapter10.Tests/Chapter10.Tests.csproj
</PropertyGroup>
<Import Project="..\ChapterTests.props" />
<ItemGroup>
-<<<<<<< RefactorPowerShellTestUtilities
-<<<<<<< RefactorPowerShellTestUtilities
<Compile Include="..\Shared\Tests\PowerShellTestUtilities.cs" Link="PowerShellTestUtilities.cs" />
-=======
- <Compile Include="..\Shared\Tests\PowerShellTestsUtilities.cs" Link="PowerShellTestsUtilities.cs" />
->>>>>>> Refactored PowerShellTestsUtilities into a solution shared file.
-=======
- <Compile Include="..\Shared\Tests\PowerShellTestUtilities.cs" Link="PowerShellTestUtilities.cs" />
->>>>>>> Minor rename of PowerShellTestUtilities
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Chapter10\Chapter10.csproj" />

MODIFY
src/Chapter10.Tests/Listing10.13.MakingTypesAvailableOutsideAnAssembly.Tests.cs
src/Chapter10.Tests/Listing10.13.MakingTypesAvailableOutsideAnAssembly.Tests.cs
@@ -13,28 +13,12 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter10.Listing10_13.Tests
[TestMethod]
public void MakingTypesAvailableExternallyPS1_ExitCodeIs0()
{
-<<<<<<< RefactorPowerShellTestUtilities
-<<<<<<< RefactorPowerShellTestUtilities
if (PowerShellTestUtilities.PowerShellNotInstalled) Assert.Inconclusive("Powershell not installed");
-=======
- if (PowerShellTestsUtilities.PowerShellNotInstalled) Assert.Inconclusive("Powershell not installed");
->>>>>>> Added top level statement and refactored PowerShellTestsUtilities
-=======
- if (PowerShellTestUtilities.PowerShellNotInstalled) Assert.Inconclusive("Powershell not installed");
->>>>>>> Minor rename of PowerShellTestUtilities
//EssentialCSharp\\src\\Chapter10.Tests\\bin\\Debug\\netcoreapp3.0
string ps1Path = Path.GetFullPath("../../../../Chapter10/Listing10.13.MakingTypesAvailableExternally.ps1", Environment.CurrentDirectory);
string traceValue = "0";
-<<<<<<< RefactorPowerShellTestUtilities
-<<<<<<< RefactorPowerShellTestUtilities
- int exitCode = PowerShellTestUtilities.RunPowerShellScript(ps1Path, traceValue);
-=======
- int exitCode = PowerShellTestsUtilities.RunPowerShellScript(ps1Path, traceValue);
->>>>>>> Added top level statement and refactored PowerShellTestsUtilities
-=======
int exitCode = PowerShellTestUtilities.RunPowerShellScript(ps1Path, traceValue);
->>>>>>> Minor rename of PowerShellTestUtilities
Assert.AreEqual(0, exitCode);
}

MODIFY
src/Chapter10.Tests/Listing10.23.RegisteringAFinalizerWithProcessExit.Tests.cs
src/Chapter10.Tests/Listing10.23.RegisteringAFinalizerWithProcessExit.Tests.cs
@@ -11,18 +11,11 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter10.Listing10_23.Tests
[TestClass]
public class DisposeTests
{
-<<<<<<< RefactorPowerShellTestUtilities
public TestContext TestContext { get; set; } = null!; // Auto-initialized by MSTest.
-<<<<<<< RefactorPowerShellTestUtilities
static string Ps1DirectoryPath { get; } =
Path.GetFullPath(Path.Join("..", "..", "..", "..", "Chapter10"), Environment.CurrentDirectory);
static string Ps1Path { get; } = Path.GetFullPath($"{Ps1DirectoryPath}/Listing10.23.RegisteringAFinalizerWithProcessExit.ps1", Environment.CurrentDirectory);
-=======
- static string Ps1Path { get; } = Path.GetFullPath("../../../../Chapter10/Listing10.23.RegisteringAFinalizerWithProcessExit.ps1", Environment.CurrentDirectory);
- static bool PowerShellNotAvailable = PowerShellTestsUtilities.PowerShellNotInstalled;
- static string PowershellEnvironmentVariableName { get; set; } = "powershell";
->>>>>>> Added top level statement and refactored PowerShellTestsUtilities
[ClassInitialize]
public static void ClassInitialize(TestContext testContext)
@@ -36,15 +29,18 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter10.Listing10_23.Tests
$"The expected project file, '{projectFilePath}', was not created.");
}
+ private static int RunPowerShellScript(string testStage, out string psOutput) =>
+ RunPowerShellScript(testStage, null, 0, out psOutput);
+ private static int RunPowerShellScript(
+ string testStage, string? finalizerOrderOption, int traceLevel, out string psOutput) => PowerShellTestUtilities.RunPowerShellScript(
+ Ps1Path, $"-TestStage {testStage} -FinalizerOption {finalizerOrderOption ?? "ignore"} {traceLevel}", out psOutput);
+
[ClassCleanup]
public static void RemoveProcessExitProj()
{
Assert.AreEqual<int>(0, RunPowerShellScript(
"cleanup", out string _));
}
-=======
- static string Ps1Path { get; } = Path.GetFullPath("../../../../Chapter10/Listing10.23.RegisteringAFinalizerWithProcessExit.ps1", Environment.CurrentDirectory);
->>>>>>> Refactored PowerShellTestsUtilities into a solution shared file.
[DataTestMethod]
[DataRow("processExit", FinalizerRegisteredWithProcessExit, DisplayName = "Finalizer Registered With ProcessExit")]
@@ -52,30 +48,15 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter10.Listing10_23.Tests
[DataRow("gc", GCCalled, DisplayName = "Garbage Collected called")]
public void FinalizerRunsAsPredicted_ConsoleOutputIsInOrder(string finalizerOrderOption, string expectedOutput)
{
-<<<<<<< RefactorPowerShellTestUtilities
int traceValue = 0;
-=======
- string traceValue = "0";
->>>>>>> Refactored PowerShellTestsUtilities into a solution shared file.
string testStatus = "run";
-<<<<<<< RefactorPowerShellTestUtilities
-<<<<<<< RefactorPowerShellTestUtilities
TestContext.WriteLine($"Ps1Path = '{Path.GetFullPath(Ps1Path)}'");
string psOutput;
int exitCode = RunPowerShellScript(
testStatus, finalizerOrderOption, traceValue, out psOutput);
Assert.AreEqual(0, exitCode, $"PowerShell Output: {psOutput}");
-=======
- int exitCode = PowerShellTestsUtilities.RunPowerShellScript(
-=======
- int exitCode = PowerShellTestUtilities.RunPowerShellScript(
->>>>>>> Minor rename of PowerShellTestUtilities
- Ps1Path, $"{traceValue} {finalizerOrderOption} {testStatus}", out string psOutput);
-
- Assert.AreEqual(0, exitCode);
->>>>>>> Added top level statement and refactored PowerShellTestsUtilities
Assert.AreEqual<string>(RemoveWhiteSpace(expectedOutput), RemoveWhiteSpace(psOutput),
$"Unexpected output from '{Ps1Path} {traceValue} {finalizerOrderOption} {testStatus}:{Environment.NewLine}{psOutput}");

RENAME
src/Shared/Tests/PowerShellTestUtilities.cs~RefactorPowerShellTestUtilities
src/Shared/Tests/PowerShellTestUtilities.cs
Added top level statement