Looks like i missed a fluent assertions update in the test utilities csproj so trying that to see if it is enough to solve the output issue.
This commit is contained in:
parent
7ad1132795
commit
c9b14717bc
7 changed files with 37 additions and 57 deletions
|
@ -34,7 +34,7 @@ namespace EndToEnd.Tests
|
|||
File.Exists(manifestFile).Should().BeTrue();
|
||||
using var fileStream = new FileStream(manifestFile, FileMode.Open, FileAccess.Read);
|
||||
Action readManifest = () => WorkloadManifestReader.ReadWorkloadManifest(manifestId, fileStream, manifestFile);
|
||||
readManifest.ShouldNotThrow("manifestId:" + manifestId + " manifestFile:" + manifestFile + "is invalid");
|
||||
readManifest.Should().NotThrow("manifestId:" + manifestId + " manifestFile:" + manifestFile + "is invalid");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using FluentAssertions.Execution;
|
||||
|
||||
namespace Microsoft.DotNet.Tools.Test.Utilities
|
||||
{
|
||||
public static class AssertionScopeExtensions
|
||||
{
|
||||
public static Continuation FailWithPreformatted(this AssertionScope assertionScope, string message)
|
||||
{
|
||||
if (!assertionScope.Succeeded)
|
||||
{
|
||||
assertionScope.AddPreFormattedFailure(message);
|
||||
}
|
||||
|
||||
return new Continuation(assertionScope, assertionScope.Succeeded);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -21,35 +21,35 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
public AndConstraint<CommandResultAssertions> ExitWith(int expectedExitCode)
|
||||
{
|
||||
Execute.Assertion.ForCondition(_commandResult.ExitCode == expectedExitCode)
|
||||
.FailWithPreformatted(AppendDiagnosticsTo($"Expected command to exit with {expectedExitCode} but it did not."));
|
||||
.FailWith(AppendDiagnosticsTo($"Expected command to exit with {expectedExitCode} but it did not."));
|
||||
return new AndConstraint<CommandResultAssertions>(this);
|
||||
}
|
||||
|
||||
public AndConstraint<CommandResultAssertions> Pass()
|
||||
{
|
||||
Execute.Assertion.ForCondition(_commandResult.ExitCode == 0)
|
||||
.FailWithPreformatted(AppendDiagnosticsTo($"Expected command to pass but it did not."));
|
||||
.FailWith(AppendDiagnosticsTo($"Expected command to pass but it did not."));
|
||||
return new AndConstraint<CommandResultAssertions>(this);
|
||||
}
|
||||
|
||||
public AndConstraint<CommandResultAssertions> Fail()
|
||||
{
|
||||
Execute.Assertion.ForCondition(_commandResult.ExitCode != 0)
|
||||
.FailWithPreformatted(AppendDiagnosticsTo($"Expected command to fail but it did not."));
|
||||
.FailWith(AppendDiagnosticsTo($"Expected command to fail but it did not."));
|
||||
return new AndConstraint<CommandResultAssertions>(this);
|
||||
}
|
||||
|
||||
public AndConstraint<CommandResultAssertions> HaveStdOut()
|
||||
{
|
||||
Execute.Assertion.ForCondition(!string.IsNullOrEmpty(_commandResult.StdOut))
|
||||
.FailWithPreformatted(AppendDiagnosticsTo($"Command did not output anything to stdout"));
|
||||
.FailWith(AppendDiagnosticsTo($"Command did not output anything to stdout"));
|
||||
return new AndConstraint<CommandResultAssertions>(this);
|
||||
}
|
||||
|
||||
public AndConstraint<CommandResultAssertions> HaveStdOut(string expectedOutput)
|
||||
{
|
||||
Execute.Assertion.ForCondition(_commandResult.StdOut.Equals(expectedOutput, StringComparison.Ordinal))
|
||||
.FailWithPreformatted(AppendDiagnosticsTo($"Command did not output with Expected Output. Expected: {expectedOutput}"));
|
||||
.FailWith(AppendDiagnosticsTo($"Command did not output with Expected Output. Expected: {expectedOutput}"));
|
||||
return new AndConstraint<CommandResultAssertions>(this);
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
{
|
||||
Execute.Assertion
|
||||
.ForCondition(_commandResult.StdOut.Contains(pattern))
|
||||
.FailWithPreformatted(AppendDiagnosticsTo($"The command output did not contain expected result: {pattern}{Environment.NewLine}"));
|
||||
.FailWith(AppendDiagnosticsTo($"The command output did not contain expected result: {pattern}{Environment.NewLine}"));
|
||||
|
||||
return new AndConstraint<CommandResultAssertions>(this);
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
|
||||
Execute.Assertion
|
||||
.ForCondition(commandResultNoSpaces.Contains(pattern))
|
||||
.FailWithPreformatted(AppendDiagnosticsTo($"The command output did not contain expected result: {pattern}{Environment.NewLine}"));
|
||||
.FailWith(AppendDiagnosticsTo($"The command output did not contain expected result: {pattern}{Environment.NewLine}"));
|
||||
|
||||
return new AndConstraint<CommandResultAssertions>(this);
|
||||
}
|
||||
|
@ -76,63 +76,63 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
public AndConstraint<CommandResultAssertions> HaveStdOutContainingIgnoreCase(string pattern)
|
||||
{
|
||||
Execute.Assertion.ForCondition(_commandResult.StdOut.IndexOf(pattern, StringComparison.OrdinalIgnoreCase) >= 0)
|
||||
.FailWithPreformatted(AppendDiagnosticsTo($"The command output did not contain expected result (ignoring case): {pattern}{Environment.NewLine}"));
|
||||
.FailWith(AppendDiagnosticsTo($"The command output did not contain expected result (ignoring case): {pattern}{Environment.NewLine}"));
|
||||
return new AndConstraint<CommandResultAssertions>(this);
|
||||
}
|
||||
|
||||
public AndConstraint<CommandResultAssertions> NotHaveStdOutContaining(string pattern)
|
||||
{
|
||||
Execute.Assertion.ForCondition(!_commandResult.StdOut.Contains(pattern))
|
||||
.FailWithPreformatted(AppendDiagnosticsTo($"The command output contained a result it should not have contained: {pattern}{Environment.NewLine}"));
|
||||
.FailWith(AppendDiagnosticsTo($"The command output contained a result it should not have contained: {pattern}{Environment.NewLine}"));
|
||||
return new AndConstraint<CommandResultAssertions>(this);
|
||||
}
|
||||
|
||||
public AndConstraint<CommandResultAssertions> HaveStdOutMatching(string pattern, RegexOptions options = RegexOptions.None)
|
||||
{
|
||||
Execute.Assertion.ForCondition(Regex.Match(_commandResult.StdOut, pattern, options).Success)
|
||||
.FailWithPreformatted(AppendDiagnosticsTo($"Matching the command output failed. Pattern: {pattern}{Environment.NewLine}"));
|
||||
.FailWith(AppendDiagnosticsTo($"Matching the command output failed. Pattern: {pattern}{Environment.NewLine}"));
|
||||
return new AndConstraint<CommandResultAssertions>(this);
|
||||
}
|
||||
|
||||
public AndConstraint<CommandResultAssertions> HaveStdErr()
|
||||
{
|
||||
Execute.Assertion.ForCondition(!string.IsNullOrEmpty(_commandResult.StdErr))
|
||||
.FailWithPreformatted(AppendDiagnosticsTo($"Command did not output anything to stderr."));
|
||||
.FailWith(AppendDiagnosticsTo($"Command did not output anything to stderr."));
|
||||
return new AndConstraint<CommandResultAssertions>(this);
|
||||
}
|
||||
|
||||
public AndConstraint<CommandResultAssertions> HaveStdErrContaining(string pattern)
|
||||
{
|
||||
Execute.Assertion.ForCondition(_commandResult.StdErr.Contains(pattern))
|
||||
.FailWithPreformatted(AppendDiagnosticsTo($"The command error output did not contain expected result: {pattern}{Environment.NewLine}"));
|
||||
.FailWith(AppendDiagnosticsTo($"The command error output did not contain expected result: {pattern}{Environment.NewLine}"));
|
||||
return new AndConstraint<CommandResultAssertions>(this);
|
||||
}
|
||||
|
||||
public AndConstraint<CommandResultAssertions> NotHaveStdErrContaining(string pattern)
|
||||
{
|
||||
Execute.Assertion.ForCondition(!_commandResult.StdErr.Contains(pattern))
|
||||
.FailWithPreformatted(AppendDiagnosticsTo($"The command error output contained a result it should not have contained: {pattern}{Environment.NewLine}"));
|
||||
.FailWith(AppendDiagnosticsTo($"The command error output contained a result it should not have contained: {pattern}{Environment.NewLine}"));
|
||||
return new AndConstraint<CommandResultAssertions>(this);
|
||||
}
|
||||
|
||||
public AndConstraint<CommandResultAssertions> HaveStdErrMatching(string pattern, RegexOptions options = RegexOptions.None)
|
||||
{
|
||||
Execute.Assertion.ForCondition(Regex.Match(_commandResult.StdErr, pattern, options).Success)
|
||||
.FailWithPreformatted(AppendDiagnosticsTo($"Matching the command error output failed. Pattern: {pattern}{Environment.NewLine}"));
|
||||
.FailWith(AppendDiagnosticsTo($"Matching the command error output failed. Pattern: {pattern}{Environment.NewLine}"));
|
||||
return new AndConstraint<CommandResultAssertions>(this);
|
||||
}
|
||||
|
||||
public AndConstraint<CommandResultAssertions> NotHaveStdOut()
|
||||
{
|
||||
Execute.Assertion.ForCondition(string.IsNullOrEmpty(_commandResult.StdOut))
|
||||
.FailWithPreformatted(AppendDiagnosticsTo($"Expected command to not output to stdout but it was not:"));
|
||||
.FailWith(AppendDiagnosticsTo($"Expected command to not output to stdout but it was not:"));
|
||||
return new AndConstraint<CommandResultAssertions>(this);
|
||||
}
|
||||
|
||||
public AndConstraint<CommandResultAssertions> NotHaveStdErr()
|
||||
{
|
||||
Execute.Assertion.ForCondition(string.IsNullOrEmpty(_commandResult.StdErr))
|
||||
.FailWithPreformatted(AppendDiagnosticsTo($"Expected command to not output to stderr but it was not:"));
|
||||
.FailWith(AppendDiagnosticsTo($"Expected command to not output to stderr but it was not:"));
|
||||
return new AndConstraint<CommandResultAssertions>(this);
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
public AndConstraint<DirectoryInfoAssertions> Exist()
|
||||
{
|
||||
Execute.Assertion.ForCondition(_dirInfo.Exists)
|
||||
.FailWithPreformatted("Expected directory {0} does not exist.", _dirInfo.FullName);
|
||||
.FailWith(String.Format("Expected directory {0} does not exist.", _dirInfo.FullName));
|
||||
return new AndConstraint<DirectoryInfoAssertions>(this);
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
Execute.Assertion
|
||||
.ForCondition(file != null)
|
||||
.BecauseOf(because, reasonArgs)
|
||||
.FailWithPreformatted($"Expected File {expectedFile} cannot be found in directory {_dirInfo.FullName}.");
|
||||
.FailWith($"Expected File {expectedFile} cannot be found in directory {_dirInfo.FullName}.");
|
||||
|
||||
return new AndConstraint<DirectoryInfoAssertions>(this);
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
Execute.Assertion
|
||||
.ForCondition(contents.Equals(expectedContents))
|
||||
.BecauseOf(because, reasonArgs)
|
||||
.FailWithPreformatted($"Expected file {expectedFile} to contain \n\n{expectedContents}\n\nbut it contains\n\n{contents}\n");
|
||||
.FailWith($"Expected file {expectedFile} to contain \n\n{expectedContents}\n\nbut it contains\n\n{contents}\n");
|
||||
|
||||
return new AndConstraint<DirectoryInfoAssertions>(this);
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
Execute.Assertion
|
||||
.ForCondition(file == null)
|
||||
.BecauseOf(because, reasonArgs)
|
||||
.FailWithPreformatted("File {0} should not be found in directory {1}.", expectedFile, _dirInfo.FullName);
|
||||
.FailWith(String.Format("File {0} should not be found in directory {1}.", expectedFile, _dirInfo.FullName));
|
||||
return new AndConstraint<DirectoryInfoAssertions>(this);
|
||||
}
|
||||
|
||||
|
@ -109,8 +109,8 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
Execute.Assertion
|
||||
.ForCondition(matchingFileExists == true)
|
||||
.BecauseOf(because, reasonArgs)
|
||||
.FailWithPreformatted("Expected directory {0} to contain files matching {1}, but no matching file exists.",
|
||||
_dirInfo.FullName, expectedFilesSearchPattern);
|
||||
.FailWith(String.Format("Expected directory {0} to contain files matching {1}, but no matching file exists.",
|
||||
_dirInfo.FullName, expectedFilesSearchPattern));
|
||||
|
||||
return new AndConstraint<DirectoryInfoAssertions>(this);
|
||||
}
|
||||
|
@ -132,8 +132,8 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
{
|
||||
var matchingFileCount = _dirInfo.EnumerateFiles(expectedFilesSearchPattern, searchOption).Count();
|
||||
Execute.Assertion.ForCondition(matchingFileCount == 0)
|
||||
.FailWithPreformatted("Found {0} files that should not exist in directory {1}. No file matching {2} should exist.",
|
||||
matchingFileCount, _dirInfo.FullName, expectedFilesSearchPattern);
|
||||
.FailWith(String.Format("Found {0} files that should not exist in directory {1}. No file matching {2} should exist.",
|
||||
matchingFileCount, _dirInfo.FullName, expectedFilesSearchPattern));
|
||||
return new AndConstraint<DirectoryInfoAssertions>(this);
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
{
|
||||
var dir = _dirInfo.EnumerateDirectories(expectedDir, SearchOption.TopDirectoryOnly).SingleOrDefault();
|
||||
Execute.Assertion.ForCondition(dir != null)
|
||||
.FailWithPreformatted("Expected directory {0} cannot be found inside directory {1}.", expectedDir, _dirInfo.FullName);
|
||||
.FailWith(String.Format("Expected directory {0} cannot be found inside directory {1}.", expectedDir, _dirInfo.FullName));
|
||||
|
||||
return new AndConstraint<DirectoryInfoAssertions>(new DirectoryInfoAssertions(dir));
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
{
|
||||
var dir = _dirInfo.EnumerateDirectories(unexpectedDir, SearchOption.TopDirectoryOnly).SingleOrDefault();
|
||||
Execute.Assertion.ForCondition(dir == null)
|
||||
.FailWithPreformatted("Directory {0} should not be found in directory {1}.", unexpectedDir, _dirInfo.FullName);
|
||||
.FailWith(String.Format("Directory {0} should not be found in directory {1}.", unexpectedDir, _dirInfo.FullName));
|
||||
|
||||
return new AndConstraint<DirectoryInfoAssertions>(new DirectoryInfoAssertions(dir));
|
||||
}
|
||||
|
@ -183,10 +183,10 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
var nl = Environment.NewLine;
|
||||
|
||||
Execute.Assertion.ForCondition(!missingFiles.Any())
|
||||
.FailWithPreformatted($"Following files cannot be found inside directory {_dirInfo.FullName} {nl} {string.Join(nl, missingFiles)}");
|
||||
.FailWith($"Following files cannot be found inside directory {_dirInfo.FullName} {nl} {string.Join(nl, missingFiles)}");
|
||||
|
||||
Execute.Assertion.ForCondition(!extraFiles.Any())
|
||||
.FailWithPreformatted($"Following extra files are found inside directory {_dirInfo.FullName} {nl} {string.Join(nl, extraFiles)}");
|
||||
.FailWith($"Following extra files are found inside directory {_dirInfo.FullName} {nl} {string.Join(nl, extraFiles)}");
|
||||
|
||||
return new AndConstraint<DirectoryInfoAssertions>(this);
|
||||
}
|
||||
|
@ -194,7 +194,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
public AndConstraint<DirectoryInfoAssertions> BeEmpty()
|
||||
{
|
||||
Execute.Assertion.ForCondition(!_dirInfo.EnumerateFileSystemInfos().Any())
|
||||
.FailWithPreformatted($"The directory {_dirInfo.FullName} is not empty.");
|
||||
.FailWith($"The directory {_dirInfo.FullName} is not empty.");
|
||||
|
||||
return new AndConstraint<DirectoryInfoAssertions>(this);
|
||||
}
|
||||
|
@ -202,7 +202,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
public AndConstraint<DirectoryInfoAssertions> NotBeEmpty()
|
||||
{
|
||||
Execute.Assertion.ForCondition(_dirInfo.EnumerateFileSystemInfos().Any())
|
||||
.FailWithPreformatted($"The directory {_dirInfo.FullName} is empty.");
|
||||
.FailWith($"The directory {_dirInfo.FullName} is empty.");
|
||||
|
||||
return new AndConstraint<DirectoryInfoAssertions>(this);
|
||||
}
|
||||
|
@ -212,7 +212,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
Execute.Assertion
|
||||
.ForCondition(_dirInfo.Exists == false)
|
||||
.BecauseOf(because, reasonArgs)
|
||||
.FailWithPreformatted($"Expected directory {_dirInfo.FullName} to not exist, but it does.");
|
||||
.FailWith($"Expected directory {_dirInfo.FullName} to not exist, but it does.");
|
||||
|
||||
return new AndConstraint<DirectoryInfoAssertions>(this);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
Execute.Assertion
|
||||
.ForCondition(_fileInfo.Exists)
|
||||
.BecauseOf(because, reasonArgs)
|
||||
.FailWithPreformatted($"Expected File {_fileInfo.FullName} to exist, but it does not.");
|
||||
.FailWith($"Expected File {_fileInfo.FullName} to exist, but it does not.");
|
||||
return new AndConstraint<FileInfoAssertions>(this);
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
Execute.Assertion
|
||||
.ForCondition(!_fileInfo.Exists)
|
||||
.BecauseOf(because, reasonArgs)
|
||||
.FailWithPreformatted($"Expected File {_fileInfo.FullName} to not exist, but it does.");
|
||||
.FailWith($"Expected File {_fileInfo.FullName} to not exist, but it does.");
|
||||
return new AndConstraint<FileInfoAssertions>(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
Execute.Assertion
|
||||
.ForCondition(NormalizeLineEndings(assertions.Subject) == NormalizeLineEndings(expected))
|
||||
.BecauseOf(because, becauseArgs)
|
||||
.FailWithPreformatted($"String \"{assertions.Subject}\" is not visually equivalent to expected string \"{expected}\".");
|
||||
.FailWith($"String \"{assertions.Subject}\" is not visually equivalent to expected string \"{expected}\".");
|
||||
|
||||
return new AndConstraint<StringAssertions>(assertions);
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
Execute.Assertion
|
||||
.ForCondition(NormalizeLineEndings(assertions.Subject).Contains(NormalizeLineEndings(expected)))
|
||||
.BecauseOf(because, becauseArgs)
|
||||
.FailWithPreformatted($"String \"{assertions.Subject}\" does not contain visually same fragment string \"{expected}\".");
|
||||
.FailWith($"String \"{assertions.Subject}\" does not contain visually same fragment string \"{expected}\".");
|
||||
|
||||
return new AndConstraint<StringAssertions>(assertions);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="FluentAssertions" Version="4.18.0" />
|
||||
<PackageReference Include="FluentAssertions" Version="6.12.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.2" />
|
||||
<PackageReference Include="Microsoft.DotNet.Cli.Utils" Version="$(MicrosoftDotNetCliUtilsPackageVersion)" />
|
||||
<PackageReference Include="System.Net.Http" Version="4.3.4" />
|
||||
|
|
Loading…
Reference in a new issue