diff --git a/eng/Versions.props b/eng/Versions.props
index 48000aabbcf6fc..f712e45c6c0949 100644
--- a/eng/Versions.props
+++ b/eng/Versions.props
@@ -154,7 +154,6 @@
13.0.3
1.0.2
4.18.4
- 8.0.2
2.14.3
2.9.1
1.1.3-beta1.24423.1
diff --git a/src/installer/tests/HostActivation.Tests/DependencyResolution/DependencyResolutionCommandResultExtensions.cs b/src/installer/tests/HostActivation.Tests/DependencyResolution/DependencyResolutionCommandResultExtensions.cs
index ed3335d00e4fc5..f5f96bf511f94b 100644
--- a/src/installer/tests/HostActivation.Tests/DependencyResolution/DependencyResolutionCommandResultExtensions.cs
+++ b/src/installer/tests/HostActivation.Tests/DependencyResolution/DependencyResolutionCommandResultExtensions.cs
@@ -1,11 +1,10 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-using FluentAssertions;
-using FluentAssertions.Execution;
using System;
using System.Collections.Generic;
using System.IO;
+using Xunit;
namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.DependencyResolution
{
@@ -16,64 +15,62 @@ public static class DependencyResolutionCommandResultExtensions
private const string NATIVE_DLL_SEARCH_DIRECTORIES = nameof(NATIVE_DLL_SEARCH_DIRECTORIES);
private const string PLATFORM_RESOURCE_ROOTS = nameof(PLATFORM_RESOURCE_ROOTS);
- public static AndConstraint HaveRuntimePropertyContaining(this CommandResultAssertions assertion, string propertyName, params string[] values)
+ public static CommandResultAssertions HaveRuntimePropertyContaining(this CommandResultAssertions assertion, string propertyName, params string[] values)
{
string propertyValue = GetAppMockPropertyValue(assertion, propertyName);
- AssertionChain assertionChain = AssertionChain.GetOrCreate();
foreach (string value in values)
{
- assertionChain.ForCondition(propertyValue != null && propertyValue.Contains(value))
- .FailWith($"The property {propertyName} doesn't contain expected value: '{value}'{Environment.NewLine}" +
- $"{propertyName}='{propertyValue}'" +
- $"{assertion.GetDiagnosticsInfo()}");
+ Assert.True(propertyValue is not null && propertyValue.Contains(value),
+ $"The property {propertyName} doesn't contain expected value: '{value}'{Environment.NewLine}" +
+ $"{propertyName}='{propertyValue}'" +
+ $"{assertion.GetDiagnosticsInfo()}");
}
- return new AndConstraint(assertion);
+ return assertion;
}
- public static AndConstraint NotHaveRuntimePropertyContaining(this CommandResultAssertions assertion, string propertyName, params string[] values)
+ public static CommandResultAssertions NotHaveRuntimePropertyContaining(this CommandResultAssertions assertion, string propertyName, params string[] values)
{
string propertyValue = GetAppMockPropertyValue(assertion, propertyName);
- AssertionChain assertionChain = AssertionChain.GetOrCreate();
foreach (string value in values)
{
- assertionChain.ForCondition(propertyValue != null && !propertyValue.Contains(value))
- .FailWith($"The property {propertyName} contains unexpected value: '{value}'{Environment.NewLine}" +
- $"{propertyName}='{propertyValue}'" +
- $"{assertion.GetDiagnosticsInfo()}");
+ Assert.True(propertyValue is not null && !propertyValue.Contains(value),
+ $"The property {propertyName} contains unexpected value: '{value}'{Environment.NewLine}" +
+ $"{propertyName}='{propertyValue}'" +
+ $"{assertion.GetDiagnosticsInfo()}");
}
- return new AndConstraint(assertion);
+ return assertion;
}
- public static AndConstraint HaveResolvedAssembly(this CommandResultAssertions assertion, string assemblyPath, TestApp app = null)
+ public static CommandResultAssertions HaveResolvedAssembly(this CommandResultAssertions assertion, string assemblyPath, TestApp app = null)
{
return assertion.HaveRuntimePropertyContaining(TRUSTED_PLATFORM_ASSEMBLIES, RelativePathsToAbsoluteAppPaths(assemblyPath, app));
}
- public static AndConstraint NotHaveResolvedAssembly(this CommandResultAssertions assertion, string assemblyPath, TestApp app = null)
+ public static CommandResultAssertions NotHaveResolvedAssembly(this CommandResultAssertions assertion, string assemblyPath, TestApp app = null)
{
return assertion.NotHaveRuntimePropertyContaining(TRUSTED_PLATFORM_ASSEMBLIES, RelativePathsToAbsoluteAppPaths(assemblyPath, app));
}
- public static AndConstraint HaveResolvedNativeLibraryPath(this CommandResultAssertions assertion, string path, TestApp app = null)
+ public static CommandResultAssertions HaveResolvedNativeLibraryPath(this CommandResultAssertions assertion, string path, TestApp app = null)
{
return assertion.HaveRuntimePropertyContaining(NATIVE_DLL_SEARCH_DIRECTORIES, RelativePathsToAbsoluteAppPaths(path, app));
}
- public static AndConstraint NotHaveResolvedNativeLibraryPath(this CommandResultAssertions assertion, string path, TestApp app = null)
+ public static CommandResultAssertions NotHaveResolvedNativeLibraryPath(this CommandResultAssertions assertion, string path, TestApp app = null)
{
return assertion.NotHaveRuntimePropertyContaining(NATIVE_DLL_SEARCH_DIRECTORIES, RelativePathsToAbsoluteAppPaths(path, app));
}
- public static AndConstraint HaveResolvedResourceRootPath(this CommandResultAssertions assertion, string path, TestApp app = null)
+ public static CommandResultAssertions HaveResolvedResourceRootPath(this CommandResultAssertions assertion, string path, TestApp app = null)
{
return assertion.HaveRuntimePropertyContaining(PLATFORM_RESOURCE_ROOTS, RelativePathsToAbsoluteAppPaths(path, app));
}
- public static AndConstraint NotHaveResolvedResourceRootPath(this CommandResultAssertions assertion, string path, TestApp app = null)
+ public static CommandResultAssertions NotHaveResolvedResourceRootPath(this CommandResultAssertions assertion, string path, TestApp app = null)
{
return assertion.NotHaveRuntimePropertyContaining(PLATFORM_RESOURCE_ROOTS, RelativePathsToAbsoluteAppPaths(path, app));
}
@@ -82,50 +79,48 @@ public static AndConstraint NotHaveResolvedResourceRoot
private const string assemblies = "assemblies";
private const string native_search_paths = "native_search_paths";
- public static AndConstraint HaveSuccessfullyResolvedComponentDependencies(this CommandResultAssertions assertion)
+ public static CommandResultAssertions HaveSuccessfullyResolvedComponentDependencies(this CommandResultAssertions assertion)
{
return assertion.HaveStdOutContaining("corehost_resolve_component_dependencies:Success");
}
- public static AndConstraint HaveResolvedComponentDependencyContaining(
+ public static CommandResultAssertions HaveResolvedComponentDependencyContaining(
this CommandResultAssertions assertion,
string propertyName,
params string[] values)
{
string propertyValue = GetComponentMockPropertyValue(assertion, propertyName);
- AssertionChain assertionChain = AssertionChain.GetOrCreate();
foreach (string value in values)
{
- assertionChain.ForCondition(propertyValue != null && propertyValue.Contains(value))
- .FailWith($"The resolved {propertyName} doesn't contain expected value: '{value}'{Environment.NewLine}" +
- $"{propertyName}='{propertyValue}'" +
- $"{assertion.GetDiagnosticsInfo()}");
+ Assert.True(propertyValue is not null && propertyValue.Contains(value),
+ $"The resolved {propertyName} doesn't contain expected value: '{value}'{Environment.NewLine}" +
+ $"{propertyName}='{propertyValue}'" +
+ $"{assertion.GetDiagnosticsInfo()}");
}
- return new AndConstraint(assertion);
+ return assertion;
}
- public static AndConstraint NotHaveResolvedComponentDependencyContaining(
+ public static CommandResultAssertions NotHaveResolvedComponentDependencyContaining(
this CommandResultAssertions assertion,
string propertyName,
params string[] values)
{
string propertyValue = GetComponentMockPropertyValue(assertion, propertyName);
- AssertionChain assertionChain = AssertionChain.GetOrCreate();
foreach (string value in values)
{
- assertionChain.ForCondition(propertyValue != null && !propertyValue.Contains(value))
- .FailWith($"The resolved {propertyName} contains unexpected value: '{value}'{Environment.NewLine}" +
- $"{propertyName}='{propertyValue}'" +
- $"{assertion.GetDiagnosticsInfo()}");
+ Assert.True(propertyValue is not null && !propertyValue.Contains(value),
+ $"The resolved {propertyName} contains unexpected value: '{value}'{Environment.NewLine}" +
+ $"{propertyName}='{propertyValue}'" +
+ $"{assertion.GetDiagnosticsInfo()}");
}
- return new AndConstraint(assertion);
+ return assertion;
}
- public static AndConstraint HaveResolvedComponentDependencyAssembly(
+ public static CommandResultAssertions HaveResolvedComponentDependencyAssembly(
this CommandResultAssertions assertion,
string assemblyPath,
TestApp app = null)
@@ -133,7 +128,7 @@ public static AndConstraint HaveResolvedComponentDepend
return assertion.HaveResolvedComponentDependencyContaining(assemblies, RelativePathsToAbsoluteAppPaths(assemblyPath, app));
}
- public static AndConstraint NotHaveResolvedComponentDependencyAssembly(
+ public static CommandResultAssertions NotHaveResolvedComponentDependencyAssembly(
this CommandResultAssertions assertion,
string assemblyPath,
TestApp app = null)
@@ -141,7 +136,7 @@ public static AndConstraint NotHaveResolvedComponentDep
return assertion.NotHaveResolvedComponentDependencyContaining(assemblies, RelativePathsToAbsoluteAppPaths(assemblyPath, app));
}
- public static AndConstraint HaveResolvedComponentDependencyNativeLibraryPath(
+ public static CommandResultAssertions HaveResolvedComponentDependencyNativeLibraryPath(
this CommandResultAssertions assertion,
string path,
TestApp app = null)
@@ -149,7 +144,7 @@ public static AndConstraint HaveResolvedComponentDepend
return assertion.HaveResolvedComponentDependencyContaining(native_search_paths, RelativePathsToAbsoluteAppPaths(path, app));
}
- public static AndConstraint NotHaveResolvedComponentDependencyNativeLibraryPath(
+ public static CommandResultAssertions NotHaveResolvedComponentDependencyNativeLibraryPath(
this CommandResultAssertions assertion,
string path,
TestApp app = null)
@@ -157,7 +152,7 @@ public static AndConstraint NotHaveResolvedComponentDep
return assertion.NotHaveResolvedComponentDependencyContaining(native_search_paths, RelativePathsToAbsoluteAppPaths(path, app));
}
- public static AndConstraint ErrorWithMissingAssembly(this CommandResultAssertions assertion, string depsFileName, string dependencyName, string dependencyVersion)
+ public static CommandResultAssertions ErrorWithMissingAssembly(this CommandResultAssertions assertion, string depsFileName, string dependencyName, string dependencyVersion)
{
return assertion.HaveStdErrContaining(
$"Error:{Environment.NewLine}" +
@@ -166,18 +161,18 @@ public static AndConstraint ErrorWithMissingAssembly(th
$" path: \'{dependencyName}.dll\'");
}
- public static AndConstraint HaveUsedAdditionalDeps(this CommandResultAssertions assertion, string depsFilePath)
+ public static CommandResultAssertions HaveUsedAdditionalDeps(this CommandResultAssertions assertion, string depsFilePath)
{
return assertion.HaveStdErrContaining($"Using specified additional deps.json: '{depsFilePath}'");
}
- public static AndConstraint HaveUsedAdditionalProbingPath(this CommandResultAssertions assertion, string path)
+ public static CommandResultAssertions HaveUsedAdditionalProbingPath(this CommandResultAssertions assertion, string path)
{
return assertion.HaveStdErrContaining($"Additional probe dir: {path}")
.And.HaveStdErrContaining($"probe type=lookup dir=[{path}]");
}
- public static AndConstraint HaveReadRidGraph(this CommandResultAssertions assertion, bool readRidGraph)
+ public static CommandResultAssertions HaveReadRidGraph(this CommandResultAssertions assertion, bool readRidGraph)
{
string ridGraphMsg = "RID fallback graph =";
string hostRidsMsg = "Host RID list =";
@@ -186,18 +181,18 @@ public static AndConstraint HaveReadRidGraph(this Comma
: assertion.HaveStdErrContaining(hostRidsMsg).And.NotHaveStdErrContaining(ridGraphMsg);
}
- public static AndConstraint HaveUsedFallbackRid(this CommandResultAssertions assertion, bool usedFallbackRid)
+ public static CommandResultAssertions HaveUsedFallbackRid(this CommandResultAssertions assertion, bool usedFallbackRid)
{
string msg = "Falling back to base HostRID";
return usedFallbackRid ? assertion.HaveStdErrContaining(msg) : assertion.NotHaveStdErrContaining(msg);
}
- public static AndConstraint HaveUsedFrameworkProbe(this CommandResultAssertions assertion, string path, int level)
+ public static CommandResultAssertions HaveUsedFrameworkProbe(this CommandResultAssertions assertion, string path, int level)
{
return assertion.HaveStdErrContaining($"probe type=framework dir=[{path}] fx_level={level}");
}
- public static AndConstraint NotHaveUsedFrameworkProbe(this CommandResultAssertions assertion, string path)
+ public static CommandResultAssertions NotHaveUsedFrameworkProbe(this CommandResultAssertions assertion, string path)
{
return assertion.NotHaveStdErrContaining($"probe type=framework dir=[{path}]");
}
diff --git a/src/installer/tests/HostActivation.Tests/FrameworkResolution/FrameworkResolutionCommandResultExtensions.cs b/src/installer/tests/HostActivation.Tests/FrameworkResolution/FrameworkResolutionCommandResultExtensions.cs
index d7280481ddaff4..f31dd2c9524070 100644
--- a/src/installer/tests/HostActivation.Tests/FrameworkResolution/FrameworkResolutionCommandResultExtensions.cs
+++ b/src/installer/tests/HostActivation.Tests/FrameworkResolution/FrameworkResolutionCommandResultExtensions.cs
@@ -2,14 +2,13 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System.IO;
-using FluentAssertions;
using Microsoft.DotNet.Cli.Build.Framework;
namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.FrameworkResolution
{
internal static class FrameworkResolutionCommandResultExtensions
{
- public static AndConstraint HaveResolvedFramework(this CommandResultAssertions assertion, string name, string version, string resolvedFrameworkBasePath = null)
+ public static CommandResultAssertions HaveResolvedFramework(this CommandResultAssertions assertion, string name, string version, string resolvedFrameworkBasePath = null)
{
string expectedOutput = $"mock frameworks: {name} {version}";
if (resolvedFrameworkBasePath is not null)
@@ -18,7 +17,7 @@ public static AndConstraint HaveResolvedFramework(this
return assertion.HaveStdOutContaining(expectedOutput);
}
- public static AndConstraint ShouldHaveResolvedFramework(this CommandResult result, string resolvedFrameworkName, string resolvedFrameworkVersion, string resolvedFrameworkBasePath = null)
+ public static CommandResultAssertions ShouldHaveResolvedFramework(this CommandResult result, string resolvedFrameworkName, string resolvedFrameworkVersion, string resolvedFrameworkBasePath = null)
{
return result.Should().Pass()
.And.HaveResolvedFramework(resolvedFrameworkName, resolvedFrameworkVersion, resolvedFrameworkBasePath);
@@ -33,7 +32,7 @@ public static AndConstraint ShouldHaveResolvedFramework
/// Either null in which case the command result is expected to fail and not find compatible framework version,
/// or the framework versions in which case the command result is expected to succeed and resolve the specified framework version.
/// Constraint
- public static AndConstraint ShouldHaveResolvedFrameworkOrFailToFind(this CommandResult result, string resolvedFrameworkName, string resolvedFrameworkVersion, string resolvedFrameworkBasePath = null)
+ public static CommandResultAssertions ShouldHaveResolvedFrameworkOrFailToFind(this CommandResult result, string resolvedFrameworkName, string resolvedFrameworkVersion, string resolvedFrameworkBasePath = null)
{
if (resolvedFrameworkName == null || resolvedFrameworkVersion == null ||
resolvedFrameworkVersion == FrameworkResolutionBase.ResolvedFramework.NotFound)
@@ -46,7 +45,7 @@ public static AndConstraint ShouldHaveResolvedFramework
}
}
- public static AndConstraint DidNotFindCompatibleFrameworkVersion(this CommandResultAssertions assertion, string frameworkName, string requestedVersion)
+ public static CommandResultAssertions DidNotFindCompatibleFrameworkVersion(this CommandResultAssertions assertion, string frameworkName, string requestedVersion)
{
var constraint = assertion.HaveStdErrContaining("You must install or update .NET to run this application.");
if (frameworkName is not null)
@@ -57,13 +56,13 @@ public static AndConstraint DidNotFindCompatibleFramewo
return constraint;
}
- public static AndConstraint ShouldFailToFindCompatibleFrameworkVersion(this CommandResult result, string frameworkName, string requestedVersion = null)
+ public static CommandResultAssertions ShouldFailToFindCompatibleFrameworkVersion(this CommandResult result, string frameworkName, string requestedVersion = null)
{
return result.Should().Fail()
.And.DidNotFindCompatibleFrameworkVersion(frameworkName, requestedVersion);
}
- public static AndConstraint FailedToReconcileFrameworkReference(
+ public static CommandResultAssertions FailedToReconcileFrameworkReference(
this CommandResultAssertions assertion,
string frameworkName,
string newVersion,
@@ -72,7 +71,7 @@ public static AndConstraint FailedToReconcileFrameworkR
return assertion.HaveStdErrMatching($".*The specified framework '{frameworkName}', version '{newVersion}', apply_patches=[0-1], version_compatibility_range=[^ ]* cannot roll-forward to the previously referenced version '{previousVersion}'.*");
}
- public static AndConstraint ShouldHaveResolvedFrameworkOrFailedToReconcileFrameworkReference(
+ public static CommandResultAssertions ShouldHaveResolvedFrameworkOrFailedToReconcileFrameworkReference(
this CommandResult result,
string frameworkName,
string resolvedVersion,
@@ -89,7 +88,7 @@ public static AndConstraint ShouldHaveResolvedFramework
}
}
- public static AndConstraint ShouldHaveResolvedFrameworkOrFail(
+ public static CommandResultAssertions ShouldHaveResolvedFrameworkOrFail(
this CommandResult result,
string frameworkName,
string resolvedVersion,
@@ -110,12 +109,12 @@ public static AndConstraint ShouldHaveResolvedFramework
}
}
- public static AndConstraint RestartedFrameworkResolution(this CommandResultAssertions assertion, string resolvedVersion, string newVersion)
+ public static CommandResultAssertions RestartedFrameworkResolution(this CommandResultAssertions assertion, string resolvedVersion, string newVersion)
{
return assertion.HaveStdErrContaining($"--- Restarting all framework resolution because the previously resolved framework 'Microsoft.NETCore.App', version '{resolvedVersion}' must be re-resolved with the new version '{newVersion}'");
}
- public static AndConstraint DidNotRecognizeRollForwardValue(this CommandResultAssertions assertion, string value)
+ public static CommandResultAssertions DidNotRecognizeRollForwardValue(this CommandResultAssertions assertion, string value)
{
return assertion.HaveStdErrContaining($"Unrecognized roll forward setting value '{value}'.");
}
diff --git a/src/installer/tests/HostActivation.Tests/InstallLocation.cs b/src/installer/tests/HostActivation.Tests/InstallLocation.cs
index 8d71c05aec56ae..4fa3b2d66860ab 100644
--- a/src/installer/tests/HostActivation.Tests/InstallLocation.cs
+++ b/src/installer/tests/HostActivation.Tests/InstallLocation.cs
@@ -3,7 +3,6 @@
using System;
using System.IO;
-using FluentAssertions;
using Microsoft.DotNet.Cli.Build.Framework;
using Microsoft.DotNet.CoreSetup.Test;
using Microsoft.DotNet.CoreSetup.Test.HostActivation;
@@ -31,7 +30,7 @@ public void EnvironmentVariable_CurrentArchitectureIsUsedIfEnvVarSet()
.DotNetRoot(HostTestContext.BuiltDotNet.BinPath, arch)
.Execute()
.Should().Pass()
- .And.HaveUsedDotNetRootInstallLocation(HostTestContext.BuiltDotNet.BinPath, HostTestContext.BuildRID, arch);
+ .HaveUsedDotNetRootInstallLocation(HostTestContext.BuiltDotNet.BinPath, HostTestContext.BuildRID, arch);
}
[Fact]
@@ -43,7 +42,7 @@ public void EnvironmentVariable_IfNoArchSpecificEnvVarIsFoundDotnetRootIsUsed()
.DotNetRoot(HostTestContext.BuiltDotNet.BinPath)
.Execute()
.Should().Pass()
- .And.HaveUsedDotNetRootInstallLocation(HostTestContext.BuiltDotNet.BinPath, HostTestContext.BuildRID);
+ .HaveUsedDotNetRootInstallLocation(HostTestContext.BuiltDotNet.BinPath, HostTestContext.BuildRID);
}
[Fact]
@@ -57,8 +56,8 @@ public void EnvironmentVariable_ArchSpecificDotnetRootIsUsedOverDotnetRoot()
.DotNetRoot(dotnet, arch)
.Execute()
.Should().Pass()
- .And.HaveUsedDotNetRootInstallLocation(dotnet, HostTestContext.BuildRID, arch)
- .And.NotHaveStdErrContaining("Using environment variable DOTNET_ROOT=");
+ .HaveUsedDotNetRootInstallLocation(dotnet, HostTestContext.BuildRID, arch)
+ .NotHaveStdErrContaining("Using environment variable DOTNET_ROOT=");
}
[Fact]
@@ -79,8 +78,8 @@ public void EnvironmentVariable_DotNetRootIsUsedOverInstallLocationIfSet()
.DotNetRoot(dotnet, arch)
.Execute()
.Should().Pass()
- .And.HaveUsedDotNetRootInstallLocation(dotnet, HostTestContext.BuildRID, arch)
- .And.NotHaveStdErrContaining("Using global install location");
+ .HaveUsedDotNetRootInstallLocation(dotnet, HostTestContext.BuildRID, arch)
+ .NotHaveStdErrContaining("Using global install location");
}
}
@@ -97,10 +96,10 @@ public void EnvironmentVariable_DotnetRootPathDoesNotExist()
HostTestContext.BuiltDotNet.BinPath)
.Execute()
.Should().Pass()
- .And.HaveStdErrContaining("Did not find [DOTNET_ROOT] directory [non_existent_path]")
+ .HaveStdErrContaining("Did not find [DOTNET_ROOT] directory [non_existent_path]")
// If DOTNET_ROOT points to a folder that does not exist, we fall back to the global install path.
- .And.HaveUsedGlobalInstallLocation(HostTestContext.BuiltDotNet.BinPath)
- .And.HaveStdOutContaining("Hello World");
+ .HaveUsedGlobalInstallLocation(HostTestContext.BuiltDotNet.BinPath)
+ .HaveStdOutContaining("Hello World");
}
[Fact]
@@ -116,9 +115,9 @@ public void EnvironmentVariable_DotnetRootPathExistsButHasNoHost()
HostTestContext.BuiltDotNet.BinPath)
.Execute()
.Should().Fail()
- .And.HaveUsedDotNetRootInstallLocation(app.Location, HostTestContext.BuildRID)
+ .HaveUsedDotNetRootInstallLocation(app.Location, HostTestContext.BuildRID)
// If DOTNET_ROOT points to a folder that exists we assume that there's a dotnet installation in it
- .And.HaveStdErrContaining($"The required library {Binaries.HostFxr.FileName} could not be found.");
+ .HaveStdErrContaining($"The required library {Binaries.HostFxr.FileName} could not be found.");
}
[Fact]
@@ -136,7 +135,7 @@ public void DefaultInstallLocation()
.DotNetRoot(null)
.Execute()
.Should().Pass()
- .And.HaveUsedGlobalInstallLocation(HostTestContext.BuiltDotNet.BinPath);
+ .HaveUsedGlobalInstallLocation(HostTestContext.BuiltDotNet.BinPath);
}
}
@@ -155,8 +154,8 @@ public void RegisteredInstallLocation()
.DotNetRoot(null)
.Execute()
.Should().Pass()
- .And.HaveUsedRegisteredInstallLocation(HostTestContext.BuiltDotNet.BinPath)
- .And.HaveUsedGlobalInstallLocation(HostTestContext.BuiltDotNet.BinPath);
+ .HaveUsedRegisteredInstallLocation(HostTestContext.BuiltDotNet.BinPath)
+ .HaveUsedGlobalInstallLocation(HostTestContext.BuiltDotNet.BinPath);
}
}
@@ -191,7 +190,7 @@ public void RegisteredInstallLocation_ArchSpecificLocationIsPickedFirst()
result.Should()
.HaveUsedRegisteredInstallLocation(path2)
- .And.HaveUsedGlobalInstallLocation(path2);
+ .HaveUsedGlobalInstallLocation(path2);
}
}
@@ -214,7 +213,7 @@ public void InstallLocationFile_ReallyLongInstallPathIsParsedCorrectly()
.DotNetRoot(null)
.Execute()
.Should().HaveLookedForDefaultInstallLocation(registeredInstallLocationOverride.PathValueOverride)
- .And.HaveUsedRegisteredInstallLocation(reallyLongPath);
+ .HaveUsedRegisteredInstallLocation(reallyLongPath);
}
}
@@ -266,9 +265,9 @@ public void RegisteredInstallLocation_DotNetInfo_ListOtherArchitectures()
.Execute();
result.Should().Pass()
- .And.HaveStdOutContaining("Other architectures found:")
- .And.NotHaveStdOutContaining(unknownArchInstall.Architecture)
- .And.NotHaveStdOutContaining($"[{unknownArchInstall.Path}]");
+ .HaveStdOutContaining("Other architectures found:")
+ .NotHaveStdOutContaining(unknownArchInstall.Architecture)
+ .NotHaveStdOutContaining($"[{unknownArchInstall.Path}]");
string pathOverride = OperatingSystem.IsWindows() // Host uses short form of base key for Windows
? registeredInstallLocationOverride.PathValueOverride.Replace(Microsoft.Win32.Registry.CurrentUser.Name, "HKCU")
@@ -306,24 +305,24 @@ public void NotFound()
.DotNetRoot(null)
.Execute()
.Should().Fail()
- .And.HaveStdErrContaining("The following locations were searched:")
- .And.HaveStdErrContaining(
+ .HaveStdErrContaining("The following locations were searched:")
+ .HaveStdErrContaining(
$"""
Application directory:
{app.Location}
""")
- .And.HaveStdErrContaining(
+ .HaveStdErrContaining(
$"""
Environment variable:
DOTNET_ROOT_{HostTestContext.BuildArchitecture.ToUpper()} =
DOTNET_ROOT =
""")
- .And.HaveStdErrMatching(
+ .HaveStdErrMatching(
$"""
Registered location:
{System.Text.RegularExpressions.Regex.Escape(registeredLocationOverride)}.*{HostTestContext.BuildArchitecture}.* =
""")
- .And.HaveStdErrContaining(
+ .HaveStdErrContaining(
$"""
Default location:
{defaultLocation}
@@ -398,8 +397,8 @@ public void SearchOptions_AppRelative_MissingPath()
.CaptureStdOut()
.Execute()
.Should().Fail()
- .And.HaveStdErrContaining("The app-relative .NET path is not embedded.")
- .And.ExitWith(Constants.ErrorCode.AppHostExeNotBoundFailure);
+ .HaveStdErrContaining("The app-relative .NET path is not embedded.")
+ .ExitWith(Constants.ErrorCode.AppHostExeNotBoundFailure);
}
[Theory]
diff --git a/src/installer/tests/HostActivation.Tests/InstallLocationCommandResultExtensions.cs b/src/installer/tests/HostActivation.Tests/InstallLocationCommandResultExtensions.cs
index 5687b7a7d5325d..e8b3628e6de96c 100644
--- a/src/installer/tests/HostActivation.Tests/InstallLocationCommandResultExtensions.cs
+++ b/src/installer/tests/HostActivation.Tests/InstallLocationCommandResultExtensions.cs
@@ -5,7 +5,7 @@
using System;
using System.IO;
using System.Runtime.InteropServices;
-using FluentAssertions;
+
using Microsoft.DotNet.Cli.Build.Framework;
using Microsoft.DotNet.CoreSetup.Test;
using Xunit;
@@ -16,12 +16,12 @@ internal static class InstallLocationCommandResultExtensions
{
private static bool IsRunningInWoW64(string rid) => OperatingSystem.IsWindows() && Environment.Is64BitOperatingSystem && rid.Equals("win-x86");
- public static AndConstraint HaveUsedDotNetRootInstallLocation(this CommandResultAssertions assertion, string installLocation, string rid)
+ public static CommandResultAssertions HaveUsedDotNetRootInstallLocation(this CommandResultAssertions assertion, string installLocation, string rid)
{
return assertion.HaveUsedDotNetRootInstallLocation(installLocation, rid, null);
}
- public static AndConstraint HaveUsedDotNetRootInstallLocation(this CommandResultAssertions assertion,
+ public static CommandResultAssertions HaveUsedDotNetRootInstallLocation(this CommandResultAssertions assertion,
string installLocation,
string rid,
string arch)
@@ -36,32 +36,32 @@ public static AndConstraint HaveUsedDotNetRootInstallLo
return assertion.HaveStdErrContaining($"Using environment variable {expectedEnvironmentVariable}=[{installLocation}] as runtime location.");
}
- public static AndConstraint HaveUsedRegisteredInstallLocation(this CommandResultAssertions assertion, string installLocation)
+ public static CommandResultAssertions HaveUsedRegisteredInstallLocation(this CommandResultAssertions assertion, string installLocation)
{
return assertion.HaveStdErrContaining($"Found registered install location '{installLocation}'.");
}
- public static AndConstraint HaveUsedGlobalInstallLocation(this CommandResultAssertions assertion, string installLocation)
+ public static CommandResultAssertions HaveUsedGlobalInstallLocation(this CommandResultAssertions assertion, string installLocation)
{
return assertion.HaveStdErrContaining($"Using global install location [{installLocation}]");
}
- public static AndConstraint HaveUsedAppLocalInstallLocation(this CommandResultAssertions assertion, string installLocation)
+ public static CommandResultAssertions HaveUsedAppLocalInstallLocation(this CommandResultAssertions assertion, string installLocation)
{
return assertion.HaveStdErrContaining($"Using app-local location [{installLocation}]");
}
- public static AndConstraint HaveUsedAppRelativeInstallLocation(this CommandResultAssertions assertion, string installLocation)
+ public static CommandResultAssertions HaveUsedAppRelativeInstallLocation(this CommandResultAssertions assertion, string installLocation)
{
return assertion.HaveStdErrContaining($"Using app-relative location [{installLocation}]");
}
- public static AndConstraint HaveLookedForDefaultInstallLocation(this CommandResultAssertions assertion, string installLocationPath)
+ public static CommandResultAssertions HaveLookedForDefaultInstallLocation(this CommandResultAssertions assertion, string installLocationPath)
{
return assertion.HaveStdErrContaining($"Looking for install_location file in '{Path.Combine(installLocationPath, "install_location")}'.");
}
- public static AndConstraint HaveLookedForArchitectureSpecificInstallLocation(this CommandResultAssertions assertion, string installLocationPath, string architecture)
+ public static CommandResultAssertions HaveLookedForArchitectureSpecificInstallLocation(this CommandResultAssertions assertion, string installLocationPath, string architecture)
{
return assertion.HaveStdErrContaining($"Looking for architecture-specific install_location file in '{Path.Combine(installLocationPath, "install_location_" + architecture.ToLowerInvariant())}'.");
}
diff --git a/src/installer/tests/HostActivation.Tests/InvalidHost.cs b/src/installer/tests/HostActivation.Tests/InvalidHost.cs
index 74e765df798fdb..6de2042911d7e4 100644
--- a/src/installer/tests/HostActivation.Tests/InvalidHost.cs
+++ b/src/installer/tests/HostActivation.Tests/InvalidHost.cs
@@ -4,7 +4,6 @@
using System;
using System.IO;
-using FluentAssertions;
using Microsoft.DotNet.Cli.Build.Framework;
using Microsoft.DotNet.CoreSetup.Test;
using Microsoft.NET.HostModel.AppHost;
@@ -30,8 +29,8 @@ public void AppHost_NotBound()
.Execute();
result.Should().Fail()
- .And.HaveStdErrContaining("This executable is not bound to a managed DLL to execute.")
- .And.ExitWith(Constants.ErrorCode.AppHostExeNotBoundFailure);
+ .HaveStdErrContaining("This executable is not bound to a managed DLL to execute.")
+ .ExitWith(Constants.ErrorCode.AppHostExeNotBoundFailure);
}
[Fact]
@@ -43,7 +42,7 @@ public void AppHost_NotBound_GUI()
.CaptureStdOut()
.Execute()
.Should().Fail()
- .And.HaveStdErrContaining("This executable is not bound to a managed DLL to execute.");
+ .HaveStdErrContaining("This executable is not bound to a managed DLL to execute.");
}
[Fact]
@@ -57,9 +56,9 @@ public void AppHost_NotBound_GUI_TraceFile()
.CaptureStdOut()
.Execute()
.Should().Fail()
- .And.FileExists(traceFilePath)
- .And.FileContains(traceFilePath, "This executable is not bound to a managed DLL to execute.")
- .And.HaveStdErrContaining("This executable is not bound to a managed DLL to execute.");
+ .FileExists(traceFilePath)
+ .FileContains(traceFilePath, "This executable is not bound to a managed DLL to execute.")
+ .HaveStdErrContaining("This executable is not bound to a managed DLL to execute.");
FileUtils.DeleteFileIfPossible(traceFilePath);
}
@@ -73,8 +72,8 @@ public void DotNet_Renamed()
.Execute();
result.Should().Fail()
- .And.HaveStdErrContaining($"Error: cannot execute dotnet when renamed to {Path.GetFileNameWithoutExtension(sharedTestState.RenamedDotNet)}")
- .And.ExitWith(Constants.ErrorCode.EntryPointFailure);
+ .HaveStdErrContaining($"Error: cannot execute dotnet when renamed to {Path.GetFileNameWithoutExtension(sharedTestState.RenamedDotNet)}")
+ .ExitWith(Constants.ErrorCode.EntryPointFailure);
}
public class SharedTestState : IDisposable
diff --git a/src/installer/tests/HostActivation.Tests/MachOHostSigningTests.cs b/src/installer/tests/HostActivation.Tests/MachOHostSigningTests.cs
index 70bc3b86a51eff..dc3b40f12e3645 100644
--- a/src/installer/tests/HostActivation.Tests/MachOHostSigningTests.cs
+++ b/src/installer/tests/HostActivation.Tests/MachOHostSigningTests.cs
@@ -2,7 +2,6 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using Xunit;
-using FluentAssertions;
using System;
using System.IO;
using Microsoft.DotNet.CoreSetup.Test;
@@ -31,7 +30,7 @@ public void SignedAppHostRuns()
.CaptureStdErr()
.CaptureStdOut()
.Execute();
- executedCommand.Should().ExitWith(Constants.ErrorCode.AppHostExeNotBoundFailure);
+ Assert.Equal(Constants.ErrorCode.AppHostExeNotBoundFailure, executedCommand.ExitCode);
}
}
}
diff --git a/src/installer/tests/HostActivation.Tests/NativeHostApis.cs b/src/installer/tests/HostActivation.Tests/NativeHostApis.cs
index 804d7eaa5c91b0..1bd4d86723b4d2 100644
--- a/src/installer/tests/HostActivation.Tests/NativeHostApis.cs
+++ b/src/installer/tests/HostActivation.Tests/NativeHostApis.cs
@@ -5,7 +5,6 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
-using FluentAssertions;
using Microsoft.DotNet.Cli.Build;
using Microsoft.DotNet.CoreSetup.Test;
using Microsoft.DotNet.CoreSetup.Test.HostActivation;
@@ -113,8 +112,8 @@ public void Hostfxr_get_available_sdks()
.EnableTracingAndCaptureOutputs()
.Execute()
.Should().Pass()
- .And.ReturnStatusCode(api, Constants.ErrorCode.Success)
- .And.HaveStdOutContaining($"{api} sdks:[{expectedList}]");
+ .ReturnStatusCode(api, Constants.ErrorCode.Success)
+ .HaveStdOutContaining($"{api} sdks:[{expectedList}]");
}
[Fact]
@@ -134,8 +133,8 @@ public void Hostfxr_resolve_sdk2_NoGlobalJson()
.EnableTracingAndCaptureOutputs()
.Execute()
.Should().Pass()
- .And.ReturnStatusCode(api, Constants.ErrorCode.Success)
- .And.HaveStdOutContaining($"{api} data:[{expectedData}]");
+ .ReturnStatusCode(api, Constants.ErrorCode.Success)
+ .HaveStdOutContaining($"{api} data:[{expectedData}]");
}
[Fact]
@@ -155,8 +154,8 @@ public void Hostfxr_resolve_sdk2_NoGlobalJson_DisallowPrerelease()
.EnableTracingAndCaptureOutputs()
.Execute()
.Should().Pass()
- .And.ReturnStatusCode(api, Constants.ErrorCode.Success)
- .And.HaveStdOutContaining($"{api} data:[{expectedData}]");
+ .ReturnStatusCode(api, Constants.ErrorCode.Success)
+ .HaveStdOutContaining($"{api} data:[{expectedData}]");
}
[Fact]
@@ -184,8 +183,8 @@ public void Hostfxr_resolve_sdk2_GlobalJson_DisallowPrerelease()
.EnableTracingAndCaptureOutputs()
.Execute()
.Should().Pass()
- .And.ReturnStatusCode(api, Constants.ErrorCode.Success)
- .And.HaveStdOutContaining($"{api} data:[{expectedData}]");
+ .ReturnStatusCode(api, Constants.ErrorCode.Success)
+ .HaveStdOutContaining($"{api} data:[{expectedData}]");
}
}
@@ -215,8 +214,8 @@ public void Hostfxr_resolve_sdk2_GlobalJson_Paths()
.EnableTracingAndCaptureOutputs()
.Execute()
.Should().Pass()
- .And.ReturnStatusCode(api, Constants.ErrorCode.Success)
- .And.HaveStdOutContaining($"{api} data:[{expectedData}]");
+ .ReturnStatusCode(api, Constants.ErrorCode.Success)
+ .HaveStdOutContaining($"{api} data:[{expectedData}]");
}
}
@@ -241,8 +240,8 @@ public void Hostfxr_resolve_sdk2_GlobalJson_InvalidJson()
.EnableTracingAndCaptureOutputs()
.Execute()
.Should().Pass()
- .And.ReturnStatusCode(api, Constants.ErrorCode.Success)
- .And.HaveStdOutContaining($"{api} data:[{expectedData}]");
+ .ReturnStatusCode(api, Constants.ErrorCode.Success)
+ .HaveStdOutContaining($"{api} data:[{expectedData}]");
}
}
@@ -268,8 +267,8 @@ public void Hostfxr_resolve_sdk2_GlobalJson_InvalidData()
.EnableTracingAndCaptureOutputs()
.Execute()
.Should().Pass()
- .And.ReturnStatusCode(api, Constants.ErrorCode.Success)
- .And.HaveStdOutContaining($"{api} data:[{expectedData}]");
+ .ReturnStatusCode(api, Constants.ErrorCode.Success)
+ .HaveStdOutContaining($"{api} data:[{expectedData}]");
}
}
@@ -296,8 +295,8 @@ public void Hostfxr_resolve_sdk2_GlobalJson_InvalidDataNoFallback()
.EnableTracingAndCaptureOutputs()
.Execute()
.Should().Pass()
- .And.ReturnStatusCode(api, Constants.ErrorCode.SdkResolveFailure)
- .And.HaveStdOutContaining($"{api} data:[{expectedData}]");
+ .ReturnStatusCode(api, Constants.ErrorCode.SdkResolveFailure)
+ .HaveStdOutContaining($"{api} data:[{expectedData}]");
}
}
@@ -327,12 +326,12 @@ public void Hostfxr_get_dotnet_environment_info_dotnet_root_only()
.EnableTracingAndCaptureOutputs()
.Execute()
.Should().Pass()
- .And.ReturnStatusCode(api, Constants.ErrorCode.Success)
- .And.HaveStdOutContaining($"{api} sdk versions:[{expectedSdkVersions}]")
- .And.HaveStdOutContaining($"{api} sdk paths:[{expectedSdkPaths}]")
- .And.HaveStdOutContaining($"{api} framework names:[{expectedFrameworkNames}]")
- .And.HaveStdOutContaining($"{api} framework versions:[{expectedFrameworkVersions}]")
- .And.HaveStdOutContaining($"{api} framework paths:[{expectedFrameworkPaths}]");
+ .ReturnStatusCode(api, Constants.ErrorCode.Success)
+ .HaveStdOutContaining($"{api} sdk versions:[{expectedSdkVersions}]")
+ .HaveStdOutContaining($"{api} sdk paths:[{expectedSdkPaths}]")
+ .HaveStdOutContaining($"{api} framework names:[{expectedFrameworkNames}]")
+ .HaveStdOutContaining($"{api} framework versions:[{expectedFrameworkVersions}]")
+ .HaveStdOutContaining($"{api} framework paths:[{expectedFrameworkPaths}]");
}
[Fact]
@@ -357,12 +356,12 @@ public void Hostfxr_get_dotnet_environment_info_DisabledVersions()
.EnvironmentVariable(Constants.DisableRuntimeVersions.EnvironmentVariable, string.Join(';', disabledVersions))
.Execute();
result.Should().Pass()
- .And.ReturnStatusCode(api, Constants.ErrorCode.Success)
- .And.HaveStdOutContaining($"{api} sdk versions:[{expectedSdkVersions}]")
- .And.HaveStdOutContaining($"{api} sdk paths:[{expectedSdkPaths}]")
- .And.HaveStdOutContaining($"{api} framework names:[{expectedFrameworkNames}]")
- .And.HaveStdOutContaining($"{api} framework versions:[{expectedFrameworkVersions}]")
- .And.HaveStdOutContaining($"{api} framework paths:[{expectedFrameworkPaths}]");
+ .ReturnStatusCode(api, Constants.ErrorCode.Success)
+ .HaveStdOutContaining($"{api} sdk versions:[{expectedSdkVersions}]")
+ .HaveStdOutContaining($"{api} sdk paths:[{expectedSdkPaths}]")
+ .HaveStdOutContaining($"{api} framework names:[{expectedFrameworkNames}]")
+ .HaveStdOutContaining($"{api} framework versions:[{expectedFrameworkVersions}]")
+ .HaveStdOutContaining($"{api} framework paths:[{expectedFrameworkPaths}]");
foreach (string version in disabledVersions)
{
result.Should().HaveStdErrContaining($"Ignoring disabled version [{version}]");
@@ -377,7 +376,7 @@ public void Hostfxr_get_dotnet_environment_info_global_install_path()
.EnableTracingAndCaptureOutputs()
.Execute()
.Should().Pass()
- .And.ReturnStatusCode(api, Constants.ErrorCode.Success);
+ .ReturnStatusCode(api, Constants.ErrorCode.Success);
}
[Fact]
@@ -388,8 +387,8 @@ public void Hostfxr_get_dotnet_environment_info_result_is_nullptr_fails()
.EnableTracingAndCaptureOutputs()
.Execute()
.Should().Pass()
- .And.ReturnStatusCode(api, Constants.ErrorCode.InvalidArgFailure)
- .And.HaveStdErrContaining($"{api} received an invalid argument: result should not be null.");
+ .ReturnStatusCode(api, Constants.ErrorCode.InvalidArgFailure)
+ .HaveStdErrContaining($"{api} received an invalid argument: result should not be null.");
}
[Fact]
@@ -400,8 +399,8 @@ public void Hostfxr_get_dotnet_environment_info_reserved_is_not_nullptr_fails()
.EnableTracingAndCaptureOutputs()
.Execute()
.Should().Pass()
- .And.ReturnStatusCode(api, Constants.ErrorCode.InvalidArgFailure)
- .And.HaveStdErrContaining($"{api} received an invalid argument: reserved should be null.");
+ .ReturnStatusCode(api, Constants.ErrorCode.InvalidArgFailure)
+ .HaveStdErrContaining($"{api} received an invalid argument: reserved should be null.");
}
[Theory]
@@ -430,8 +429,8 @@ public void Hostfxr_resolve_frameworks_for_runtime_config(bool isMissing, bool w
.CaptureStdErr()
.Execute();
result.Should().Pass()
- .And.NotHaveStdErr()
- .And.ReturnStatusCode(api, isMissing ? Constants.ErrorCode.FrameworkMissingFailure : Constants.ErrorCode.Success);
+ .NotHaveStdErr()
+ .ReturnStatusCode(api, isMissing ? Constants.ErrorCode.FrameworkMissingFailure : Constants.ErrorCode.Success);
if (isMissing)
{
result.Should().ReturnUnresolvedFramework(requested.Name, requested.Version);
@@ -464,8 +463,8 @@ public void Hostfxr_resolve_frameworks_for_runtime_config_SelfContained()
.CaptureStdErr()
.Execute();
result.Should().Pass()
- .And.NotHaveStdErr()
- .And.ReturnStatusCode(api, Constants.ErrorCode.Success);
+ .NotHaveStdErr()
+ .ReturnStatusCode(api, Constants.ErrorCode.Success);
foreach (var framework in includedFrameworks)
{
// All frameworks included in a self-contained config are resolved to be next to the config
@@ -536,8 +535,8 @@ Constants.RollForwardSetting.Major or Constants.RollForwardSetting.LatestMajor
.CaptureStdErr()
.Execute();
result.Should().Pass()
- .And.NotHaveStdErr()
- .And.ReturnStatusCode(api, isMissing ? Constants.ErrorCode.FrameworkMissingFailure : Constants.ErrorCode.Success);
+ .NotHaveStdErr()
+ .ReturnStatusCode(api, isMissing ? Constants.ErrorCode.FrameworkMissingFailure : Constants.ErrorCode.Success);
if (isMissing)
{
result.Should().ReturnUnresolvedFramework(requested.Name, requested.Version);
@@ -587,8 +586,8 @@ public void Hostfxr_resolve_frameworks_for_runtime_config_NoDotnetRoot(bool isMi
.CaptureStdErr()
.Execute();
result.Should().Pass()
- .And.NotHaveStdErr()
- .And.ReturnStatusCode(api, isMissing ? Constants.ErrorCode.FrameworkMissingFailure : Constants.ErrorCode.Success);
+ .NotHaveStdErr()
+ .ReturnStatusCode(api, isMissing ? Constants.ErrorCode.FrameworkMissingFailure : Constants.ErrorCode.Success);
if (isMissing)
{
result.Should().ReturnUnresolvedFramework(requested.Name, requested.Version);
@@ -633,8 +632,8 @@ public void Hostfxr_resolve_frameworks_for_runtime_config_MultipleFrameworks(boo
.CaptureStdErr()
.Execute();
result.Should().Pass()
- .And.NotHaveStdErr()
- .And.ReturnStatusCode(api, isMissing ? Constants.ErrorCode.FrameworkMissingFailure : Constants.ErrorCode.Success);
+ .NotHaveStdErr()
+ .ReturnStatusCode(api, isMissing ? Constants.ErrorCode.FrameworkMissingFailure : Constants.ErrorCode.Success);
foreach (var framework in expectedFrameworks)
{
result.Should().ReturnResolvedFramework(framework.Name, framework.Version, GetFrameworkPath(framework.Name, framework.Version, dotnet.BinPath));
@@ -678,11 +677,11 @@ public void Hostfxr_resolve_frameworks_for_runtime_config_IncompatibleFrameworks
.CaptureStdErr()
.Execute()
.Should().Pass()
- .And.NotHaveStdErr()
- .And.ReturnStatusCode(api, Constants.ErrorCode.FrameworkCompatFailure)
- .And.ReturnResolvedFramework(expectedFramework.Name, expectedFramework.Version, GetFrameworkPath(expectedFramework.Name, expectedFramework.Version, dotnet.BinPath))
- .And.ReturnUnresolvedFramework(incompatibleLower.Name, incompatibleLower.Version)
- .And.ReturnUnresolvedFramework(incompatibleHigher.Name, incompatibleHigher.Version);
+ .NotHaveStdErr()
+ .ReturnStatusCode(api, Constants.ErrorCode.FrameworkCompatFailure)
+ .ReturnResolvedFramework(expectedFramework.Name, expectedFramework.Version, GetFrameworkPath(expectedFramework.Name, expectedFramework.Version, dotnet.BinPath))
+ .ReturnUnresolvedFramework(incompatibleLower.Name, incompatibleLower.Version)
+ .ReturnUnresolvedFramework(incompatibleHigher.Name, incompatibleHigher.Version);
}
}
@@ -710,9 +709,9 @@ public void Hostfxr_resolve_frameworks_for_runtime_config_InvalidConfig()
.CaptureStdErr()
.Execute()
.Should().Pass()
- .And.NotHaveStdErr()
- .And.ReturnStatusCode(api, Constants.ErrorCode.InvalidConfigFile)
- .And.ReturnUnresolvedFramework(requested.Name, requested.Version, frameworkPath);
+ .NotHaveStdErr()
+ .ReturnStatusCode(api, Constants.ErrorCode.InvalidConfigFile)
+ .ReturnUnresolvedFramework(requested.Name, requested.Version, frameworkPath);
}
}
@@ -743,8 +742,8 @@ public void Hostfxr_resolve_frameworks_for_runtime_config_MissingVersion(bool se
.CaptureStdErr()
.Execute()
.Should().Pass()
- .And.HaveStdErrContaining($"Framework '{Constants.MicrosoftNETCoreApp}' is missing a version")
- .And.ReturnStatusCode(api, Constants.ErrorCode.InvalidConfigFile);
+ .HaveStdErrContaining($"Framework '{Constants.MicrosoftNETCoreApp}' is missing a version")
+ .ReturnStatusCode(api, Constants.ErrorCode.InvalidConfigFile);
}
}
@@ -765,10 +764,10 @@ public void HostRuntimeContract_get_runtime_property()
.EnableTracingAndCaptureOutputs()
.Execute()
.Should().Pass()
- .And.HaveStdOutContaining($"APP_CONTEXT_BASE_DIRECTORY = {Path.GetDirectoryName(app.AppDll)}")
- .And.HaveStdOutContaining($"RUNTIME_IDENTIFIER = {HostTestContext.BuildRID}")
- .And.HaveStdOutContaining($"DOES_NOT_EXIST = ")
- .And.HaveStdOutContaining($"ENTRY_ASSEMBLY_NAME = {app.AssemblyName}");
+ .HaveStdOutContaining($"APP_CONTEXT_BASE_DIRECTORY = {Path.GetDirectoryName(app.AppDll)}")
+ .HaveStdOutContaining($"RUNTIME_IDENTIFIER = {HostTestContext.BuildRID}")
+ .HaveStdOutContaining($"DOES_NOT_EXIST = ")
+ .HaveStdOutContaining($"ENTRY_ASSEMBLY_NAME = {app.AssemblyName}");
}
[Fact]
@@ -778,7 +777,7 @@ public void HostRuntimeContract_bundle_probe()
.EnableTracingAndCaptureOutputs()
.Execute()
.Should().Pass()
- .And.HaveStdOutContaining("host_runtime_contract.bundle_probe is not set");
+ .HaveStdOutContaining("host_runtime_contract.bundle_probe is not set");
}
private static string GetFrameworkPath(string name, string version, string dotnetRoot)
@@ -829,7 +828,7 @@ public static AndConstraint ReturnUnresolvedFramework(t
{
string api = ApiNames.hostfxr_resolve_frameworks_for_runtime_config;
return assertion.HaveStdOutContaining($"{api} unresolved_framework: name={name}, requested_version={version}, path=[{path}]")
- .And.NotHaveStdOutContaining($"{api} resolved_framework: name={name}");
+ .NotHaveStdOutContaining($"{api} resolved_framework: name={name}");
}
}
}
diff --git a/src/installer/tests/HostActivation.Tests/NativeHosting/HostContextResultExtensions.cs b/src/installer/tests/HostActivation.Tests/NativeHosting/HostContextResultExtensions.cs
index 4a4e55db762a80..bbd21da95bb1b5 100644
--- a/src/installer/tests/HostActivation.Tests/NativeHosting/HostContextResultExtensions.cs
+++ b/src/installer/tests/HostActivation.Tests/NativeHosting/HostContextResultExtensions.cs
@@ -1,119 +1,117 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-using FluentAssertions;
-
namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.NativeHosting
{
internal static class HostContextResultExtensions
{
- public static AndConstraint ExecuteSelfContained(this CommandResultAssertions assertion, bool selfContained)
+ public static CommandResultAssertions ExecuteSelfContained(this CommandResultAssertions assertion, bool selfContained)
{
return assertion.HaveStdErrContaining($"Executing as a {(selfContained ? "self-contained" : "framework-dependent")} app");
}
- public static AndConstraint ExecuteAssemblyMock(this CommandResultAssertions assertion, string appPath, string[] appArgs)
+ public static CommandResultAssertions ExecuteAssemblyMock(this CommandResultAssertions assertion, string appPath, string[] appArgs)
{
var constraint = assertion.HaveStdOutContaining("mock coreclr_initialize() called")
- .And.HaveStdOutContaining("mock coreclr_execute_assembly() called")
- .And.HaveStdOutContaining($"mock managedAssemblyPath:{appPath}")
- .And.HaveStdOutContaining($"mock argc:{appArgs.Length}")
- .And.HaveStdOutContaining("mock coreclr_shutdown_2() called");
+ .HaveStdOutContaining("mock coreclr_execute_assembly() called")
+ .HaveStdOutContaining($"mock managedAssemblyPath:{appPath}")
+ .HaveStdOutContaining($"mock argc:{appArgs.Length}")
+ .HaveStdOutContaining("mock coreclr_shutdown_2() called");
for (int i = 0; i < appArgs.Length; ++i)
{
- constraint = constraint.And.HaveStdOutContaining($"mock argv[{i}] = {appArgs[i]}");
+ constraint = constraint.HaveStdOutContaining($"mock argv[{i}] = {appArgs[i]}");
}
return constraint;
}
- public static AndConstraint CreateDelegateMock(this CommandResultAssertions assertion)
+ public static CommandResultAssertions CreateDelegateMock(this CommandResultAssertions assertion)
{
return assertion.HaveStdOutContaining("mock coreclr_initialize() called")
- .And.HaveStdOutContaining("mock coreclr_create_delegate() called");
+ .HaveStdOutContaining("mock coreclr_create_delegate() called");
}
- public static AndConstraint CreateDelegateMock_COM(this CommandResultAssertions assertion)
+ public static CommandResultAssertions CreateDelegateMock_COM(this CommandResultAssertions assertion)
{
return assertion.CreateDelegateMock()
- .And.HaveStdOutContaining("mock entryPointAssemblyName:System.Private.CoreLib")
- .And.HaveStdOutContaining("mock entryPointTypeName:Internal.Runtime.InteropServices.ComActivator")
- .And.HaveStdOutContaining("mock entryPointMethodName:GetClassFactoryForTypeInternal");
+ .HaveStdOutContaining("mock entryPointAssemblyName:System.Private.CoreLib")
+ .HaveStdOutContaining("mock entryPointTypeName:Internal.Runtime.InteropServices.ComActivator")
+ .HaveStdOutContaining("mock entryPointMethodName:GetClassFactoryForTypeInternal");
}
- public static AndConstraint CreateDelegateMock_InMemoryAssembly(this CommandResultAssertions assertion)
+ public static CommandResultAssertions CreateDelegateMock_InMemoryAssembly(this CommandResultAssertions assertion)
{
return assertion.CreateDelegateMock()
- .And.HaveStdOutContaining("mock entryPointAssemblyName:System.Private.CoreLib")
- .And.HaveStdOutContaining("mock entryPointTypeName:Internal.Runtime.InteropServices.InMemoryAssemblyLoader")
- .And.HaveStdOutContaining("mock entryPointMethodName:LoadInMemoryAssembly");
+ .HaveStdOutContaining("mock entryPointAssemblyName:System.Private.CoreLib")
+ .HaveStdOutContaining("mock entryPointTypeName:Internal.Runtime.InteropServices.InMemoryAssemblyLoader")
+ .HaveStdOutContaining("mock entryPointMethodName:LoadInMemoryAssembly");
}
- public static AndConstraint HavePropertyMock(this CommandResultAssertions assertion, string name, string value)
+ public static CommandResultAssertions HavePropertyMock(this CommandResultAssertions assertion, string name, string value)
{
return assertion.HaveStdOutContaining($"mock property[{name}] = {value}");
}
- public static AndConstraint NotHavePropertyMock(this CommandResultAssertions assertion, string name)
+ public static CommandResultAssertions NotHavePropertyMock(this CommandResultAssertions assertion, string name)
{
return assertion.NotHaveStdOutContaining($"mock property[{name}]");
}
- public static AndConstraint InitializeContextForApp(this CommandResultAssertions assertion, string path)
+ public static CommandResultAssertions InitializeContextForApp(this CommandResultAssertions assertion, string path)
{
return assertion.HaveStdErrContaining($"Initialized context for app: {path}");
}
- public static AndConstraint InitializeContextForConfig(this CommandResultAssertions assertion, string path)
+ public static CommandResultAssertions InitializeContextForConfig(this CommandResultAssertions assertion, string path)
{
return assertion.HaveStdErrContaining($"Initialized context for config: {path}");
}
- public static AndConstraint InitializeSecondaryContext(this CommandResultAssertions assertion, string path, int statusCode)
+ public static CommandResultAssertions InitializeSecondaryContext(this CommandResultAssertions assertion, string path, int statusCode)
{
return assertion.HaveStdErrContaining($"Initialized secondary context for config: {path}")
- .And.HaveStdOutContaining($"hostfxr_initialize_for_runtime_config succeeded: 0x{statusCode.ToString("x")}");
+ .HaveStdOutContaining($"hostfxr_initialize_for_runtime_config succeeded: 0x{statusCode.ToString("x")}");
}
- public static AndConstraint FailToInitializeContextForConfig(this CommandResultAssertions assertion, int errorCode)
+ public static CommandResultAssertions FailToInitializeContextForConfig(this CommandResultAssertions assertion, int errorCode)
{
return assertion.HaveStdOutContaining($"hostfxr_initialize_for_runtime_config failed: 0x{errorCode.ToString("x")}");
}
- public static AndConstraint GetRuntimePropertyValue(this CommandResultAssertions assertion, string prefix, string name, string value)
+ public static CommandResultAssertions GetRuntimePropertyValue(this CommandResultAssertions assertion, string prefix, string name, string value)
{
return assertion.HaveStdOutContaining($"{prefix}hostfxr_get_runtime_property_value succeeded for property: {name}={value}");
}
- public static AndConstraint FailToGetRuntimePropertyValue(this CommandResultAssertions assertion, string prefix, string name, int errorCode)
+ public static CommandResultAssertions FailToGetRuntimePropertyValue(this CommandResultAssertions assertion, string prefix, string name, int errorCode)
{
return assertion.HaveStdOutContaining($"{prefix}hostfxr_get_runtime_property_value failed for property: {name} - 0x{errorCode.ToString("x")}");
}
- public static AndConstraint SetRuntimePropertyValue(this CommandResultAssertions assertion, string prefix, string name)
+ public static CommandResultAssertions SetRuntimePropertyValue(this CommandResultAssertions assertion, string prefix, string name)
{
return assertion.HaveStdOutContaining($"{prefix}hostfxr_set_runtime_property_value succeeded for property: {name}");
}
- public static AndConstraint FailToSetRuntimePropertyValue(this CommandResultAssertions assertion, string prefix, string name, int errorCode)
+ public static CommandResultAssertions FailToSetRuntimePropertyValue(this CommandResultAssertions assertion, string prefix, string name, int errorCode)
{
return assertion.HaveStdOutContaining($"{prefix}hostfxr_set_runtime_property_value failed for property: {name} - 0x{errorCode.ToString("x")}");
}
- public static AndConstraint GetRuntimePropertiesIncludes(this CommandResultAssertions assertion, string prefix, string name, string value)
+ public static CommandResultAssertions GetRuntimePropertiesIncludes(this CommandResultAssertions assertion, string prefix, string name, string value)
{
return assertion.HaveStdOutContaining($"{prefix}hostfxr_get_runtime_properties succeeded")
- .And.HaveStdOutContaining($"{prefix}hostfxr_get_runtime_properties: {name}={value}");
+ .HaveStdOutContaining($"{prefix}hostfxr_get_runtime_properties: {name}={value}");
}
- public static AndConstraint GetRuntimePropertiesExcludes(this CommandResultAssertions assertion, string prefix, string name)
+ public static CommandResultAssertions GetRuntimePropertiesExcludes(this CommandResultAssertions assertion, string prefix, string name)
{
return assertion.HaveStdOutContaining($"{prefix}hostfxr_get_runtime_properties succeeded")
- .And.NotHaveStdOutContaining($"{prefix}hostfxr_get_runtime_properties: {name}");
+ .NotHaveStdOutContaining($"{prefix}hostfxr_get_runtime_properties: {name}");
}
- public static AndConstraint FailToGetRuntimeProperties(this CommandResultAssertions assertion, string prefix, int errorCode)
+ public static CommandResultAssertions FailToGetRuntimeProperties(this CommandResultAssertions assertion, string prefix, int errorCode)
{
return assertion.HaveStdOutContaining($"{prefix}hostfxr_get_runtime_properties failed - 0x{errorCode.ToString("x")}");
}
diff --git a/src/installer/tests/HostActivation.Tests/NativeUnitTests.cs b/src/installer/tests/HostActivation.Tests/NativeUnitTests.cs
index 4b73a613a2e60e..8eb5f47c28701e 100644
--- a/src/installer/tests/HostActivation.Tests/NativeUnitTests.cs
+++ b/src/installer/tests/HostActivation.Tests/NativeUnitTests.cs
@@ -2,7 +2,6 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using Xunit;
-using FluentAssertions;
using System;
using System.IO;
using Microsoft.DotNet.CoreSetup.Test;
@@ -20,8 +19,7 @@ public void Native_Test_Fx_Ver()
Command testCommand = Command.Create(testPath);
testCommand
.Execute()
- .Should()
- .Pass();
+ .Should().Pass();
}
}
}
diff --git a/src/installer/tests/HostActivation.Tests/SDKResolutionCommandResultExtensions.cs b/src/installer/tests/HostActivation.Tests/SDKResolutionCommandResultExtensions.cs
index 4e01bf7ebc5943..c0ce9993a9ac90 100644
--- a/src/installer/tests/HostActivation.Tests/SDKResolutionCommandResultExtensions.cs
+++ b/src/installer/tests/HostActivation.Tests/SDKResolutionCommandResultExtensions.cs
@@ -1,39 +1,38 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-using FluentAssertions;
using Microsoft.DotNet.CoreSetup.Test;
namespace HostActivation.Tests
{
internal static class SDKResolutionCommandResultExtensions
{
- public static AndConstraint FindAnySdk(this CommandResultAssertions assertion, bool shouldFindAnySdk)
+ public static CommandResultAssertions FindAnySdk(this CommandResultAssertions assertion, bool shouldFindAnySdk)
{
string noSdkMessage = "No .NET SDKs were found";
return shouldFindAnySdk
? assertion.NotHaveStdErrContaining(noSdkMessage)
: assertion.HaveStdErrContaining(noSdkMessage)
- .And.HaveStdErrContaining("Download a .NET SDK:");
+ .HaveStdErrContaining("Download a .NET SDK:");
}
- public static AndConstraint NotFindCompatibleSdk(this CommandResultAssertions assertion, string globalJsonPath = null, string requestedVersion = null)
+ public static CommandResultAssertions NotFindCompatibleSdk(this CommandResultAssertions assertion, string globalJsonPath = null, string requestedVersion = null)
{
var constraint = assertion.HaveStdErrContaining("compatible .NET SDK was not found");
if (globalJsonPath is not null)
{
- constraint = constraint.And.HaveStdErrContaining($"global.json file: {globalJsonPath}");
+ constraint = constraint.HaveStdErrContaining($"global.json file: {globalJsonPath}");
}
if (requestedVersion is not null)
{
- constraint = constraint.And.HaveStdErrContaining($"Requested SDK version: {requestedVersion}");
+ constraint = constraint.HaveStdErrContaining($"Requested SDK version: {requestedVersion}");
}
if (globalJsonPath is not null && requestedVersion is not null)
{
- constraint = constraint.And.HaveStdErrContaining($"Install the [{requestedVersion}] .NET SDK or update [{globalJsonPath}] to match an installed SDK.");
+ constraint = constraint.HaveStdErrContaining($"Install the [{requestedVersion}] .NET SDK or update [{globalJsonPath}] to match an installed SDK.");
}
return constraint;
diff --git a/src/installer/tests/HostActivation.Tests/SelfContainedAppLaunch.cs b/src/installer/tests/HostActivation.Tests/SelfContainedAppLaunch.cs
index a5379109930032..4a6ba2aa6c4dbc 100644
--- a/src/installer/tests/HostActivation.Tests/SelfContainedAppLaunch.cs
+++ b/src/installer/tests/HostActivation.Tests/SelfContainedAppLaunch.cs
@@ -5,7 +5,6 @@
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
-using FluentAssertions;
using Microsoft.DotNet.Cli.Build.Framework;
using Microsoft.DotNet.CoreSetup.Test;
using Microsoft.NET.HostModel.AppHost;
@@ -36,8 +35,8 @@ public void Default()
.CaptureStdOut()
.Execute()
.Should().Pass()
- .And.HaveStdOutContaining("Hello World")
- .And.HaveStdOutContaining(HostTestContext.MicrosoftNETCoreAppVersion);
+ .HaveStdOutContaining("Hello World")
+ .HaveStdOutContaining(HostTestContext.MicrosoftNETCoreAppVersion);
if (OperatingSystem.IsWindows())
{
@@ -63,8 +62,8 @@ public void AppHost_DisableCetCompat()
.CaptureStdOut()
.Execute()
.Should().Pass()
- .And.HaveStdOutContaining("Hello World")
- .And.HaveStdOutContaining(HostTestContext.MicrosoftNETCoreAppVersion);
+ .HaveStdOutContaining("Hello World")
+ .HaveStdOutContaining(HostTestContext.MicrosoftNETCoreAppVersion);
}
[Fact]
@@ -82,17 +81,17 @@ public void NoDepsJson_NoRuntimeConfig()
.Execute()
.Should().Pass()
// Note that this is an exact match - we don't expect any output from the host itself
- .And.HaveStdOut($"Hello World!{Environment.NewLine}{Environment.NewLine}.NET {HostTestContext.MicrosoftNETCoreAppVersion}{Environment.NewLine}")
- .And.NotHaveStdErr();
+ .HaveStdOut($"Hello World!{Environment.NewLine}{Environment.NewLine}.NET {HostTestContext.MicrosoftNETCoreAppVersion}{Environment.NewLine}")
+ .NotHaveStdErr();
// Make sure tracing indicates there is no runtime config and no deps json
Command.Create(app.AppExe)
.EnableTracingAndCaptureOutputs()
.Execute()
.Should().Pass()
- .And.HaveStdOut($"Hello World!{Environment.NewLine}{Environment.NewLine}.NET {HostTestContext.MicrosoftNETCoreAppVersion}{Environment.NewLine}")
- .And.HaveStdErrContaining($"Runtime config does not exist at [{app.RuntimeConfigJson}]")
- .And.HaveStdErrContaining($"Dependencies manifest does not exist at [{app.DepsJson}]");
+ .HaveStdOut($"Hello World!{Environment.NewLine}{Environment.NewLine}.NET {HostTestContext.MicrosoftNETCoreAppVersion}{Environment.NewLine}")
+ .HaveStdErrContaining($"Runtime config does not exist at [{app.RuntimeConfigJson}]")
+ .HaveStdErrContaining($"Dependencies manifest does not exist at [{app.DepsJson}]");
}
[Fact]
@@ -108,8 +107,8 @@ public void RenameApphost()
.CaptureStdOut()
.Execute()
.Should().Pass()
- .And.HaveStdOutContaining("Hello World")
- .And.HaveStdOutContaining(HostTestContext.MicrosoftNETCoreAppVersion);
+ .HaveStdOutContaining("Hello World")
+ .HaveStdOutContaining(HostTestContext.MicrosoftNETCoreAppVersion);
}
[Fact]
@@ -135,8 +134,8 @@ public void RelativeEmbeddedPath()
.CaptureStdOut()
.Execute()
.Should().Pass()
- .And.HaveStdOutContaining("Hello World")
- .And.HaveStdOutContaining(HostTestContext.MicrosoftNETCoreAppVersion);
+ .HaveStdOutContaining("Hello World")
+ .HaveStdOutContaining(HostTestContext.MicrosoftNETCoreAppVersion);
}
[Fact]
@@ -158,8 +157,8 @@ public void DotNetRoot_IncorrectLayout_Fails()
.DotNetRoot(app.Location)
.Execute()
.Should().Fail()
- .And.HaveUsedDotNetRootInstallLocation(Path.GetFullPath(app.Location), HostTestContext.BuildRID)
- .And.HaveStdErrContaining($"The required library {Binaries.HostFxr.FileName} could not be found.");
+ .HaveUsedDotNetRootInstallLocation(Path.GetFullPath(app.Location), HostTestContext.BuildRID)
+ .HaveStdErrContaining($"The required library {Binaries.HostFxr.FileName} could not be found.");
}
[Fact]
@@ -172,8 +171,8 @@ public void Exe_activation_of_GUI_App()
.CaptureStdOut()
.Execute()
.Should().Pass()
- .And.HaveStdOutContaining("Hello World")
- .And.HaveStdOutContaining(HostTestContext.MicrosoftNETCoreAppVersion);
+ .HaveStdOutContaining("Hello World")
+ .HaveStdOutContaining(HostTestContext.MicrosoftNETCoreAppVersion);
appExe = $@"\\.\{sharedTestState.App.AppExe}";
Command.Create(appExe)
@@ -181,8 +180,8 @@ public void Exe_activation_of_GUI_App()
.CaptureStdOut()
.Execute()
.Should().Pass()
- .And.HaveStdOutContaining("Hello World")
- .And.HaveStdOutContaining(HostTestContext.MicrosoftNETCoreAppVersion);
+ .HaveStdOutContaining("Hello World")
+ .HaveStdOutContaining(HostTestContext.MicrosoftNETCoreAppVersion);
}
[Fact]
@@ -225,9 +224,9 @@ public void CustomRuntimeLocation()
.EnableTracingAndCaptureOutputs()
.Execute()
.Should().Pass()
- .And.HaveStdOutContaining("Hello World")
- .And.HaveStdOutContaining(HostTestContext.MicrosoftNETCoreAppVersion)
- .And.HaveStdErrContaining($"CoreCLR path = '{Path.Join(app.Location, subdirectory, Binaries.CoreClr.FileName)}'");
+ .HaveStdOutContaining("Hello World")
+ .HaveStdOutContaining(HostTestContext.MicrosoftNETCoreAppVersion)
+ .HaveStdErrContaining($"CoreCLR path = '{Path.Join(app.Location, subdirectory, Binaries.CoreClr.FileName)}'");
}
public class SharedTestState : IDisposable
diff --git a/src/installer/tests/HostActivation.Tests/SymbolicLinks.cs b/src/installer/tests/HostActivation.Tests/SymbolicLinks.cs
index a80d9c9e014e90..9228cec0850b48 100644
--- a/src/installer/tests/HostActivation.Tests/SymbolicLinks.cs
+++ b/src/installer/tests/HostActivation.Tests/SymbolicLinks.cs
@@ -7,7 +7,6 @@
using System.Linq;
using System.Runtime.InteropServices;
-using FluentAssertions;
using Microsoft.DotNet.Cli.Build.Framework;
using Microsoft.DotNet.CoreSetup.Test;
using Xunit;
@@ -54,7 +53,7 @@ public void Symlink_all_files_fx(string symlinkRelativePath)
// * Unix: The apphost will look next to the resolved apphost for the app dll and find the real thing
result
.Should().Pass()
- .And.HaveStdOutContaining("Hello World");
+ .HaveStdOutContaining("Hello World");
}
finally
{
@@ -121,14 +120,14 @@ public void Symlink_split_files_fx(string symlinkRelativePath)
// On Windows, the apphost will look next to the symlink for the app dll and find the symlinks
result
.Should().Pass()
- .And.HaveStdOutContaining("Hello World");
+ .HaveStdOutContaining("Hello World");
}
else
{
// On Unix, the apphost will not find the app files next to the symlink
result
.Should().Fail()
- .And.HaveStdErrContaining("The application to execute does not exist");
+ .HaveStdErrContaining("The application to execute does not exist");
}
}
finally
@@ -171,7 +170,7 @@ public void Symlink_all_files_self_contained(string symlinkRelativePath)
// * Unix: The apphost will look next to the resolved apphost for the files and find the real thing
result
.Should().Pass()
- .And.HaveStdOutContaining("Hello World");
+ .HaveStdOutContaining("Hello World");
}
finally
{
@@ -203,13 +202,13 @@ public void Run_apphost_behind_symlink(string symlinkRelativePath)
{
result
.Should().Fail()
- .And.HaveStdErrContaining("The application to execute does not exist");
+ .HaveStdErrContaining("The application to execute does not exist");
}
else
{
result
.Should().Pass()
- .And.HaveStdOutContaining("Hello World");
+ .HaveStdOutContaining("Hello World");
}
}
}
@@ -244,13 +243,13 @@ public void Run_apphost_behind_transitive_symlinks(string firstSymlinkRelativePa
{
result
.Should().Fail()
- .And.HaveStdErrContaining("The application to execute does not exist");
+ .HaveStdErrContaining("The application to execute does not exist");
}
else
{
result
.Should().Pass()
- .And.HaveStdOutContaining("Hello World");
+ .HaveStdOutContaining("Hello World");
}
}
}
@@ -279,13 +278,13 @@ public void Run_framework_dependent_app_behind_symlink(string symlinkRelativePat
{
result
.Should().Fail()
- .And.HaveStdErrContaining("The application to execute does not exist");
+ .HaveStdErrContaining("The application to execute does not exist");
}
else
{
result
.Should().Pass()
- .And.HaveStdOutContaining("Hello World");
+ .HaveStdOutContaining("Hello World");
}
}
}
@@ -306,7 +305,7 @@ public void Run_framework_dependent_app_with_runtime_behind_symlink()
.CaptureStdOut()
.Execute()
.Should().Pass()
- .And.HaveStdOutContaining("Hello World");
+ .HaveStdOutContaining("Hello World");
}
}
@@ -326,7 +325,7 @@ public void Put_app_directory_behind_symlink()
.CaptureStdOut()
.Execute()
.Should().Pass()
- .And.HaveStdOutContaining("Hello World");
+ .HaveStdOutContaining("Hello World");
}
}
@@ -347,13 +346,13 @@ public void Put_dotnet_behind_symlink()
{
result
.Should().Fail()
- .And.HaveStdErrContaining($"[{Path.Combine(testDir.Location, "host", "fxr")}] does not exist");
+ .HaveStdErrContaining($"[{Path.Combine(testDir.Location, "host", "fxr")}] does not exist");
}
else
{
result
.Should().Pass()
- .And.HaveStdOutContaining("Hello World");
+ .HaveStdOutContaining("Hello World");
}
}
}
@@ -374,7 +373,7 @@ public void Put_app_directory_behind_symlink_and_use_dotnet()
.CaptureStdOut()
.Execute()
.Should().Pass()
- .And.HaveStdOutContaining("Hello World");
+ .HaveStdOutContaining("Hello World");
}
}
@@ -400,7 +399,7 @@ public void Put_satellite_assembly_behind_symlink()
.CaptureStdOut()
.Execute()
.Should().Pass()
- .And.HaveStdOutContaining("[kn-IN]! [ta-IN]! [default]!");
+ .HaveStdOutContaining("[kn-IN]! [ta-IN]! [default]!");
}
}
diff --git a/src/installer/tests/Microsoft.NET.HostModel.Tests/AppHost/CreateAppHost.cs b/src/installer/tests/Microsoft.NET.HostModel.Tests/AppHost/CreateAppHost.cs
index dc69ddb8adc80a..c43464b5b90eee 100644
--- a/src/installer/tests/Microsoft.NET.HostModel.Tests/AppHost/CreateAppHost.cs
+++ b/src/installer/tests/Microsoft.NET.HostModel.Tests/AppHost/CreateAppHost.cs
@@ -10,7 +10,6 @@
using System.Runtime.CompilerServices;
using System.Text;
-using FluentAssertions;
using Microsoft.NET.HostModel.MachO.CodeSign;
using Microsoft.NET.HostModel.MachO;
using Microsoft.DotNet.Cli.Build.Framework;
@@ -54,16 +53,11 @@ public void EmbedAppBinaryPath()
byte[] binaryPathBlob = Encoding.UTF8.GetBytes(appBinaryFilePath);
byte[] result = File.ReadAllBytes(destinationFilePath);
- result
+ Assert.Equal(binaryPathBlob, result
.Skip(WindowsFileHeader.Length)
- .Take(binaryPathBlob.Length)
- .Should()
- .BeEquivalentTo(binaryPathBlob);
-
- BitConverter
- .ToUInt16(result, SubsystemOffset)
- .Should()
- .Be((ushort)Subsystem.WindowsCui);
+ .Take(binaryPathBlob.Length));
+
+ Assert.Equal((ushort)Subsystem.WindowsCui, BitConverter.ToUInt16(result, SubsystemOffset));
}
}
@@ -86,7 +80,7 @@ public void PlaceholderHashNotFound_Fails()
destinationFilePath,
appBinaryFilePath));
- File.Exists(destinationFilePath).Should().BeFalse();
+ Assert.False(File.Exists(destinationFilePath));
}
}
@@ -105,7 +99,7 @@ public void AppBinaryPathTooLong_Fails()
destinationFilePath,
appBinaryFilePath));
- File.Exists(destinationFilePath).Should().BeFalse();
+ Assert.False(File.Exists(destinationFilePath));
}
}
@@ -129,7 +123,7 @@ public void AppRelativePathRooted_Fails()
"app.dll",
dotNetSearchOptions: options));
- File.Exists(destinationFilePath).Should().BeFalse();
+ Assert.False(File.Exists(destinationFilePath));
}
}
@@ -153,7 +147,7 @@ public void AppRelativePathTooLong_Fails()
"app.dll",
dotNetSearchOptions: options));
- File.Exists(destinationFilePath).Should().BeFalse();
+ Assert.False(File.Exists(destinationFilePath));
}
}
@@ -172,10 +166,7 @@ public void GUISubsystem_WindowsPEFile()
appBinaryFilePath,
windowsGraphicalUserInterface: true);
- BitConverter
- .ToUInt16(File.ReadAllBytes(destinationFilePath), SubsystemOffset)
- .Should()
- .Be((ushort)Subsystem.WindowsGui);
+ Assert.Equal((ushort)Subsystem.WindowsGui, BitConverter.ToUInt16(File.ReadAllBytes(destinationFilePath), SubsystemOffset));
Assert.Equal((ushort)Subsystem.WindowsGui, PEUtils.GetWindowsGraphicalUserInterfaceBit(destinationFilePath));
}
@@ -202,7 +193,7 @@ public void GUISubsystem_NonWindowsPEFile_Fails()
appBinaryFilePath,
windowsGraphicalUserInterface: true));
- File.Exists(destinationFilePath).Should().BeFalse();
+ Assert.False(File.Exists(destinationFilePath));
}
}
@@ -227,7 +218,7 @@ public void GUISubsystem_WrongDefault_Fails()
appBinaryFilePath,
windowsGraphicalUserInterface: true));
- File.Exists(destinationFilePath).Should().BeFalse();
+ Assert.False(File.Exists(destinationFilePath));
}
}
@@ -256,9 +247,7 @@ public void ExecutableImage()
// assert that the generated app has executable permissions
// despite different permissions on the template binary.
- File.GetUnixFileMode(destinationFilePath)
- .Should()
- .Be(expectedPermissions);
+ Assert.Equal(expectedPermissions, File.GetUnixFileMode(destinationFilePath));
}
[Theory]
@@ -282,7 +271,7 @@ public void CodeSignMachOAppHost(string subdir)
enableMacOSCodeSign: true);
// Validate that there is a signature present in the apphost Mach file
- SigningTests.IsSigned(destinationFilePath).Should().BeTrue();
+ Assert.True(SigningTests.IsSigned(destinationFilePath));
}
}
@@ -345,7 +334,7 @@ public void CodeSignMockMachOAppHost(string subdir)
enableMacOSCodeSign: true);
// Validate that there is a signature present in the apphost Mach file
- SigningTests.IsSigned(destinationFilePath).Should().BeTrue();
+ Assert.True(SigningTests.IsSigned(destinationFilePath));
}
}
@@ -370,7 +359,7 @@ public void DoesNotCodeSignAppHostByDefault()
}
var (exitCode, stdErr) = Codesign.Run("-d", destinationFilePath);
- stdErr.Should().Contain($"{Path.GetFullPath(destinationFilePath)}: code object is not signed at all");
+ Assert.Contains($"{Path.GetFullPath(destinationFilePath)}: code object is not signed at all", stdErr);
}
}
diff --git a/src/installer/tests/Microsoft.NET.HostModel.Tests/Bundle/BundlerConsistencyTests.cs b/src/installer/tests/Microsoft.NET.HostModel.Tests/Bundle/BundlerConsistencyTests.cs
index 327ae29f2c47a9..26e07a1fcf5830 100644
--- a/src/installer/tests/Microsoft.NET.HostModel.Tests/Bundle/BundlerConsistencyTests.cs
+++ b/src/installer/tests/Microsoft.NET.HostModel.Tests/Bundle/BundlerConsistencyTests.cs
@@ -8,7 +8,6 @@
using System.Linq;
using System.Runtime.InteropServices;
-using FluentAssertions;
using Microsoft.DotNet.Cli.Build.Framework;
using Microsoft.DotNet.CoreSetup;
using Microsoft.DotNet.CoreSetup.Test;
@@ -131,7 +130,7 @@ public void DuplicateBundleRelativePath_Fails()
Assert.Throws(() => bundler.GenerateBundle(fileSpecs))
.Message
.Should().Contain("rel/app.repeat")
- .And.Contain(sharedTestState.App.AppDll);
+ .Contain(sharedTestState.App.AppDll);
}
[Fact]
@@ -232,9 +231,9 @@ public void MultipleDuplicateBundleRelativePath_Fails()
Assert.Throws(() => bundler.GenerateBundle(fileSpecs))
.Message
.Should().Contain("rel/system.repeat.dll")
- .And.NotContain("rel/app.repeat.dll")
- .And.Contain(appPath)
- .And.Contain(systemLibPath);
+ .NotContain("rel/app.repeat.dll")
+ .Contain(appPath)
+ .Contain(systemLibPath);
}
[Fact]
diff --git a/src/installer/tests/Microsoft.NET.HostModel.Tests/MachObjectSigning/SigningTests.cs b/src/installer/tests/Microsoft.NET.HostModel.Tests/MachObjectSigning/SigningTests.cs
index 653ac085423938..62cc1d0119366c 100644
--- a/src/installer/tests/Microsoft.NET.HostModel.Tests/MachObjectSigning/SigningTests.cs
+++ b/src/installer/tests/Microsoft.NET.HostModel.Tests/MachObjectSigning/SigningTests.cs
@@ -13,7 +13,6 @@
using Microsoft.DotNet.CoreSetup;
using Microsoft.DotNet.CoreSetup.Test;
using Xunit;
-using FluentAssertions;
using System.IO.MemoryMappedFiles;
using System.Collections;
using System.Collections.Generic;
diff --git a/src/installer/tests/TestUtils/Assertions/CommandResultAssertions.cs b/src/installer/tests/TestUtils/Assertions/CommandResultAssertions.cs
index f2331aec6d69a2..1a3834c356bda6 100644
--- a/src/installer/tests/TestUtils/Assertions/CommandResultAssertions.cs
+++ b/src/installer/tests/TestUtils/Assertions/CommandResultAssertions.cs
@@ -3,9 +3,8 @@
using System;
using System.Text.RegularExpressions;
-using FluentAssertions;
-using FluentAssertions.Execution;
using Microsoft.DotNet.Cli.Build.Framework;
+using Xunit;
namespace Microsoft.DotNet.CoreSetup.Test
{
@@ -13,144 +12,123 @@ public class CommandResultAssertions
{
public CommandResult Result { get; }
- public AssertionChain CurrentAssertionChain { get; }
-
- public CommandResultAssertions(CommandResult commandResult, AssertionChain assertionChain)
+ public CommandResultAssertions(CommandResult commandResult)
{
Result = commandResult;
- CurrentAssertionChain = assertionChain;
}
- public AndConstraint ExitWith(int expectedExitCode)
+ public CommandResultAssertions ExitWith(int expectedExitCode)
{
// Some Unix systems will have 8 bit exit codes
if (!OperatingSystem.IsWindows())
expectedExitCode = expectedExitCode & 0xFF;
- CurrentAssertionChain.ForCondition(Result.ExitCode == expectedExitCode)
- .FailWith($"Expected command to exit with {expectedExitCode} but it did not.{GetDiagnosticsInfo()}");
- return new AndConstraint(this);
+ Assert.True(Result.ExitCode == expectedExitCode, $"Expected command to exit with {expectedExitCode} but it did not.{GetDiagnosticsInfo()}");
+ return this;
}
- public AndConstraint Pass()
+ public CommandResultAssertions Pass()
{
- CurrentAssertionChain.ForCondition(Result.ExitCode == 0)
- .FailWith($"Expected command to pass but it did not.{GetDiagnosticsInfo()}");
- return new AndConstraint(this);
+ Assert.True(Result.ExitCode == 0, $"Expected command to pass but it did not.{GetDiagnosticsInfo()}");
+ return this;
}
- public AndConstraint Fail()
+ public CommandResultAssertions Fail()
{
- CurrentAssertionChain.ForCondition(Result.ExitCode != 0)
- .FailWith($"Expected command to fail but it did not.{GetDiagnosticsInfo()}");
- return new AndConstraint(this);
+ Assert.True(Result.ExitCode != 0, $"Expected command to fail but it did not.{GetDiagnosticsInfo()}");
+ return this;
}
- public AndConstraint HaveStdOut()
+ public CommandResultAssertions HaveStdOut()
{
- CurrentAssertionChain.ForCondition(!string.IsNullOrEmpty(Result.StdOut))
- .FailWith($"Command did not output anything to stdout{GetDiagnosticsInfo()}");
- return new AndConstraint(this);
+ Assert.True(!string.IsNullOrEmpty(Result.StdOut), $"Command did not output anything to stdout{GetDiagnosticsInfo()}");
+ return this;
}
- public AndConstraint HaveStdOut(string expectedOutput)
+ public CommandResultAssertions HaveStdOut(string expectedOutput)
{
- CurrentAssertionChain.ForCondition(Result.StdOut.Equals(expectedOutput, StringComparison.Ordinal))
- .FailWith($"Command did not output with Expected Output. Expected: '{expectedOutput}'{GetDiagnosticsInfo()}");
- return new AndConstraint(this);
+ Assert.True(Result.StdOut.Equals(expectedOutput, StringComparison.Ordinal), $"Command did not output with Expected Output. Expected: '{expectedOutput}'{GetDiagnosticsInfo()}");
+ return this;
}
- public AndConstraint HaveStdOutContaining(string pattern)
+ public CommandResultAssertions HaveStdOutContaining(string pattern)
{
- CurrentAssertionChain.ForCondition(!string.IsNullOrEmpty(Result.StdOut) && Result.StdOut.Contains(pattern))
- .FailWith($"The command output did not contain expected result: '{pattern}'{GetDiagnosticsInfo()}");
- return new AndConstraint(this);
+ Assert.True(!string.IsNullOrEmpty(Result.StdOut) && Result.StdOut.Contains(pattern), $"The command output did not contain expected result: '{pattern}'{GetDiagnosticsInfo()}");
+ return this;
}
- public AndConstraint NotHaveStdOutContaining(string pattern)
+ public CommandResultAssertions NotHaveStdOutContaining(string pattern)
{
- CurrentAssertionChain.ForCondition(!Result.StdOut.Contains(pattern))
- .FailWith($"The command output contained a result it should not have contained: '{pattern}'{GetDiagnosticsInfo()}");
- return new AndConstraint(this);
+ Assert.True(!Result.StdOut.Contains(pattern), $"The command output contained a result it should not have contained: '{pattern}'{GetDiagnosticsInfo()}");
+ return this;
}
- public AndConstraint HaveStdOutMatching(string pattern, RegexOptions options = RegexOptions.None)
+ public CommandResultAssertions HaveStdOutMatching(string pattern, RegexOptions options = RegexOptions.None)
{
- CurrentAssertionChain.ForCondition(Regex.IsMatch(Result.StdOut, pattern, options))
- .FailWith($"Matching the command output failed. Pattern: '{pattern}'{GetDiagnosticsInfo()}");
- return new AndConstraint(this);
+ Assert.True(Regex.IsMatch(Result.StdOut, pattern, options), $"Matching the command output failed. Pattern: '{pattern}'{GetDiagnosticsInfo()}");
+ return this;
}
- public AndConstraint NotHaveStdOutMatching(string pattern, RegexOptions options = RegexOptions.None)
+ public CommandResultAssertions NotHaveStdOutMatching(string pattern, RegexOptions options = RegexOptions.None)
{
- CurrentAssertionChain.ForCondition(!Regex.IsMatch(Result.StdOut, pattern, options))
- .FailWith($"The command output matched a pattern is should not have matched. Pattern: '{pattern}'{GetDiagnosticsInfo()}");
- return new AndConstraint(this);
+ Assert.True(!Regex.IsMatch(Result.StdOut, pattern, options), $"The command output matched a pattern is should not have matched. Pattern: '{pattern}'{GetDiagnosticsInfo()}");
+ return this;
}
- public AndConstraint HaveStdErr()
+ public CommandResultAssertions HaveStdErr()
{
- CurrentAssertionChain.ForCondition(!string.IsNullOrEmpty(Result.StdErr))
- .FailWith($"Command did not output anything to stderr.{GetDiagnosticsInfo()}");
- return new AndConstraint(this);
+ Assert.True(!string.IsNullOrEmpty(Result.StdErr), $"Command did not output anything to stderr.{GetDiagnosticsInfo()}");
+ return this;
}
- public AndConstraint HaveStdErrContaining(string pattern)
+ public CommandResultAssertions HaveStdErrContaining(string pattern)
{
- CurrentAssertionChain.ForCondition(!string.IsNullOrEmpty(Result.StdErr) && Result.StdErr.Contains(pattern))
- .FailWith($"The command error output did not contain expected result: '{pattern}'{GetDiagnosticsInfo()}");
- return new AndConstraint(this);
+ Assert.True(!string.IsNullOrEmpty(Result.StdErr) && Result.StdErr.Contains(pattern), $"The command error output did not contain expected result: '{pattern}'{GetDiagnosticsInfo()}");
+ return this;
}
- public AndConstraint NotHaveStdErrContaining(string pattern)
+ public CommandResultAssertions NotHaveStdErrContaining(string pattern)
{
- CurrentAssertionChain.ForCondition(!Result.StdErr.Contains(pattern))
- .FailWith($"The command error output contained a result it should not have contained: '{pattern}'{GetDiagnosticsInfo()}");
- return new AndConstraint(this);
+ Assert.True(!Result.StdErr.Contains(pattern), $"The command error output contained a result it should not have contained: '{pattern}'{GetDiagnosticsInfo()}");
+ return this;
}
- public AndConstraint HaveStdErrMatching(string pattern, RegexOptions options = RegexOptions.None)
+ public CommandResultAssertions HaveStdErrMatching(string pattern, RegexOptions options = RegexOptions.None)
{
- CurrentAssertionChain.ForCondition(Regex.IsMatch(Result.StdErr, pattern, options))
- .FailWith($"Matching the command error output failed. Pattern: '{pattern}'{GetDiagnosticsInfo()}");
- return new AndConstraint(this);
+ Assert.True(Regex.IsMatch(Result.StdErr, pattern, options), $"Matching the command error output failed. Pattern: '{pattern}'{GetDiagnosticsInfo()}");
+ return this;
}
- public AndConstraint NotHaveStdOut()
+ public CommandResultAssertions NotHaveStdOut()
{
- CurrentAssertionChain.ForCondition(string.IsNullOrEmpty(Result.StdOut))
- .FailWith($"Expected command to not output to stdout but it did:{GetDiagnosticsInfo()}");
- return new AndConstraint(this);
+ Assert.True(string.IsNullOrEmpty(Result.StdOut), $"Expected command to not output to stdout but it did:{GetDiagnosticsInfo()}");
+ return this;
}
- public AndConstraint NotHaveStdErr()
+ public CommandResultAssertions NotHaveStdErr()
{
- CurrentAssertionChain.ForCondition(string.IsNullOrEmpty(Result.StdErr))
- .FailWith($"Expected command to not output to stderr but it did:{GetDiagnosticsInfo()}");
- return new AndConstraint(this);
+ Assert.True(string.IsNullOrEmpty(Result.StdErr), $"Expected command to not output to stderr but it did:{GetDiagnosticsInfo()}");
+ return this;
}
- public AndConstraint FileExists(string path)
+ public CommandResultAssertions FileExists(string path)
{
- CurrentAssertionChain.ForCondition(System.IO.File.Exists(path))
- .FailWith($"The command did not write the expected file: '{path}'{GetDiagnosticsInfo()}");
- return new AndConstraint(this);
+ Assert.True(System.IO.File.Exists(path), $"The command did not write the expected file: '{path}'{GetDiagnosticsInfo()}");
+ return this;
}
- public AndConstraint FileContains(string path, string pattern)
+ public CommandResultAssertions FileContains(string path, string pattern)
{
string fileContent = System.IO.File.ReadAllText(path);
- CurrentAssertionChain.ForCondition(fileContent.Contains(pattern))
- .FailWith($"The command did not write the expected result '{pattern}' to the file: '{path}'{GetDiagnosticsInfo()}{Environment.NewLine}file content: >>{fileContent}<<");
- return new AndConstraint(this);
+ Assert.True(fileContent.Contains(pattern), $"The command did not write the expected result '{pattern}' to the file: '{path}'{GetDiagnosticsInfo()}{Environment.NewLine}file content: >>{fileContent}<<");
+ return this;
}
- public AndConstraint NotFileContains(string path, string pattern)
+ public CommandResultAssertions NotFileContains(string path, string pattern)
{
string fileContent = System.IO.File.ReadAllText(path);
- CurrentAssertionChain.ForCondition(!fileContent.Contains(pattern))
- .FailWith($"The command did not write the expected result '{pattern}' to the file: '{path}'{GetDiagnosticsInfo()}{Environment.NewLine}file content: >>{fileContent}<<");
- return new AndConstraint(this);
+ Assert.True(!fileContent.Contains(pattern), $"The command did not write the expected result '{pattern}' to the file: '{path}'{GetDiagnosticsInfo()}{Environment.NewLine}file content: >>{fileContent}<<");
+ return this;
}
public string GetDiagnosticsInfo() => Result.GetDiagnosticsInfo();
diff --git a/src/installer/tests/TestUtils/Assertions/CommandResultExtensions.cs b/src/installer/tests/TestUtils/Assertions/CommandResultExtensions.cs
index 7ca15639b7dc2d..17782efa410922 100644
--- a/src/installer/tests/TestUtils/Assertions/CommandResultExtensions.cs
+++ b/src/installer/tests/TestUtils/Assertions/CommandResultExtensions.cs
@@ -1,9 +1,8 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-using FluentAssertions;
-using FluentAssertions.Execution;
using Microsoft.DotNet.Cli.Build.Framework;
+using Xunit;
namespace Microsoft.DotNet.CoreSetup.Test
{
@@ -11,15 +10,13 @@ public static class CommandResultExtensions
{
public static CommandResultAssertions Should(this CommandResult commandResult)
{
- return new CommandResultAssertions(commandResult, AssertionChain.GetOrCreate());
+ return new CommandResultAssertions(commandResult);
}
public static CommandResult StdErrAfter(this CommandResult commandResult, string pattern)
{
int i = commandResult.StdErr.IndexOf(pattern);
- i.Should().BeGreaterThanOrEqualTo(
- 0,
- $"'{pattern}' should be in StdErr - cannot filter StdErr to after expected string.{commandResult.GetDiagnosticsInfo()}");
+ Assert.True(i >= 0, $"'{pattern}' should be in StdErr - cannot filter StdErr to after expected string.{commandResult.GetDiagnosticsInfo()}");
string filteredStdErr = commandResult.StdErr.Substring(i);
return new CommandResult(commandResult.StartInfo, commandResult.ProcessId, commandResult.ExitCode, commandResult.StdOut, filteredStdErr);
diff --git a/src/installer/tests/TestUtils/Assertions/DirectoryInfoAssertions.cs b/src/installer/tests/TestUtils/Assertions/DirectoryInfoAssertions.cs
index 8138a68368a458..1db3ff06fa7e9b 100644
--- a/src/installer/tests/TestUtils/Assertions/DirectoryInfoAssertions.cs
+++ b/src/installer/tests/TestUtils/Assertions/DirectoryInfoAssertions.cs
@@ -1,114 +1,103 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-using FluentAssertions;
-using FluentAssertions.Execution;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
+using Xunit;
namespace Microsoft.DotNet.CoreSetup.Test
{
public class DirectoryInfoAssertions
{
private DirectoryInfo _dirInfo;
- private AssertionChain _assertionChain;
- public DirectoryInfoAssertions(DirectoryInfo dir, AssertionChain assertionChain)
+ public DirectoryInfoAssertions(DirectoryInfo dir)
{
_dirInfo = dir;
- _assertionChain = assertionChain;
}
public DirectoryInfo DirectoryInfo => _dirInfo;
- public AndConstraint Exist()
+ public DirectoryInfoAssertions Exist()
{
- _assertionChain.ForCondition(_dirInfo.Exists)
- .FailWith($"Expected directory '{_dirInfo.FullName}' does not exist.");
- return new AndConstraint(this);
+ Assert.True(_dirInfo.Exists, $"Expected directory '{_dirInfo.FullName}' does not exist.");
+ return this;
}
- public AndConstraint HaveFile(string expectedFile)
+ public DirectoryInfoAssertions HaveFile(string expectedFile)
{
var file = _dirInfo.EnumerateFiles(expectedFile, SearchOption.TopDirectoryOnly).SingleOrDefault();
- _assertionChain.ForCondition(file != null)
- .FailWith($"Expected File '{expectedFile}' cannot be found in directory '{_dirInfo.FullName}.");
- return new AndConstraint(this);
+ Assert.True(file is not null, $"Expected File '{expectedFile}' cannot be found in directory '{_dirInfo.FullName}.");
+ return this;
}
- public AndConstraint NotHaveFile(string expectedFile)
+ public DirectoryInfoAssertions NotHaveFile(string expectedFile)
{
var file = _dirInfo.EnumerateFiles(expectedFile, SearchOption.TopDirectoryOnly).SingleOrDefault();
- _assertionChain.ForCondition(file == null)
- .FailWith($"File '{expectedFile}' should not be found in directory '{_dirInfo.FullName}'.");
- return new AndConstraint(this);
+ Assert.True(file is null, $"File '{expectedFile}' should not be found in directory '{_dirInfo.FullName}'.");
+ return this;
}
- public AndConstraint HaveFiles(IEnumerable expectedFiles)
+ public DirectoryInfoAssertions HaveFiles(IEnumerable expectedFiles)
{
foreach (var expectedFile in expectedFiles)
{
HaveFile(expectedFile);
}
- return new AndConstraint(this);
+ return this;
}
- public AndConstraint NotHaveFiles(IEnumerable expectedFiles)
+ public DirectoryInfoAssertions NotHaveFiles(IEnumerable expectedFiles)
{
foreach (var expectedFile in expectedFiles)
{
NotHaveFile(expectedFile);
}
- return new AndConstraint(this);
+ return this;
}
- public AndConstraint HaveDirectory(string expectedDir)
+ public DirectoryInfoAssertions HaveDirectory(string expectedDir)
{
var dir = _dirInfo.EnumerateDirectories(expectedDir, SearchOption.TopDirectoryOnly).SingleOrDefault();
- _assertionChain.ForCondition(dir != null)
- .FailWith($"Expected directory '{expectedDir}' cannot be found inside directory '{_dirInfo.FullName}'.");
+ Assert.True(dir is not null, $"Expected directory '{expectedDir}' cannot be found inside directory '{_dirInfo.FullName}'.");
- return new AndConstraint(new DirectoryInfoAssertions(dir, _assertionChain));
+ return new DirectoryInfoAssertions(dir);
}
- public AndConstraint NotHaveDirectory(string expectedDir)
+ public DirectoryInfoAssertions NotHaveDirectory(string expectedDir)
{
var dir = _dirInfo.EnumerateDirectories(expectedDir, SearchOption.TopDirectoryOnly).SingleOrDefault();
- _assertionChain.ForCondition(dir == null)
- .FailWith($"Directory '{expectedDir}' should not be found in found inside directory '{_dirInfo.FullName}'.");
+ Assert.True(dir is null, $"Directory '{expectedDir}' should not be found in found inside directory '{_dirInfo.FullName}'.");
- return new AndConstraint(new DirectoryInfoAssertions(dir, _assertionChain));
+ return new DirectoryInfoAssertions(dir);
}
- public AndConstraint OnlyHaveFiles(IEnumerable expectedFiles)
+ public DirectoryInfoAssertions OnlyHaveFiles(IEnumerable expectedFiles)
{
var actualFiles = _dirInfo.EnumerateFiles("*", SearchOption.TopDirectoryOnly).Select(f => f.Name);
var missingFiles = Enumerable.Except(expectedFiles, actualFiles);
var extraFiles = Enumerable.Except(actualFiles, expectedFiles);
var nl = Environment.NewLine;
- _assertionChain.ForCondition(!missingFiles.Any())
- .FailWith($"Following files cannot be found inside directory {_dirInfo.FullName} {nl} {string.Join(nl, missingFiles)}");
+ Assert.True(!missingFiles.Any(), $"Following files cannot be found inside directory {_dirInfo.FullName} {nl} {string.Join(nl, missingFiles)}");
- _assertionChain.ForCondition(!extraFiles.Any())
- .FailWith($"Following extra files are found inside directory {_dirInfo.FullName} {nl} {string.Join(nl, extraFiles)}");
+ Assert.True(!extraFiles.Any(), $"Following extra files are found inside directory {_dirInfo.FullName} {nl} {string.Join(nl, extraFiles)}");
- return new AndConstraint(this);
+ return this;
}
- public AndConstraint NotBeModifiedAfter(DateTime timeUtc)
+ public DirectoryInfoAssertions NotBeModifiedAfter(DateTime timeUtc)
{
_dirInfo.Refresh();
DateTime writeTime = _dirInfo.LastWriteTimeUtc;
- _assertionChain.ForCondition(writeTime <= timeUtc)
- .FailWith($"Directory '{_dirInfo.FullName}' should not be modified after {timeUtc}, but is modified at {writeTime}.");
+ Assert.True(writeTime <= timeUtc, $"Directory '{_dirInfo.FullName}' should not be modified after {timeUtc}, but is modified at {writeTime}.");
- return new AndConstraint(this);
+ return this;
}
}
diff --git a/src/installer/tests/TestUtils/Assertions/DirectoryInfoExtensions.cs b/src/installer/tests/TestUtils/Assertions/DirectoryInfoExtensions.cs
index 192bd1fad255fc..0f240d6a91bc2d 100644
--- a/src/installer/tests/TestUtils/Assertions/DirectoryInfoExtensions.cs
+++ b/src/installer/tests/TestUtils/Assertions/DirectoryInfoExtensions.cs
@@ -1,7 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-using FluentAssertions.Execution;
using System.IO;
namespace Microsoft.DotNet.CoreSetup.Test
@@ -10,7 +9,7 @@ public static class DirectoryInfoExtensions
{
public static DirectoryInfoAssertions Should(this DirectoryInfo dir)
{
- return new DirectoryInfoAssertions(dir, AssertionChain.GetOrCreate());
+ return new DirectoryInfoAssertions(dir);
}
}
}
diff --git a/src/installer/tests/TestUtils/TestUtils.csproj b/src/installer/tests/TestUtils/TestUtils.csproj
index a88b817b47ac5b..dd7bad21458006 100644
--- a/src/installer/tests/TestUtils/TestUtils.csproj
+++ b/src/installer/tests/TestUtils/TestUtils.csproj
@@ -15,8 +15,8 @@
-
+