diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c024d5025..33aaa96a5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,26 +12,26 @@ jobs: strategy: fail-fast: false matrix: - os: [windows-latest, ubuntu-latest, macos-latest] + # libsass.dylib is not working on macos-14 + os: [windows-latest, ubuntu-latest, macos-13] env: # https://github.com/NuGet/Home/issues/11548 # https://twitter.com/xoofx/status/1488617114940452872?s=20&t=BKSN4j9rP6fOyg8l7aW0eg NUGET_CERT_REVOCATION_MODE: offline steps: - name: Get Source - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: submodules: recursive - name: Install .NET Core SDK - uses: actions/setup-dotnet@v1 + uses: actions/setup-dotnet@v4 with: dotnet-version: | - 3.1.x - 6.0.x + 8.0.x - name: Build and Test run: dotnet test --logger "trx;LogFileName=test-results.trx" - name: Upload Test Results - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 if: success() || failure() with: name: test-results-${{ matrix.os }} diff --git a/.github/workflows/test-report.yml b/.github/workflows/test-report.yml index 6bc50c1a6..ad6ce6c6c 100644 --- a/.github/workflows/test-report.yml +++ b/.github/workflows/test-report.yml @@ -10,7 +10,8 @@ jobs: strategy: fail-fast: false matrix: - os: [windows-latest, ubuntu-latest, macos-latest] + # libsass.dylib is not working on macos-14 + os: [windows-latest, ubuntu-latest, macos-13] steps: - name: Process Test Results uses: dorny/test-reporter@v1 diff --git a/Directory.Build.props b/Directory.Build.props index 3d207d2be..54e445523 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,5 +1,24 @@ + + CA1021;CA1040;CA1062;CA1505;CA1710;CA1711;CA1720;CA1721;CA1725;CS0672;SYSLIB0010;SYSLIB0013;VSTHRD103;$(NoWarn) + net8.0 1.0.0 $(StatiqFrameworkVersion) $(Version) @@ -20,7 +39,6 @@ true snupkg true - netcoreapp3.1 true NU1901;NU1902;NU1903;NU1904;CA1724 @@ -29,9 +47,9 @@ - + - + diff --git a/src/core/Statiq.App/Statiq.App.csproj b/src/core/Statiq.App/Statiq.App.csproj index 65d025a2a..2085f2d61 100644 --- a/src/core/Statiq.App/Statiq.App.csproj +++ b/src/core/Statiq.App/Statiq.App.csproj @@ -11,18 +11,18 @@ - - - - - - - - + + + + + + + + diff --git a/src/core/Statiq.Common/Meta/TypeConversion/MetadataTypeConverter{T}.cs b/src/core/Statiq.Common/Meta/TypeConversion/MetadataTypeConverter{T}.cs index 9ccaae54f..61017d8fd 100644 --- a/src/core/Statiq.Common/Meta/TypeConversion/MetadataTypeConverter{T}.cs +++ b/src/core/Statiq.Common/Meta/TypeConversion/MetadataTypeConverter{T}.cs @@ -23,6 +23,10 @@ public override IEnumerable ToEnumerable(IEnumerable enumerable) => public static bool TryConvert(object value, out T result) => UniversalTypeConverter.TryConvertTo(value, out result); + // This is where the magic happens via https://github.com/t-bruning/UniversalTypeConverter + public static bool TryConvertInvariant(object value, out T result) => + UniversalTypeConverter.TryConvertTo(value, out result, System.Globalization.CultureInfo.InvariantCulture); + private static IEnumerable ConvertEnumerable(IEnumerable enumerable) { foreach (object value in enumerable) diff --git a/src/core/Statiq.Common/Meta/TypeHelper.cs b/src/core/Statiq.Common/Meta/TypeHelper.cs index d9fb1c9b2..e49e5cf8f 100644 --- a/src/core/Statiq.Common/Meta/TypeHelper.cs +++ b/src/core/Statiq.Common/Meta/TypeHelper.cs @@ -228,7 +228,7 @@ public static bool TryConvert(object value, out T result) } // Check a normal conversion (in case it's a special type that implements a cast, IConvertible, or something) - if (MetadataTypeConverter.TryConvert(value, out result)) + if (MetadataTypeConverter.TryConvertInvariant(value, out result)) { return true; } diff --git a/src/core/Statiq.Common/Statiq.Common.csproj b/src/core/Statiq.Common/Statiq.Common.csproj index 3b1aa596c..47266c855 100644 --- a/src/core/Statiq.Common/Statiq.Common.csproj +++ b/src/core/Statiq.Common/Statiq.Common.csproj @@ -6,12 +6,12 @@ - - - - - + + + + + diff --git a/src/core/Statiq.Core/Statiq.Core.csproj b/src/core/Statiq.Core/Statiq.Core.csproj index b2de0e472..40450953a 100644 --- a/src/core/Statiq.Core/Statiq.Core.csproj +++ b/src/core/Statiq.Core/Statiq.Core.csproj @@ -7,14 +7,14 @@ - - - + + - - + + + diff --git a/src/core/Statiq.Testing/Statiq.Testing.csproj b/src/core/Statiq.Testing/Statiq.Testing.csproj index 2405d486f..8d527eaa3 100644 --- a/src/core/Statiq.Testing/Statiq.Testing.csproj +++ b/src/core/Statiq.Testing/Statiq.Testing.csproj @@ -4,14 +4,14 @@ Statiq Static StaticContent StaticSite Blog BlogEngine - - - - + + build - + + + diff --git a/src/extensions/Statiq.Images/Statiq.Images.csproj b/src/extensions/Statiq.Images/Statiq.Images.csproj index b588603cc..12ac6c0a3 100644 --- a/src/extensions/Statiq.Images/Statiq.Images.csproj +++ b/src/extensions/Statiq.Images/Statiq.Images.csproj @@ -4,7 +4,7 @@ Statiq Static StaticContent StaticSite Blog BlogEngine Images ImageProcessor - + diff --git a/src/extensions/Statiq.Markdown/MarkdownHelper.cs b/src/extensions/Statiq.Markdown/MarkdownHelper.cs index 0c4006d83..58291254d 100644 --- a/src/extensions/Statiq.Markdown/MarkdownHelper.cs +++ b/src/extensions/Statiq.Markdown/MarkdownHelper.cs @@ -112,7 +112,7 @@ public static MarkdownDocument RenderMarkdown( } catch (Exception ex) { - document.LogWarning($"Exception while rendering Markdown: {ex.Message}"); + document.LogWarning(ex, "Exception while rendering Markdown: {Message}", ex.Message); } return null; } diff --git a/src/extensions/Statiq.Markdown/Statiq.Markdown.csproj b/src/extensions/Statiq.Markdown/Statiq.Markdown.csproj index eade706bd..707bd5d8e 100644 --- a/src/extensions/Statiq.Markdown/Statiq.Markdown.csproj +++ b/src/extensions/Statiq.Markdown/Statiq.Markdown.csproj @@ -4,7 +4,7 @@ Statiq Static StaticContent StaticSite Blog BlogEngine Markdown - + diff --git a/src/extensions/Statiq.Razor/Statiq.Razor.csproj b/src/extensions/Statiq.Razor/Statiq.Razor.csproj index 0e62bdfa6..38303a349 100644 --- a/src/extensions/Statiq.Razor/Statiq.Razor.csproj +++ b/src/extensions/Statiq.Razor/Statiq.Razor.csproj @@ -7,13 +7,13 @@ - - - - - - - + + + + + + + diff --git a/src/extensions/Statiq.Razor/StatiqRazorProjectFileSystem.cs b/src/extensions/Statiq.Razor/StatiqRazorProjectFileSystem.cs index b19f66b68..6e2877731 100644 --- a/src/extensions/Statiq.Razor/StatiqRazorProjectFileSystem.cs +++ b/src/extensions/Statiq.Razor/StatiqRazorProjectFileSystem.cs @@ -27,7 +27,6 @@ public StatiqRazorProjectFileSystem(Microsoft.Extensions.FileProviders.IFileProv _hostingEnvironment = hostingEnviroment.ThrowIfNull(nameof(hostingEnviroment)); } - [Obsolete("Use GetItem(string path, string fileKind) instead.")] public override RazorProjectItem GetItem(string path) { return GetItem(path, fileKind: null); diff --git a/src/extensions/Statiq.Xmp/Statiq.Xmp.csproj b/src/extensions/Statiq.Xmp/Statiq.Xmp.csproj index c17d2e92a..6cfaf8828 100644 --- a/src/extensions/Statiq.Xmp/Statiq.Xmp.csproj +++ b/src/extensions/Statiq.Xmp/Statiq.Xmp.csproj @@ -5,7 +5,7 @@ - + diff --git a/src/extensions/Statiq.Yaml/Statiq.Yaml.csproj b/src/extensions/Statiq.Yaml/Statiq.Yaml.csproj index 082aae7c0..a9022a800 100644 --- a/src/extensions/Statiq.Yaml/Statiq.Yaml.csproj +++ b/src/extensions/Statiq.Yaml/Statiq.Yaml.csproj @@ -4,7 +4,7 @@ Statiq Static StaticContent StaticSite Blog BlogEngine Yaml - + diff --git a/tests/Directory.Build.props b/tests/Directory.Build.props index aa2133ccb..8f897c62b 100644 --- a/tests/Directory.Build.props +++ b/tests/Directory.Build.props @@ -5,7 +5,11 @@ true - - + + + + all + runtime; build; native; contentfiles; analyzers + \ No newline at end of file diff --git a/tests/core/Statiq.App.Tests/Bootstrapper/BootstrapperFixture.cs b/tests/core/Statiq.App.Tests/Bootstrapper/BootstrapperFixture.cs index 4edce7d51..101106e8b 100644 --- a/tests/core/Statiq.App.Tests/Bootstrapper/BootstrapperFixture.cs +++ b/tests/core/Statiq.App.Tests/Bootstrapper/BootstrapperFixture.cs @@ -69,12 +69,12 @@ public async Task SetsLogLevel(string logLevel, int expected) result.LogMessages.Count(x => x.FormattedMessage.StartsWith("Foo/Process")).ShouldBe(expected); } - [TestCase("Trace", false)] - [TestCase("Debug", false)] - [TestCase("Information", false)] - [TestCase("Warning", false)] - [TestCase("Error", true)] - [TestCase("Critical", true)] + [TestCase(LogLevel.Trace, false)] + [TestCase(LogLevel.Debug, false)] + [TestCase(LogLevel.Information, false)] + [TestCase(LogLevel.Warning, false)] + [TestCase(LogLevel.Error, true)] + [TestCase(LogLevel.Critical, true)] public async Task DefaultFailureLogLevel(LogLevel logLevel, bool expectedFailure) { // Given @@ -91,12 +91,12 @@ public async Task DefaultFailureLogLevel(LogLevel logLevel, bool expectedFailure result.ExitCode.ShouldBe(expectedFailure ? (int)ExitCode.LogLevelFailure : (int)ExitCode.Normal); } - [TestCase("Trace", false)] - [TestCase("Debug", false)] - [TestCase("Information", false)] - [TestCase("Warning", true)] - [TestCase("Error", true)] - [TestCase("Critical", true)] + [TestCase(LogLevel.Trace, false)] + [TestCase(LogLevel.Debug, false)] + [TestCase(LogLevel.Information, false)] + [TestCase(LogLevel.Warning, true)] + [TestCase(LogLevel.Error, true)] + [TestCase(LogLevel.Critical, true)] public async Task SetFailureLogLevel(LogLevel logLevel, bool expectedFailure) { // Given diff --git a/tests/core/Statiq.Common.Tests/Documents/DocumentFixture.cs b/tests/core/Statiq.Common.Tests/Documents/DocumentFixture.cs index fc0ec89f9..65b9f58a2 100644 --- a/tests/core/Statiq.Common.Tests/Documents/DocumentFixture.cs +++ b/tests/core/Statiq.Common.Tests/Documents/DocumentFixture.cs @@ -19,7 +19,7 @@ public void IdIsNotTheSameForDifferentDocuments() Document b = new Document(); // Then - Assert.AreNotEqual(a.Id, b.Id); + Assert.That(b.Id, Is.Not.EqualTo(a.Id)); } [Test] @@ -48,7 +48,7 @@ public void IdIsTheSameAfterClone() IDocument cloned = document.Clone(null); // Then - Assert.AreEqual(document.Id, cloned.Id); + Assert.That(cloned.Id, Is.EqualTo(document.Id)); } [Test] diff --git a/tests/core/Statiq.Common.Tests/Documents/ObjectDocumentFixture.cs b/tests/core/Statiq.Common.Tests/Documents/ObjectDocumentFixture.cs index 2631ca542..7fe8f3e2b 100644 --- a/tests/core/Statiq.Common.Tests/Documents/ObjectDocumentFixture.cs +++ b/tests/core/Statiq.Common.Tests/Documents/ObjectDocumentFixture.cs @@ -19,7 +19,7 @@ public void IdIsNotTheSameForDifferentDocuments() IDocument b = new ObjectDocument(obj); // Then - Assert.AreNotEqual(a.Id, b.Id); + Assert.That(b.Id, Is.Not.EqualTo(a.Id)); } } @@ -36,7 +36,7 @@ public void IdIsTheSameAfterClone() IDocument cloned = document.Clone(null); // Then - Assert.AreEqual(document.Id, cloned.Id); + Assert.That(cloned.Id, Is.EqualTo(document.Id)); } [Test] diff --git a/tests/core/Statiq.Common.Tests/Documents/ToLookupExtensionsFixture.cs b/tests/core/Statiq.Common.Tests/Documents/ToLookupExtensionsFixture.cs index 4d4030278..581a9491a 100644 --- a/tests/core/Statiq.Common.Tests/Documents/ToLookupExtensionsFixture.cs +++ b/tests/core/Statiq.Common.Tests/Documents/ToLookupExtensionsFixture.cs @@ -36,11 +36,14 @@ public void ReturnsCorrectLookupOfInt() ILookup lookup = documents.ToLookupMany("Numbers"); // Then - Assert.AreEqual(4, lookup.Count); - CollectionAssert.AreEquivalent(new[] { a }, lookup[1]); - CollectionAssert.AreEquivalent(new[] { a, b }, lookup[2]); - CollectionAssert.AreEquivalent(new[] { a, b, c }, lookup[3]); - CollectionAssert.AreEquivalent(new[] { b, d }, lookup[4]); + Assert.Multiple(() => + { + Assert.That(lookup, Has.Count.EqualTo(4)); + Assert.That(lookup[1], Is.EquivalentTo(new[] { a })); + Assert.That(lookup[2], Is.EquivalentTo(new[] { a, b })); + Assert.That(lookup[3], Is.EquivalentTo(new[] { a, b, c })); + Assert.That(lookup[4], Is.EquivalentTo(new[] { b, d })); + }); } [Test] @@ -69,11 +72,14 @@ public void ReturnsCorrectLookupOfString() ILookup lookup = documents.ToLookupMany("Numbers"); // Then - Assert.AreEqual(4, lookup.Count); - CollectionAssert.AreEquivalent(new[] { a }, lookup["1"]); - CollectionAssert.AreEquivalent(new[] { a, b }, lookup["2"]); - CollectionAssert.AreEquivalent(new[] { a, b, c }, lookup["3"]); - CollectionAssert.AreEquivalent(new[] { b, d }, lookup["4"]); + Assert.Multiple(() => + { + Assert.That(lookup, Has.Count.EqualTo(4)); + Assert.That(lookup["1"], Is.EquivalentTo(new[] { a })); + Assert.That(lookup["2"], Is.EquivalentTo(new[] { a, b })); + Assert.That(lookup["3"], Is.EquivalentTo(new[] { a, b, c })); + Assert.That(lookup["4"], Is.EquivalentTo(new[] { b, d })); + }); } [Test] @@ -106,11 +112,14 @@ public void ReturnsCorrectLookupWithValues() ILookup lookup = documents.ToLookupMany("Numbers", "Colors"); // Then - Assert.AreEqual(4, lookup.Count); - CollectionAssert.AreEquivalent(new[] { "Red" }, lookup[1]); - CollectionAssert.AreEquivalent(new[] { "Red", "Red" }, lookup[2]); - CollectionAssert.AreEquivalent(new[] { "Red", "Red", "Green" }, lookup[3]); - CollectionAssert.AreEquivalent(new[] { "Red", "Green" }, lookup[4]); + Assert.Multiple(() => + { + Assert.That(lookup, Has.Count.EqualTo(4)); + Assert.That(lookup[1], Is.EquivalentTo(new[] { "Red" })); + Assert.That(lookup[2], Is.EquivalentTo(new[] { "Red", "Red" })); + Assert.That(lookup[3], Is.EquivalentTo(new[] { "Red", "Red", "Green" })); + Assert.That(lookup[4], Is.EquivalentTo(new[] { "Red", "Green" })); + }); } } @@ -146,11 +155,14 @@ public void ReturnsCorrectLookupWithValues() ILookup lookup = documents.ToLookupManyToMany("Numbers", "Colors"); // Then - Assert.AreEqual(4, lookup.Count); - CollectionAssert.AreEquivalent(new[] { "Red" }, lookup[1]); - CollectionAssert.AreEquivalent(new[] { "Red", "Red", "Blue" }, lookup[2]); - CollectionAssert.AreEquivalent(new[] { "Red", "Red", "Blue", "Green" }, lookup[3]); - CollectionAssert.AreEquivalent(new[] { "Red", "Blue", "Green", "Blue" }, lookup[4]); + Assert.That(lookup, Has.Count.EqualTo(4)); + Assert.Multiple(() => + { + Assert.That(lookup[1], Is.EquivalentTo(new[] { "Red" })); + Assert.That(lookup[2], Is.EquivalentTo(new[] { "Red", "Red", "Blue" })); + Assert.That(lookup[3], Is.EquivalentTo(new[] { "Red", "Red", "Blue", "Green" })); + Assert.That(lookup[4], Is.EquivalentTo(new[] { "Red", "Blue", "Green", "Blue" })); + }); } } } diff --git a/tests/core/Statiq.Common.Tests/IO/Globbing/GlobberFixture.cs b/tests/core/Statiq.Common.Tests/IO/Globbing/GlobberFixture.cs index 0fd7420f5..65353abee 100644 --- a/tests/core/Statiq.Common.Tests/IO/Globbing/GlobberFixture.cs +++ b/tests/core/Statiq.Common.Tests/IO/Globbing/GlobberFixture.cs @@ -49,8 +49,8 @@ public void ShouldReturnMatchedFiles(string directoryPath, string[] patterns, st IEnumerable matchesReversedSlash = Globber.GetFiles(directory, patterns.Select(x => x.Replace("/", "\\"))); // Then - CollectionAssert.AreEquivalent(resultPaths, matches.Select(x => x.Path.FullPath)); - CollectionAssert.AreEquivalent(resultPaths, matchesReversedSlash.Select(x => x.Path.FullPath)); + Assert.That(matches.Select(x => x.Path.FullPath), Is.EquivalentTo(resultPaths)); + Assert.That(matchesReversedSlash.Select(x => x.Path.FullPath), Is.EquivalentTo(resultPaths)); } [Test] @@ -110,8 +110,8 @@ public void RecursiveWildcardTests(string directoryPath, string[] patterns, stri IEnumerable matchesReversedSlash = Globber.GetFiles(directory, patterns.Select(x => x.Replace("/", "\\"))); // Then - CollectionAssert.AreEquivalent(resultPaths, matches.Select(x => x.Path.FullPath)); - CollectionAssert.AreEquivalent(resultPaths, matchesReversedSlash.Select(x => x.Path.FullPath)); + Assert.That(matches.Select(x => x.Path.FullPath), Is.EquivalentTo(resultPaths)); + Assert.That(matchesReversedSlash.Select(x => x.Path.FullPath), Is.EquivalentTo(resultPaths)); } // Addresses a specific problem with nested folders in a wildcard search @@ -132,7 +132,7 @@ public void NestedFoldersWilcard() IEnumerable matches = Globber.GetFiles(directory, new[] { "**/*.txt" }); // Then - CollectionAssert.AreEquivalent(new[] { "/a/b/c/x.txt", "/a/bar/foo/y.txt" }, matches.Select(x => x.Path.FullPath)); + Assert.That(matches.Select(x => x.Path.FullPath), Is.EquivalentTo(new[] { "/a/b/c/x.txt", "/a/bar/foo/y.txt" })); } [TestCase("/a/b")] @@ -224,7 +224,7 @@ public void ShouldExpandBraces(string pattern, string[] expected) IEnumerable result = Globber.ExpandBraces(pattern); // Then - CollectionAssert.AreEquivalent(expected, result); + Assert.That(result, Is.EquivalentTo(expected)); } } diff --git a/tests/core/Statiq.Common.Tests/IO/IReadOnlyFileSystemExtensionsFixture.cs b/tests/core/Statiq.Common.Tests/IO/IReadOnlyFileSystemExtensionsFixture.cs index 68a19b9c2..76c7ed3d3 100644 --- a/tests/core/Statiq.Common.Tests/IO/IReadOnlyFileSystemExtensionsFixture.cs +++ b/tests/core/Statiq.Common.Tests/IO/IReadOnlyFileSystemExtensionsFixture.cs @@ -32,7 +32,7 @@ public void ReturnsInputFile(string input, string expected) IFile result = fileSystem.GetInputFile(input); // Then - Assert.AreEqual(expected, result.Path.FullPath); + Assert.That(result.Path.FullPath, Is.EqualTo(expected)); } [Test] @@ -47,7 +47,7 @@ public void ReturnsInputFileAboveInputDirectory() IFile result = fileSystem.GetInputFile("../bar.txt"); // Then - Assert.AreEqual("/a/x/bar.txt", result.Path.FullPath); + Assert.That(result.Path.FullPath, Is.EqualTo("/a/x/bar.txt")); } [Test] @@ -62,7 +62,7 @@ public void ReturnsInputFileWhenInputDirectoryAboveRoot() IFile result = fileSystem.GetInputFile("bar.txt"); // Then - Assert.AreEqual("/a/x/bar.txt", result.Path.FullPath); + Assert.That(result.Path.FullPath, Is.EqualTo("/a/x/bar.txt")); } [Test] @@ -77,7 +77,7 @@ public void ReturnsInputFileWhenInputDirectoryAndFileAscend() IFile result = fileSystem.GetInputFile("../bar.txt"); // Then - Assert.AreEqual("/a/x/bar.txt", result.Path.FullPath); + Assert.That(result.Path.FullPath, Is.EqualTo("/a/x/bar.txt")); } } @@ -93,8 +93,8 @@ public void ReturnsVirtualInputDirectoryForRelativePath() IDirectory result = fileSystem.GetInputDirectory("A/B/C"); // Then - Assert.IsInstanceOf(result); - Assert.AreEqual("A/B/C", result.Path.FullPath); + Assert.That(result, Is.InstanceOf()); + Assert.That(result.Path.FullPath, Is.EqualTo("A/B/C")); } [Test] @@ -107,8 +107,8 @@ public void ReturnsVirtualInputDirectoryForAscendingPath() IDirectory result = fileSystem.GetInputDirectory("../A/B/C"); // Then - Assert.IsInstanceOf(result); - Assert.AreEqual("../A/B/C", result.Path.FullPath); + Assert.That(result, Is.InstanceOf()); + Assert.That(result.Path.FullPath, Is.EqualTo("../A/B/C")); } [Test] @@ -121,8 +121,8 @@ public void ReturnsVirtualInputDirectoryForNullPath() IDirectory result = fileSystem.GetInputDirectory(); // Then - Assert.IsInstanceOf(result); - Assert.AreEqual(string.Empty, result.Path.FullPath); + Assert.That(result, Is.InstanceOf()); + Assert.That(result.Path.FullPath, Is.EqualTo(string.Empty)); } [Test] @@ -135,7 +135,7 @@ public void ReturnsDirectoryForAbsolutePath() IDirectory result = fileSystem.GetInputDirectory("/A/B/C"); // Then - Assert.AreEqual("/A/B/C", result.Path.FullPath); + Assert.That(result.Path.FullPath, Is.EqualTo("/A/B/C")); } } @@ -158,17 +158,18 @@ public void ReturnsCombinedInputDirectories() IEnumerable result = fileSystem.GetInputDirectories(); // Then - CollectionAssert.AreEquivalent( - new[] - { - "/a/theme", - "/a/input", - "/a/b/c", - "/a/b/d", - "/a/x", - "/a/y", - "/z" - }, result.Select(x => x.Path.FullPath)); + Assert.That( + result.Select(x => x.Path.FullPath), + Is.EquivalentTo(new[] + { + "/a/theme", + "/a/input", + "/a/b/c", + "/a/b/d", + "/a/x", + "/a/y", + "/z" + })); } } @@ -438,7 +439,7 @@ public void ShouldNotThrowForNullPattern() IEnumerable results = fileSystem.GetFiles(dir, null, "**/foo.txt"); // Then - CollectionAssert.AreEquivalent(new[] { "/a/b/c/foo.txt" }, results.Select(x => x.Path.FullPath)); + Assert.That(results.Select(x => x.Path.FullPath), Is.EquivalentTo(new[] { "/a/b/c/foo.txt" })); } [TestCase("/", new[] { "/a/b/c/foo.txt" }, new[] { "/a/b/c/foo.txt" }, true)] @@ -486,7 +487,7 @@ public void ShouldReturnExistingFiles(string directory, string[] patterns, strin IEnumerable results = fileSystem.GetFiles(dir, patterns); // Then - CollectionAssert.AreEquivalent(expected, results.Select(x => x.Path.FullPath)); + Assert.That(results.Select(x => x.Path.FullPath), Is.EquivalentTo(expected)); if (reverseSlashes) { @@ -494,7 +495,7 @@ public void ShouldReturnExistingFiles(string directory, string[] patterns, strin results = fileSystem.GetFiles(dir, patterns.Select(x => x.Replace("/", "\\"))); // Then - CollectionAssert.AreEquivalent(expected, results.Select(x => x.Path.FullPath)); + Assert.That(results.Select(x => x.Path.FullPath), Is.EquivalentTo(expected)); } } @@ -526,7 +527,7 @@ public void ShouldNotReturnExcludedFiles(string directory, string excluded, stri IEnumerable results = fileSystem.GetFiles(dir, patterns); // Then - CollectionAssert.AreEquivalent(expected, results.Select(x => x.Path.FullPath)); + Assert.That(results.Select(x => x.Path.FullPath), Is.EquivalentTo(expected)); } } diff --git a/tests/core/Statiq.Common.Tests/IO/NormalizedPathFixture.cs b/tests/core/Statiq.Common.Tests/IO/NormalizedPathFixture.cs index 2a4b32733..e34fef734 100644 --- a/tests/core/Statiq.Common.Tests/IO/NormalizedPathFixture.cs +++ b/tests/core/Statiq.Common.Tests/IO/NormalizedPathFixture.cs @@ -591,7 +591,7 @@ public void CanSeeIfAPathHasAnExtension(string fullPath, bool expected) NormalizedPath path = new NormalizedPath(fullPath); // Then - Assert.AreEqual(expected, path.HasExtension); + Assert.That(path.HasExtension, Is.EqualTo(expected)); } } @@ -610,7 +610,7 @@ public void CanGetExtension(string fullPath, string expected) string extension = result.Extension; // Then - Assert.AreEqual(expected, extension); + Assert.That(extension, Is.EqualTo(expected)); } } @@ -626,7 +626,7 @@ public void CanGetDirectoryForFilePath() NormalizedPath directory = path.Parent; // Then - Assert.AreEqual("temp", directory.FullPath); + Assert.That(directory.FullPath, Is.EqualTo("temp")); } [Test] @@ -662,7 +662,7 @@ public void ShouldReturnRootRelativePath(string fullPath, string expected) NormalizedPath rootRelative = path.RootRelative; // Then - Assert.AreEqual(expected, rootRelative.FullPath); + Assert.That(rootRelative.FullPath, Is.EqualTo(expected)); } [TestCase(@"\a\b\c")] @@ -682,7 +682,7 @@ public void ShouldReturnSelfForExplicitRelativePath(string fullPath) NormalizedPath rootRelative = path.RootRelative; // Then - Assert.AreEqual(path.FullPath, rootRelative.FullPath); + Assert.That(rootRelative.FullPath, Is.EqualTo(path.FullPath)); } } @@ -711,7 +711,7 @@ public void ShouldChangeExtension(string path, string extension, string expected normalized = normalized.ChangeExtension(extension); // Then - Assert.AreEqual(expected, normalized.ToString()); + Assert.That(normalized.ToString(), Is.EqualTo(expected)); } [TestCase("foo")] @@ -755,7 +755,7 @@ public void CanAppendExtensionToPath(string extension, string expected) path = path.AppendExtension(extension); // Then - Assert.AreEqual(expected, path.ToString()); + Assert.That(path.ToString(), Is.EqualTo(expected)); } } @@ -787,7 +787,7 @@ public void CanInsertSuffixToPath(string path, string suffix, string expected) filePath = filePath.InsertSuffix(suffix); // Then - Assert.AreEqual(expected, filePath.FullPath); + Assert.That(filePath.FullPath, Is.EqualTo(expected)); } } @@ -820,7 +820,7 @@ public void CanInsertPrefixToPath(string path, string prefix, string expected) filePath = filePath.InsertPrefix(prefix); // Then - Assert.AreEqual(expected, filePath.FullPath); + Assert.That(filePath.FullPath, Is.EqualTo(expected)); } } @@ -985,7 +985,7 @@ public void ShouldReturnDirectoryName(string directoryPath, string name) string result = path.Name; // Then - Assert.AreEqual(name, result); + Assert.That(result, Is.EqualTo(name)); } } @@ -1006,7 +1006,7 @@ public void ReturnsParent(string directoryPath, string expected) NormalizedPath parent = path.Parent; // Then - Assert.AreEqual(expected, parent.FullPath); + Assert.That(parent.FullPath, Is.EqualTo(expected)); } [TestCase(".")] @@ -1078,7 +1078,7 @@ public void ShouldCombinePaths(string first, string second, string expected) NormalizedPath result = path.GetFilePath(new NormalizedPath(second)); // Then - Assert.AreEqual(expected, result.FullPath); + Assert.That(result.FullPath, Is.EqualTo(expected)); } } @@ -1121,7 +1121,7 @@ public void ShouldCombinePaths(string first, string second, string expected) NormalizedPath result = path.Combine(new NormalizedPath(second)); // Then - Assert.AreEqual(expected, result.FullPath); + Assert.That(result.FullPath, Is.EqualTo(expected)); } } diff --git a/tests/core/Statiq.Common.Tests/IO/PathCollectionFixture.cs b/tests/core/Statiq.Common.Tests/IO/PathCollectionFixture.cs index de2f50957..8538a5493 100644 --- a/tests/core/Statiq.Common.Tests/IO/PathCollectionFixture.cs +++ b/tests/core/Statiq.Common.Tests/IO/PathCollectionFixture.cs @@ -49,7 +49,7 @@ public void ShouldReturnTheNumberOfPathsInTheCollection() PathCollection collection = new PathCollection(new[] { _upperCaseA, _upperCaseB }); // When, Then - Assert.AreEqual(2, collection.Count); + Assert.That(collection, Has.Count.EqualTo(2)); } } @@ -66,7 +66,7 @@ public void ShouldAddPathIfNotAlreadyPresent() collection.Add(_upperCaseA); // Then - Assert.AreEqual(2, collection.Count); + Assert.That(collection, Has.Count.EqualTo(2)); } } @@ -83,7 +83,7 @@ public void ShouldAddPathsThatAreNotPresent() collection.AddRange(new[] { _upperCaseA, _upperCaseB, _upperCaseC }); // Then - Assert.AreEqual(3, collection.Count); + Assert.That(collection, Has.Count.EqualTo(3)); } } } diff --git a/tests/core/Statiq.Common.Tests/IO/VirtualInputDirectoryFixture.cs b/tests/core/Statiq.Common.Tests/IO/VirtualInputDirectoryFixture.cs index 7e1811e64..40ab3462c 100644 --- a/tests/core/Statiq.Common.Tests/IO/VirtualInputDirectoryFixture.cs +++ b/tests/core/Statiq.Common.Tests/IO/VirtualInputDirectoryFixture.cs @@ -49,7 +49,7 @@ public void RootVirtualDirectoryDoesNotIncludeSelf(string virtualPath, SearchOpt IEnumerable directories = directory.GetDirectories(searchOption); // Then - CollectionAssert.AreEquivalent(expectedPaths, directories.Select(x => x.Path.FullPath)); + Assert.That(directories.Select(x => x.Path.FullPath), Is.EquivalentTo(expectedPaths)); } [TestCase("a", SearchOption.AllDirectories, new[] { "a/b" })] @@ -63,7 +63,7 @@ public void NonRootVirtualDirectoryIncludesSelf(string virtualPath, SearchOption IEnumerable directories = directory.GetDirectories(searchOption); // Then - CollectionAssert.AreEquivalent(expectedPaths, directories.Select(x => x.Path.FullPath)); + Assert.That(directories.Select(x => x.Path.FullPath), Is.EquivalentTo(expectedPaths)); } [TestCase("", SearchOption.TopDirectoryOnly, new[] { "x", "i" })] @@ -126,7 +126,7 @@ public void GetsFiles(string virtualPath, SearchOption searchOption, string[] ex IEnumerable files = directory.GetFiles(searchOption); // Then - CollectionAssert.AreEquivalent(expectedPaths, files.Select(x => x.Path.FullPath)); + Assert.That(files.Select(x => x.Path.FullPath), Is.EquivalentTo(expectedPaths)); } [TestCase("", SearchOption.TopDirectoryOnly, new string[] { })] @@ -173,8 +173,8 @@ public void GetsInputFile(string virtualPath, string filePath, string expectedPa IFile file = directory.GetFile(filePath); // Then - Assert.AreEqual(expectedPath, file.Path.FullPath); - Assert.AreEqual(expectedExists, file.Exists); + Assert.That(file.Path.FullPath, Is.EqualTo(expectedPath)); + Assert.That(file.Exists, Is.EqualTo(expectedExists)); } [TestCase("", "x/y/z/foo.txt", "/root/a/x/y/z/foo.txt", true)] @@ -203,8 +203,8 @@ public void GetsMappedInputFile(string virtualPath, string filePath, string expe IFile file = directory.GetFile(filePath); // Then - Assert.AreEqual(expectedPath, file.Path.FullPath); - Assert.AreEqual(expectedExists, file.Exists); + Assert.That(file.Path.FullPath, Is.EqualTo(expectedPath)); + Assert.That(file.Exists, Is.EqualTo(expectedExists)); } [Test] @@ -221,7 +221,7 @@ public void GetsInputFileAboveInputDirectory() IFile file = directory.GetFile("../c/foo.txt"); // Then - Assert.AreEqual("/a/b/c/foo.txt", file.Path.FullPath); + Assert.That(file.Path.FullPath, Is.EqualTo("/a/b/c/foo.txt")); } [Test] @@ -234,7 +234,7 @@ public void GetsMappedInputFileAboveInputDirectory() IFile file = directory.GetFile("../../z/fizz.txt"); // Then - Assert.AreEqual("/root/c/z/fizz.txt", file.Path.FullPath); + Assert.That(file.Path.FullPath, Is.EqualTo("/root/c/z/fizz.txt")); } [Test] @@ -293,7 +293,7 @@ public void ShouldReturnDirectory(string virtualPath, string path, string expect IDirectory result = directory.GetDirectory(path); // Then - Assert.AreEqual(expected, result.Path.FullPath); + Assert.That(result.Path.FullPath, Is.EqualTo(expected)); } [Test] @@ -333,7 +333,7 @@ public void ShouldReturnParentDirectory(string virtualPath, string expected) IDirectory result = directory.Parent; // Then - Assert.AreEqual(expected, result?.Path.FullPath); + Assert.That(result?.Path.FullPath, Is.EqualTo(expected)); } } diff --git a/tests/core/Statiq.Common.Tests/Meta/MetadataFixture.cs b/tests/core/Statiq.Common.Tests/Meta/MetadataFixture.cs index f2ba5c093..605ace6e8 100644 --- a/tests/core/Statiq.Common.Tests/Meta/MetadataFixture.cs +++ b/tests/core/Statiq.Common.Tests/Meta/MetadataFixture.cs @@ -60,7 +60,7 @@ public void ReturnsCorrectResultWithMetadataValue() object value = metadata["A"]; // Then - Assert.AreEqual("a", value); + Assert.That(value, Is.EqualTo("a")); } [Test] @@ -77,7 +77,7 @@ public void ReturnsCorrectResultForKeysWithDifferentCase() object value = metadata["a"]; // Then - Assert.AreEqual("a", value); + Assert.That(value, Is.EqualTo("a")); } } @@ -94,7 +94,7 @@ public void ReturnsTrueForValidValue() bool contains = metadata.ContainsKey("A"); // Then - Assert.IsTrue(contains); + Assert.That(contains, Is.True); } [Test] @@ -108,7 +108,7 @@ public void ReturnsFalseForInvalidValue() bool contains = metadata.ContainsKey("B"); // Then - Assert.IsFalse(contains); + Assert.That(contains, Is.False); } [Test] @@ -122,7 +122,7 @@ public void ReturnsTrueForSameKeysWithDifferentCase() bool contains = metadata.ContainsKey("a"); // Then - Assert.IsTrue(contains); + Assert.That(contains, Is.True); } } @@ -140,8 +140,8 @@ public void ReturnsTrueForValidValue() bool contains = metadata.TryGetValue("A", out value); // Then - Assert.IsTrue(contains); - Assert.AreEqual("a", value); + Assert.That(contains, Is.True); + Assert.That(value, Is.EqualTo("a")); } [Test] @@ -156,8 +156,11 @@ public void ReturnsFalseForInvalidValue() bool contains = metadata.TryGetValue("B", out value); // Then - Assert.IsFalse(contains); - Assert.AreEqual(null, value); + Assert.Multiple(() => + { + Assert.That(contains, Is.False); + Assert.That(value, Is.EqualTo(null)); + }); } [Test] @@ -175,8 +178,11 @@ public void ReturnsCorrectResultWithMetadataValue() bool contains = metadata.TryGetValue("A", out value); // Then - Assert.IsTrue(contains); - Assert.AreEqual("a", value); + Assert.Multiple(() => + { + Assert.That(contains, Is.True); + Assert.That(value, Is.EqualTo("a")); + }); } } @@ -193,7 +199,7 @@ public void CanCloneWithNewValues() metadata = new Metadata(metadata, new[] { new KeyValuePair("A", "a") }); // Then - Assert.AreEqual("a", metadata["A"]); + Assert.That(metadata["A"], Is.EqualTo("a")); } [Test] @@ -207,7 +213,7 @@ public void ContainsPreviousValues() Metadata clone = new Metadata(metadata, new Dictionary { { "B", "b" } }); // Then - Assert.AreEqual("a", clone["A"]); + Assert.That(clone["A"], Is.EqualTo("a")); } [Test] @@ -221,7 +227,7 @@ public void ClonedMetadataDoesNotContainNewValues() Metadata clone = new Metadata(metadata, new Dictionary { { "B", "b" } }); // Then - Assert.IsFalse(metadata.ContainsKey("B")); + Assert.That(metadata.ContainsKey("B"), Is.False); } [Test] @@ -235,7 +241,7 @@ public void ContainsNewValues() Metadata clone = new Metadata(metadata, new Dictionary { { "B", "b" } }); // Then - Assert.AreEqual("b", clone["B"]); + Assert.That(clone["B"], Is.EqualTo("b")); } [Test] @@ -249,8 +255,11 @@ public void ReplacesValue() Metadata clone = new Metadata(metadata, new Dictionary { { "A", "b" } }); // Then - Assert.AreEqual("a", metadata["A"]); - Assert.AreEqual("b", clone["A"]); + Assert.Multiple(() => + { + Assert.That(metadata["A"], Is.EqualTo("a")); + Assert.That(clone["A"], Is.EqualTo("b")); + }); } } @@ -267,7 +276,7 @@ public void GetWithMetadataValueReturnsCorrectResult() object value = metadata.Get("A"); // Then - Assert.AreEqual("a", value); + Assert.That(value, Is.EqualTo("a")); } [Test] @@ -285,7 +294,7 @@ public void ReturnsCorrectResultWithDerivedMetadataValue() object value = metadata.Get("A"); // Then - Assert.AreEqual("x", value); + Assert.That(value, Is.EqualTo("x")); } [Test] @@ -302,8 +311,11 @@ public void MetadataValueCalledForEachRequest() value = metadata.Get("A"); // Then - Assert.AreEqual("a", value); - Assert.AreEqual(3, metadataValue.Calls); + Assert.Multiple(() => + { + Assert.That(value, Is.EqualTo("a")); + Assert.That(metadataValue.Calls, Is.EqualTo(3)); + }); } } @@ -320,8 +332,11 @@ public void ReturnsCorrectResultForList() IReadOnlyList result = metadata.GetList("A"); // Then - Assert.IsNotNull(result); - CollectionAssert.AreEqual(result, new[] { 1, 2, 3 }); + Assert.Multiple(() => + { + Assert.That(result, Is.Not.Null); + Assert.That(new[] { 1, 2, 3 }, Is.EqualTo(result).AsCollection); + }); } [Test] @@ -335,8 +350,8 @@ public void ReturnsCorrectResultForConvertedStringList() IReadOnlyList result = metadata.GetList("A"); // Then - Assert.IsNotNull(result); - CollectionAssert.AreEqual(result, new[] { 1, 2, 3 }); + Assert.That(result, Is.Not.Null); + Assert.That(new[] { 1, 2, 3 }, Is.EqualTo(result).AsCollection); } [Test] @@ -350,8 +365,8 @@ public void ReturnsCorrectResultForConvertedIntList() IReadOnlyList result = metadata.GetList("A"); // Then - Assert.IsNotNull(result); - CollectionAssert.AreEqual(result, new[] { "1", "2", "3" }); + Assert.That(result, Is.Not.Null); + Assert.That(new[] { "1", "2", "3" }, Is.EqualTo(result).AsCollection); } [Test] @@ -365,8 +380,8 @@ public void ReturnsCorrectResultForArray() IReadOnlyList result = metadata.GetList("A"); // Then - Assert.IsNotNull(result); - CollectionAssert.AreEqual(result, new[] { 1, 2, 3 }); + Assert.That(result, Is.Not.Null); + Assert.That(new[] { 1, 2, 3 }, Is.EqualTo(result).AsCollection); } } @@ -400,8 +415,8 @@ public void ReturnsListForList() IEnumerable result = metadata.GetDocuments("A"); // Then - Assert.IsNotNull(result); - CollectionAssert.AreEqual(new[] { a, b, c }, result); + Assert.That(result, Is.Not.Null); + Assert.That(result, Is.EqualTo(new[] { a, b, c }).AsCollection); } [Test] @@ -415,8 +430,8 @@ public void ReturnsEmptyListForListOfInt() IEnumerable result = metadata.GetDocuments("A"); // Then - Assert.IsNotNull(result); - CollectionAssert.IsEmpty(result); + Assert.That(result, Is.Not.Null); + Assert.That(result, Is.Empty); } [Test] @@ -430,8 +445,8 @@ public void ReturnsEmptyListForSingleInt() IEnumerable result = metadata.GetDocuments("A"); // Then - Assert.IsNotNull(result); - CollectionAssert.IsEmpty(result); + Assert.That(result, Is.Not.Null); + Assert.That(result, Is.Empty); } } @@ -448,7 +463,7 @@ public void ReturnsEmptyListWhenKeyNotFound() DocumentList result = metadata.GetDocumentList("A"); // Then - Assert.IsEmpty(result); + Assert.That(result, Is.Empty); } [Test] @@ -465,8 +480,8 @@ public void ReturnsListForList() DocumentList result = metadata.GetDocumentList("A"); // Then - Assert.IsNotNull(result); - CollectionAssert.AreEqual(new[] { a, b, c }, result); + Assert.That(result, Is.Not.Null); + Assert.That(result, Is.EqualTo(new[] { a, b, c }).AsCollection); } [Test] @@ -480,8 +495,8 @@ public void ReturnsEmptyListForListOfInt() DocumentList result = metadata.GetDocumentList("A"); // Then - Assert.IsNotNull(result); - CollectionAssert.IsEmpty(result); + Assert.That(result, Is.Not.Null); + Assert.That(result, Is.Empty); } [Test] @@ -495,8 +510,8 @@ public void ReturnsEmptyListForSingleInt() DocumentList result = metadata.GetDocumentList("A"); // Then - Assert.IsNotNull(result); - CollectionAssert.IsEmpty(result); + Assert.That(result, Is.Not.Null); + Assert.That(result, Is.Empty); } } @@ -515,8 +530,8 @@ public void ReturnsCorrectStringForFilePath(string path, string expected) object result = metadata.GetString("A"); // Then - Assert.IsInstanceOf(result); - Assert.AreEqual(expected, result); + Assert.That(result, Is.InstanceOf()); + Assert.That(result, Is.EqualTo(expected)); } [TestCase("/a/b/c", "/a/b/c")] @@ -532,8 +547,8 @@ public void ReturnsCorrectStringForDirectoryPath(string path, string expected) object result = metadata.GetString("A"); // Then - Assert.IsInstanceOf(result); - Assert.AreEqual(expected, result); + Assert.That(result, Is.InstanceOf()); + Assert.That(result, Is.EqualTo(expected)); } } @@ -638,7 +653,7 @@ public void EnumeratingMetadataValuesReturnsCorrectResults() object[] values = metadata.Select(x => x.Value).ToArray(); // Then - CollectionAssert.AreEquivalent(new[] { "a", "b", "c" }, values); + Assert.That(values, Is.EquivalentTo(new[] { "a", "b", "c" })); } } diff --git a/tests/core/Statiq.Common.Tests/Modules/ModuleListFixture.cs b/tests/core/Statiq.Common.Tests/Modules/ModuleListFixture.cs index 62cff539f..030a8069d 100644 --- a/tests/core/Statiq.Common.Tests/Modules/ModuleListFixture.cs +++ b/tests/core/Statiq.Common.Tests/Modules/ModuleListFixture.cs @@ -159,10 +159,13 @@ public void InsertAfterFirst() collection.InsertAfterFirst(new CountModule("foo")); // Then - Assert.AreEqual(collection[0].GetType(), typeof(RedModule)); - Assert.AreEqual(collection[1].GetType(), typeof(CountModule)); - Assert.AreEqual(collection[2].GetType(), typeof(RedModule)); - Assert.AreEqual(collection[3].GetType(), typeof(GreenModule)); + Assert.Multiple(() => + { + Assert.That(typeof(RedModule), Is.EqualTo(collection[0].GetType())); + Assert.That(typeof(CountModule), Is.EqualTo(collection[1].GetType())); + Assert.That(typeof(RedModule), Is.EqualTo(collection[2].GetType())); + Assert.That(typeof(GreenModule), Is.EqualTo(collection[3].GetType())); + }); } } @@ -181,10 +184,13 @@ public void InsertBeforeFirst() collection.InsertBeforeFirst(new CountModule("foo")); // Then - Assert.AreEqual(collection[0].GetType(), typeof(CountModule)); - Assert.AreEqual(collection[1].GetType(), typeof(RedModule)); - Assert.AreEqual(collection[2].GetType(), typeof(RedModule)); - Assert.AreEqual(collection[3].GetType(), typeof(GreenModule)); + Assert.Multiple(() => + { + Assert.That(typeof(CountModule), Is.EqualTo(collection[0].GetType())); + Assert.That(typeof(RedModule), Is.EqualTo(collection[1].GetType())); + Assert.That(typeof(RedModule), Is.EqualTo(collection[2].GetType())); + Assert.That(typeof(GreenModule), Is.EqualTo(collection[3].GetType())); + }); } } @@ -203,10 +209,13 @@ public void InsertAfterLast() collection.InsertAfterLast(new CountModule("foo")); // Then - Assert.AreEqual(collection[0].GetType(), typeof(RedModule)); - Assert.AreEqual(collection[1].GetType(), typeof(RedModule)); - Assert.AreEqual(collection[2].GetType(), typeof(CountModule)); - Assert.AreEqual(collection[3].GetType(), typeof(GreenModule)); + Assert.Multiple(() => + { + Assert.That(typeof(RedModule), Is.EqualTo(collection[0].GetType())); + Assert.That(typeof(RedModule), Is.EqualTo(collection[1].GetType())); + Assert.That(typeof(CountModule), Is.EqualTo(collection[2].GetType())); + Assert.That(typeof(GreenModule), Is.EqualTo(collection[3].GetType())); + }); } } @@ -225,10 +234,13 @@ public void InsertBeforeLast() collection.InsertBeforeLast(new CountModule("foo")); // Then - Assert.AreEqual(collection[0].GetType(), typeof(RedModule)); - Assert.AreEqual(collection[1].GetType(), typeof(CountModule)); - Assert.AreEqual(collection[2].GetType(), typeof(RedModule)); - Assert.AreEqual(collection[3].GetType(), typeof(GreenModule)); + Assert.Multiple(() => + { + Assert.That(typeof(RedModule), Is.EqualTo(collection[0].GetType())); + Assert.That(typeof(CountModule), Is.EqualTo(collection[1].GetType())); + Assert.That(typeof(RedModule), Is.EqualTo(collection[2].GetType())); + Assert.That(typeof(GreenModule), Is.EqualTo(collection[3].GetType())); + }); } } @@ -248,8 +260,11 @@ public void ReplaceFirst() collection.ReplaceFirst(new CountModule("replacedKey")); // Then - Assert.AreEqual("replacedKey", ((CountModule)collection[1]).ValueKey); - Assert.AreEqual("mykey2", ((CountModule)collection[2]).ValueKey); + Assert.Multiple(() => + { + Assert.That(((CountModule)collection[1]).ValueKey, Is.EqualTo("replacedKey")); + Assert.That(((CountModule)collection[2]).ValueKey, Is.EqualTo("mykey2")); + }); } } @@ -269,8 +284,11 @@ public void ReplaceLast() collection.ReplaceLast(new CountModule("replacedKey")); // Then - Assert.AreEqual("mykey1", ((CountModule)collection[1]).ValueKey); - Assert.AreEqual("replacedKey", ((CountModule)collection[2]).ValueKey); + Assert.Multiple(() => + { + Assert.That(((CountModule)collection[1]).ValueKey, Is.EqualTo("mykey1")); + Assert.That(((CountModule)collection[2]).ValueKey, Is.EqualTo("replacedKey")); + }); } } diff --git a/tests/core/Statiq.Common.Tests/Statiq.Common.Tests.csproj b/tests/core/Statiq.Common.Tests/Statiq.Common.Tests.csproj index 1b5f8feda..c92fd1e67 100644 --- a/tests/core/Statiq.Common.Tests/Statiq.Common.Tests.csproj +++ b/tests/core/Statiq.Common.Tests/Statiq.Common.Tests.csproj @@ -3,9 +3,7 @@ - - - + diff --git a/tests/core/Statiq.Common.Tests/Util/RelativeUrlFixture.cs b/tests/core/Statiq.Common.Tests/Util/RelativeUrlFixture.cs index 230156f41..10aba3914 100644 --- a/tests/core/Statiq.Common.Tests/Util/RelativeUrlFixture.cs +++ b/tests/core/Statiq.Common.Tests/Util/RelativeUrlFixture.cs @@ -27,7 +27,7 @@ public void ShouldParseRoot(string url, bool expected) RelativeUrl relativeUrl = new RelativeUrl(url); // Then - Assert.AreEqual(expected, relativeUrl.HasRoot); + Assert.That(relativeUrl.HasRoot, Is.EqualTo(expected)); } [TestCase(null, "")] @@ -55,7 +55,7 @@ public void ShouldParseFragment(string url, string expected) RelativeUrl relativeUrl = new RelativeUrl(url); // Then - Assert.AreEqual(expected, relativeUrl.Fragment); + Assert.That(relativeUrl.Fragment, Is.EqualTo(expected)); } [TestCase(null, "")] @@ -97,7 +97,7 @@ public void ShouldParseQuery(string url, string expected) RelativeUrl relativeUrl = new RelativeUrl(url); // Then - Assert.AreEqual(expected, relativeUrl.Query); + Assert.That(relativeUrl.Query, Is.EqualTo(expected)); } [TestCase(null, null)] @@ -135,7 +135,7 @@ public void ShouldParsePath(string url, string expected) RelativeUrl relativeUrl = new RelativeUrl(url); // Then - Assert.AreEqual(expected, (string)relativeUrl.Path); + Assert.That((string)relativeUrl.Path, Is.EqualTo(expected)); } [TestCase("?", null, "?")] @@ -155,7 +155,7 @@ public void ShouldCreateUrl(string url, string root, string expected) RelativeUrl relativeUrl = new RelativeUrl(url, root); // Then - Assert.AreEqual(expected, relativeUrl.ToString()); + Assert.That(relativeUrl.ToString(), Is.EqualTo(expected)); } [Test] @@ -165,7 +165,7 @@ public void ImplicitOperatorShouldMatchToString() RelativeUrl relativeUrl = new RelativeUrl("~/foo?a=b#fragment", "root"); // Then - Assert.AreEqual(relativeUrl.ToString(), (string)relativeUrl); + Assert.That((string)relativeUrl, Is.EqualTo(relativeUrl.ToString())); } } } diff --git a/tests/core/Statiq.Core.Tests/Execution/PipelineCollectionFixture.cs b/tests/core/Statiq.Core.Tests/Execution/PipelineCollectionFixture.cs index 69d4744dc..500dabdb5 100644 --- a/tests/core/Statiq.Core.Tests/Execution/PipelineCollectionFixture.cs +++ b/tests/core/Statiq.Core.Tests/Execution/PipelineCollectionFixture.cs @@ -56,7 +56,7 @@ public void ReturnsTrueForDifferentCase() bool contains = pipelines.ContainsKey("test"); // Then - Assert.IsTrue(contains); + Assert.That(contains, Is.True); } } } diff --git a/tests/core/Statiq.Core.Tests/IO/FileSystemFixture.cs b/tests/core/Statiq.Core.Tests/IO/FileSystemFixture.cs index 277725786..bf30b025e 100644 --- a/tests/core/Statiq.Core.Tests/IO/FileSystemFixture.cs +++ b/tests/core/Statiq.Core.Tests/IO/FileSystemFixture.cs @@ -18,7 +18,7 @@ public void AddsDefaultInputPath() FileSystem fileSystem = new FileSystem(); // Then - CollectionAssert.AreEquivalent(new[] { "input" }, fileSystem.InputPaths.Select(x => x.FullPath)); + Assert.That(fileSystem.InputPaths.Select(x => x.FullPath), Is.EquivalentTo(new[] { "input" })); } } @@ -54,7 +54,7 @@ public void CanSet() fileSystem.RootPath = "/foo/bar"; // Then - Assert.AreEqual("/foo/bar", fileSystem.RootPath.FullPath); + Assert.That(fileSystem.RootPath.FullPath, Is.EqualTo("/foo/bar")); } } @@ -80,7 +80,7 @@ public void CanSet() fileSystem.OutputPath = "/foo/bar"; // Then - Assert.AreEqual("/foo/bar", fileSystem.OutputPath.FullPath); + Assert.That(fileSystem.OutputPath.FullPath, Is.EqualTo("/foo/bar")); } } diff --git a/tests/core/Statiq.Core.Tests/Modules/Control/CombineDocumentsFixture.cs b/tests/core/Statiq.Core.Tests/Modules/Control/CombineDocumentsFixture.cs index 7eee661e7..e9340b118 100644 --- a/tests/core/Statiq.Core.Tests/Modules/Control/CombineDocumentsFixture.cs +++ b/tests/core/Statiq.Core.Tests/Modules/Control/CombineDocumentsFixture.cs @@ -26,12 +26,12 @@ public async Task AppendsContent() IReadOnlyList results = await ExecuteAsync(new[] { a, b }, combine); // Then - CollectionAssert.AreEqual( - new[] { "ab" }, + Assert.That( await results .ToAsyncEnumerable() .SelectAwait(async x => await x.GetContentStringAsync()) - .ToListAsync()); + .ToListAsync(), + Is.EqualTo(new[] { "ab" }).AsCollection); } [Test] diff --git a/tests/core/Statiq.Core.Tests/Modules/Control/ConcatDocumentsFixture.cs b/tests/core/Statiq.Core.Tests/Modules/Control/ConcatDocumentsFixture.cs index 617113755..cf6189b17 100644 --- a/tests/core/Statiq.Core.Tests/Modules/Control/ConcatDocumentsFixture.cs +++ b/tests/core/Statiq.Core.Tests/Modules/Control/ConcatDocumentsFixture.cs @@ -36,16 +36,19 @@ public async Task ResultsInCorrectCountsWithInputDocumentsOnConcat() IReadOnlyList results = await ExecuteAsync(a, new ConcatDocuments(b), c); // Then - Assert.AreEqual(1, a.ExecuteCount); - Assert.AreEqual(1, b.ExecuteCount); - Assert.AreEqual(1, c.ExecuteCount); - Assert.AreEqual(1, a.InputCount); - Assert.AreEqual(2, b.InputCount); - Assert.AreEqual(8, c.InputCount); - Assert.AreEqual(2, a.OutputCount); - Assert.AreEqual(6, b.OutputCount); - Assert.AreEqual(32, c.OutputCount); - results.Count.ShouldBe(32); + Assert.Multiple(() => + { + Assert.That(a.ExecuteCount, Is.EqualTo(1)); + Assert.That(b.ExecuteCount, Is.EqualTo(1)); + Assert.That(c.ExecuteCount, Is.EqualTo(1)); + Assert.That(a.InputCount, Is.EqualTo(1)); + Assert.That(b.InputCount, Is.EqualTo(2)); + Assert.That(c.InputCount, Is.EqualTo(8)); + Assert.That(a.OutputCount, Is.EqualTo(2)); + Assert.That(b.OutputCount, Is.EqualTo(6)); + Assert.That(c.OutputCount, Is.EqualTo(32)); + Assert.That(results, Has.Count.EqualTo(32)); + }); } } } diff --git a/tests/core/Statiq.Core.Tests/Modules/Control/ExecuteSwitchFixture.cs b/tests/core/Statiq.Core.Tests/Modules/Control/ExecuteSwitchFixture.cs index 0661fc11a..163734263 100644 --- a/tests/core/Statiq.Core.Tests/Modules/Control/ExecuteSwitchFixture.cs +++ b/tests/core/Statiq.Core.Tests/Modules/Control/ExecuteSwitchFixture.cs @@ -24,10 +24,13 @@ public async Task SwitchResultsInCorrectCounts() await ExecuteAsync(a, switchModule); // Then - Assert.AreEqual(1, a.ExecuteCount); - Assert.AreEqual(1, b.ExecuteCount); - Assert.AreEqual(1, c.ExecuteCount); - Assert.AreEqual(1, d.ExecuteCount); + Assert.Multiple(() => + { + Assert.That(a.ExecuteCount, Is.EqualTo(1)); + Assert.That(b.ExecuteCount, Is.EqualTo(1)); + Assert.That(c.ExecuteCount, Is.EqualTo(1)); + Assert.That(d.ExecuteCount, Is.EqualTo(1)); + }); } [Test] @@ -47,11 +50,14 @@ public async Task SwitchNoCasesResultsInCorrectCounts() await ExecuteAsync(a, switchModule, c); // Then - Assert.AreEqual(1, a.ExecuteCount); - Assert.AreEqual(1, b.ExecuteCount); - Assert.AreEqual(3, b.InputCount); - Assert.AreEqual(3, b.OutputCount); - Assert.AreEqual(3, c.InputCount); + Assert.Multiple(() => + { + Assert.That(a.ExecuteCount, Is.EqualTo(1)); + Assert.That(b.ExecuteCount, Is.EqualTo(1)); + Assert.That(b.InputCount, Is.EqualTo(3)); + Assert.That(b.OutputCount, Is.EqualTo(3)); + Assert.That(c.InputCount, Is.EqualTo(3)); + }); } [Test] @@ -71,11 +77,14 @@ public async Task MissingDefaultResultsInCorrectCounts() await ExecuteAsync(a, switchModule, c); // Then - Assert.AreEqual(1, a.ExecuteCount); - Assert.AreEqual(1, b.ExecuteCount); - Assert.AreEqual(1, b.InputCount); - Assert.AreEqual(1, b.OutputCount); - Assert.AreEqual(3, c.InputCount); + Assert.Multiple(() => + { + Assert.That(a.ExecuteCount, Is.EqualTo(1)); + Assert.That(b.ExecuteCount, Is.EqualTo(1)); + Assert.That(b.InputCount, Is.EqualTo(1)); + Assert.That(b.OutputCount, Is.EqualTo(1)); + Assert.That(c.InputCount, Is.EqualTo(3)); + }); } [Test] @@ -95,11 +104,14 @@ public async Task ArrayInCaseResultsInCorrectCounts() await ExecuteAsync(a, switchModule, c); // Then - Assert.AreEqual(1, a.ExecuteCount); - Assert.AreEqual(1, b.ExecuteCount); - Assert.AreEqual(2, b.InputCount); - Assert.AreEqual(2, b.OutputCount); - Assert.AreEqual(3, c.InputCount); + Assert.Multiple(() => + { + Assert.That(a.ExecuteCount, Is.EqualTo(1)); + Assert.That(b.ExecuteCount, Is.EqualTo(1)); + Assert.That(b.InputCount, Is.EqualTo(2)); + Assert.That(b.OutputCount, Is.EqualTo(2)); + Assert.That(c.InputCount, Is.EqualTo(3)); + }); } [Test] @@ -118,7 +130,7 @@ public async Task OmittingCasesAndDefaultResultsInCorrectCounts() await ExecuteAsync(a, switchModule, b); // Then - Assert.AreEqual(3, b.InputCount); + Assert.That(b.InputCount, Is.EqualTo(3)); } } } diff --git a/tests/core/Statiq.Core.Tests/Modules/Control/GroupDocumentsFixture.cs b/tests/core/Statiq.Core.Tests/Modules/Control/GroupDocumentsFixture.cs index 5fefb3d1f..cf87cdf99 100644 --- a/tests/core/Statiq.Core.Tests/Modules/Control/GroupDocumentsFixture.cs +++ b/tests/core/Statiq.Core.Tests/Modules/Control/GroupDocumentsFixture.cs @@ -35,7 +35,7 @@ public async Task SetsCorrectMetadata() IReadOnlyList results = await ExecuteAsync(count, groupByMany, gatherData); // Then - CollectionAssert.AreEquivalent(new[] { 0, 1, 2, 3 }, groupKey); + Assert.That(groupKey, Is.EquivalentTo(new[] { 0, 1, 2, 3 })); } [Test] @@ -66,11 +66,14 @@ public async Task SetsDocumentsInMetadata() IReadOnlyList results = await ExecuteAsync(count, groupByMany, orderBy, gatherData); // Then - Assert.AreEqual(4, content.Count); - CollectionAssert.AreEquivalent(new[] { "3", "6" }, content[0]); - CollectionAssert.AreEquivalent(new[] { "1", "4", "7" }, content[1]); - CollectionAssert.AreEquivalent(new[] { "2", "5", "8" }, content[2]); - CollectionAssert.AreEquivalent(new[] { "1", "2", "3", "4", "5", "6", "7", "8" }, content[3]); + Assert.Multiple(() => + { + Assert.That(content, Has.Count.EqualTo(4)); + Assert.That(content[0], Is.EquivalentTo(new[] { "3", "6" })); + Assert.That(content[1], Is.EquivalentTo(new[] { "1", "4", "7" })); + Assert.That(content[2], Is.EquivalentTo(new[] { "2", "5", "8" })); + Assert.That(content[3], Is.EquivalentTo(new[] { "1", "2", "3", "4", "5", "6", "7", "8" })); + }); } [Test] @@ -96,7 +99,7 @@ public async Task GroupByMetadataKey() IReadOnlyList results = await ExecuteAsync(count, meta, groupByMany, gatherData); // Then - CollectionAssert.AreEquivalent(new[] { 0, 1, 2, 3 }, groupKey); + Assert.That(groupKey, Is.EquivalentTo(new[] { 0, 1, 2, 3 })); } [Test] @@ -127,7 +130,7 @@ public async Task GroupByMetadataKeyWithMissingMetadata() IReadOnlyList results = await ExecuteAsync(count, meta, groupByMany, gatherData); // Then - CollectionAssert.AreEquivalent(new[] { 1, 2, 3 }, groupKey); + Assert.That(groupKey, Is.EquivalentTo(new[] { 1, 2, 3 })); } [Test] @@ -157,7 +160,7 @@ public async Task DefaultComparerIsCaseSensitive() IReadOnlyList results = await ExecuteAsync(meta, groupByMany, gatherData); // Then - CollectionAssert.AreEquivalent(new object[] { "A", "B", "b", "C", "c", 1, "1" }, groupKey); + Assert.That(groupKey, Is.EquivalentTo(new object[] { "A", "B", "b", "C", "c", 1, "1" })); } [Test] @@ -187,7 +190,7 @@ public async Task CaseInsensitiveStringComparer() IReadOnlyList results = await ExecuteAsync(meta, groupByMany, gatherData); // Then - CollectionAssert.AreEquivalent(new object[] { "A", "b", "C", 1 }, groupKey); + Assert.That(groupKey, Is.EquivalentTo(new object[] { "A", "b", "C", 1 })); } } } diff --git a/tests/core/Statiq.Core.Tests/Modules/Control/MergeDocumentsFixture.cs b/tests/core/Statiq.Core.Tests/Modules/Control/MergeDocumentsFixture.cs index 1ecf44430..7aadaa3b4 100644 --- a/tests/core/Statiq.Core.Tests/Modules/Control/MergeDocumentsFixture.cs +++ b/tests/core/Statiq.Core.Tests/Modules/Control/MergeDocumentsFixture.cs @@ -35,7 +35,7 @@ public async Task ReplacesContent() new SetMetadata("Content", Config.FromDocument(async doc => await doc.GetContentStringAsync()))); // Then - CollectionAssert.AreEqual(new[] { "1121" }, results.Select(x => x["Content"])); + Assert.That(results.Select(x => x["Content"]), Is.EqualTo(new[] { "1121" }).AsCollection); } [Test] @@ -60,7 +60,7 @@ public async Task ReverseReplacesContent() new SetMetadata("Content", Config.FromDocument(async doc => await doc.GetContentStringAsync()))); // Then - CollectionAssert.AreEqual(new[] { "11" }, results.Select(x => x["Content"])); + Assert.That(results.Select(x => x["Content"]), Is.EqualTo(new[] { "11" }).AsCollection); } [Test] @@ -82,8 +82,11 @@ public async Task CombinesMetadata() IReadOnlyList results = await ExecuteAsync(a, new MergeDocuments(b)); // Then - CollectionAssert.AreEqual(new[] { 11 }, results.Select(x => x["A"])); - CollectionAssert.AreEqual(new[] { 21 }, results.Select(x => x["B"])); + Assert.Multiple(() => + { + Assert.That(results.Select(x => x["A"]), Is.EqualTo(new[] { 11 }).AsCollection); + Assert.That(results.Select(x => x["B"]), Is.EqualTo(new[] { 21 }).AsCollection); + }); } [Test] @@ -105,7 +108,7 @@ public async Task CombinesAndOverwritesMetadata() IReadOnlyList results = await ExecuteAsync(a, new MergeDocuments(b)); // Then - CollectionAssert.AreEqual(new[] { 21 }, results.Select(x => x["A"])); + Assert.That(results.Select(x => x["A"]), Is.EqualTo(new[] { 21 }).AsCollection); } [Test] @@ -127,10 +130,13 @@ public async Task SingleInputSingleResult() IReadOnlyList results = await ExecuteAsync(a, new MergeDocuments(b)); // Then - Assert.AreEqual(1, a.OutputCount); - Assert.AreEqual(1, b.OutputCount); - CollectionAssert.AreEqual(new[] { 11 }, results.Select(x => x["A"])); - CollectionAssert.AreEqual(new[] { 21 }, results.Select(x => x["B"])); + Assert.Multiple(() => + { + Assert.That(a.OutputCount, Is.EqualTo(1)); + Assert.That(b.OutputCount, Is.EqualTo(1)); + Assert.That(results.Select(x => x["A"]), Is.EqualTo(new[] { 11 }).AsCollection); + Assert.That(results.Select(x => x["B"]), Is.EqualTo(new[] { 21 }).AsCollection); + }); } [Test] @@ -152,11 +158,14 @@ public async Task SingleInputMultipleResults() // When IReadOnlyList results = await ExecuteAsync(a, new MergeDocuments(b)); - // Then - Assert.AreEqual(1, a.OutputCount); - Assert.AreEqual(2, b.OutputCount); - CollectionAssert.AreEqual(new[] { 11, 11 }, results.Select(x => x["A"])); - CollectionAssert.AreEqual(new[] { 21, 22 }, results.Select(x => x["B"])); + Assert.Multiple(() => + { + // Then + Assert.That(a.OutputCount, Is.EqualTo(1)); + Assert.That(b.OutputCount, Is.EqualTo(2)); + Assert.That(results.Select(x => x["A"]), Is.EqualTo(new[] { 11, 11 }).AsCollection); + Assert.That(results.Select(x => x["B"]), Is.EqualTo(new[] { 21, 22 }).AsCollection); + }); } [Test] @@ -236,15 +245,18 @@ public async Task ResultsInCorrectCountsWithInputDocuments() IReadOnlyList results = await ExecuteAsync(a, new MergeDocuments(b), c); // Then - Assert.AreEqual(1, a.ExecuteCount); - Assert.AreEqual(1, b.ExecuteCount); - Assert.AreEqual(1, c.ExecuteCount); - Assert.AreEqual(1, a.InputCount); - Assert.AreEqual(2, b.InputCount); - Assert.AreEqual(12, c.InputCount); - Assert.AreEqual(2, a.OutputCount); - Assert.AreEqual(6, b.OutputCount); - Assert.AreEqual(48, c.OutputCount); + Assert.Multiple(() => + { + Assert.That(a.ExecuteCount, Is.EqualTo(1)); + Assert.That(b.ExecuteCount, Is.EqualTo(1)); + Assert.That(c.ExecuteCount, Is.EqualTo(1)); + Assert.That(a.InputCount, Is.EqualTo(1)); + Assert.That(b.InputCount, Is.EqualTo(2)); + Assert.That(c.InputCount, Is.EqualTo(12)); + Assert.That(a.OutputCount, Is.EqualTo(2)); + Assert.That(b.OutputCount, Is.EqualTo(6)); + Assert.That(c.OutputCount, Is.EqualTo(48)); + }); results.Count.ShouldBe(48); } } diff --git a/tests/core/Statiq.Core.Tests/Modules/Control/OrderDocumentsFixture.cs b/tests/core/Statiq.Core.Tests/Modules/Control/OrderDocumentsFixture.cs index bf8f686c9..8b09a622a 100644 --- a/tests/core/Statiq.Core.Tests/Modules/Control/OrderDocumentsFixture.cs +++ b/tests/core/Statiq.Core.Tests/Modules/Control/OrderDocumentsFixture.cs @@ -107,8 +107,8 @@ public async Task OrdersThenByInAscendingOrder() await ExecuteAsync(count, count2, orderBy, gatherData); // Then - Assert.AreEqual(10, content.Count); // (4+1) * (21+1) - CollectionAssert.AreEqual(new[] { "11", "12", "23", "24", "35", "36", "47", "48", "59", "510" }, content); + Assert.That(content, Has.Count.EqualTo(10)); // (4+1) * (21+1) + Assert.That(content, Is.EqualTo(new[] { "11", "12", "23", "24", "35", "36", "47", "48", "59", "510" }).AsCollection); } [Test] @@ -139,8 +139,8 @@ public async Task OrdersThenByInDescendingOrder() await ExecuteAsync(count, count2, orderBy, gatherData); // Then - Assert.AreEqual(10, content.Count); // (4+1) * (21+1) - CollectionAssert.AreEqual(new[] { "12", "11", "24", "23", "36", "35", "48", "47", "510", "59" }, content); + Assert.That(content.Count, Is.EqualTo(10)); // (4+1) * (21+1) + Assert.That(content, Is.EqualTo(new[] { "12", "11", "24", "23", "36", "35", "48", "47", "510", "59" }).AsCollection); } [Test] @@ -172,8 +172,8 @@ public async Task OrdersDescendingThenByInDescendingOrder() await ExecuteAsync(count, count2, orderBy, gatherData); // Then - Assert.AreEqual(10, content.Count); // (4+1) * (21+1) - CollectionAssert.AreEqual(new[] { "510", "59", "48", "47", "36", "35", "24", "23", "12", "11" }, content); + Assert.That(content, Has.Count.EqualTo(10)); // (4+1) * (21+1) + Assert.That(content, Is.EqualTo(new[] { "510", "59", "48", "47", "36", "35", "24", "23", "12", "11" }).AsCollection); } [Test] @@ -204,8 +204,8 @@ public async Task OrdersDescendingThenByInAscendingOrder() await ExecuteAsync(count, count2, orderBy, gatherData); // Then - Assert.AreEqual(10, content.Count); // (4+1) * (21+1) - CollectionAssert.AreEqual(new[] { "59", "510", "47", "48", "35", "36", "23", "24", "11", "12" }, content); + Assert.That(content, Has.Count.EqualTo(10)); // (4+1) * (21+1) + Assert.That(content, Is.EqualTo(new[] { "59", "510", "47", "48", "35", "36", "23", "24", "11", "12" }).AsCollection); } [Test] diff --git a/tests/core/Statiq.Core.Tests/Modules/Control/PaginateDocumentsFixture.cs b/tests/core/Statiq.Core.Tests/Modules/Control/PaginateDocumentsFixture.cs index fb51028ac..1f6fa4e92 100644 --- a/tests/core/Statiq.Core.Tests/Modules/Control/PaginateDocumentsFixture.cs +++ b/tests/core/Statiq.Core.Tests/Modules/Control/PaginateDocumentsFixture.cs @@ -40,10 +40,13 @@ public async Task PaginateSetsDocumentsInMetadata() await ExecuteAsync(count, paginate, gatherData); // Then - Assert.AreEqual(3, content.Count); - CollectionAssert.AreEqual(new[] { "1", "2", "3" }, content[0]); - CollectionAssert.AreEqual(new[] { "4", "5", "6" }, content[1]); - CollectionAssert.AreEqual(new[] { "7", "8" }, content[2]); + Assert.Multiple(() => + { + Assert.That(content, Has.Count.EqualTo(3)); + Assert.That(content[0], Is.EqualTo(new[] { "1", "2", "3" }).AsCollection); + Assert.That(content[1], Is.EqualTo(new[] { "4", "5", "6" }).AsCollection); + Assert.That(content[2], Is.EqualTo(new[] { "7", "8" }).AsCollection); + }); } [Test] diff --git a/tests/core/Statiq.Core.Tests/Modules/Control/ProcessSidecarFileFixture.cs b/tests/core/Statiq.Core.Tests/Modules/Control/ProcessSidecarFileFixture.cs index 26dd04ade..a4281148e 100644 --- a/tests/core/Statiq.Core.Tests/Modules/Control/ProcessSidecarFileFixture.cs +++ b/tests/core/Statiq.Core.Tests/Modules/Control/ProcessSidecarFileFixture.cs @@ -36,8 +36,11 @@ public async Task LoadsSidecarFile() IReadOnlyList documents = await ExecuteAsync(inputs, context, sidecar); // Then - Assert.AreEqual("data: a1", lodedSidecarContent); - Assert.AreEqual("File a1", documents.Single().Content); + Assert.Multiple(() => + { + Assert.That(lodedSidecarContent, Is.EqualTo("data: a1")); + Assert.That(documents.Single().Content, Is.EqualTo("File a1")); + }); } [Test] @@ -63,8 +66,11 @@ public async Task LoadsCustomSidecarFile() IReadOnlyList documents = await ExecuteAsync(inputs, context, sidecar); // Then - Assert.AreEqual("data: other", lodedSidecarContent); - Assert.AreEqual("File a1", documents.Single().Content); + Assert.Multiple(() => + { + Assert.That(lodedSidecarContent, Is.EqualTo("data: other")); + Assert.That(documents.Single().Content, Is.EqualTo("File a1")); + }); } [Test] @@ -90,8 +96,11 @@ public async Task ReturnsOriginalDocumentForMissingSidecarFile() IReadOnlyList documents = await ExecuteAsync(inputs, context, sidecar); // Then - Assert.IsFalse(executedSidecarModules); - Assert.AreEqual(inputs.First(), documents.First()); + Assert.Multiple(() => + { + Assert.That(executedSidecarModules, Is.False); + Assert.That(documents.First(), Is.EqualTo(inputs.First())); + }); } private TestDocument GetDocument(string source, string content) => diff --git a/tests/core/Statiq.Core.Tests/Modules/Control/ReplaceDocumentsFixture.cs b/tests/core/Statiq.Core.Tests/Modules/Control/ReplaceDocumentsFixture.cs index b3f746e5d..ea59f6e01 100644 --- a/tests/core/Statiq.Core.Tests/Modules/Control/ReplaceDocumentsFixture.cs +++ b/tests/core/Statiq.Core.Tests/Modules/Control/ReplaceDocumentsFixture.cs @@ -36,8 +36,8 @@ public async Task PipelineReturnsCorrectDocuments() await engine.ExecuteAsync(cancellationTokenSource.Token); // Then - Assert.AreEqual(4, content.Count); - CollectionAssert.AreEquivalent(new[] { "A", "B", "C", "D" }, content); + Assert.That(content, Has.Count.EqualTo(4)); + Assert.That(content, Is.EquivalentTo(new[] { "A", "B", "C", "D" })); } [Test] @@ -63,8 +63,8 @@ public async Task EmptyConstructorWithSpecifiedPipelinesReturnsCorrectDocuments( await engine.ExecuteAsync(cancellationTokenSource.Token); // Then - Assert.AreEqual(6, content.Count); - CollectionAssert.AreEquivalent(new[] { "A", "B", "C", "D", "G", "H" }, content); + Assert.That(content, Has.Count.EqualTo(6)); + Assert.That(content, Is.EquivalentTo(new[] { "A", "B", "C", "D", "G", "H" })); } [Test] @@ -90,8 +90,8 @@ public async Task SpecifiedPipelineDocumentsAreReturnedInCorrectOrder() await engine.ExecuteAsync(cancellationTokenSource.Token); // Then - Assert.AreEqual(6, content.Count); - CollectionAssert.AreEquivalent(new[] { "G", "H", "A", "B", "C", "D" }, content); + Assert.That(content, Has.Count.EqualTo(6)); + Assert.That(content, Is.EquivalentTo(new[] { "G", "H", "A", "B", "C", "D" })); } } } diff --git a/tests/core/Statiq.Core.Tests/Modules/Extensibility/ExecuteConfigFixture.cs b/tests/core/Statiq.Core.Tests/Modules/Extensibility/ExecuteConfigFixture.cs index 6480415cc..465631fb1 100644 --- a/tests/core/Statiq.Core.Tests/Modules/Extensibility/ExecuteConfigFixture.cs +++ b/tests/core/Statiq.Core.Tests/Modules/Extensibility/ExecuteConfigFixture.cs @@ -40,7 +40,7 @@ public async Task ContextConfigReturnsInputsForNullResult() IReadOnlyList outputs = await ExecuteAsync(inputs, execute); // Then - CollectionAssert.AreEqual(inputs, outputs); + Assert.That(outputs, Is.EqualTo(inputs).AsCollection); } [Test] @@ -156,7 +156,7 @@ public async Task DocumentConfigReturnsInputsForNullResult() IReadOnlyList outputs = await ExecuteAsync(inputs, execute); // Then - CollectionAssert.AreEqual(inputs, outputs); + Assert.That(outputs, Is.EqualTo(inputs).AsCollection); } [Test] @@ -174,7 +174,7 @@ public async Task DocumentConfigReturnsDocumentForSingleResultDocument() IReadOnlyList result = await ExecuteAsync(count, execute); // Then - CollectionAssert.AreEquivalent(document, result.Single()); + Assert.That(result.Single(), Is.EquivalentTo(document)); } [Test] diff --git a/tests/core/Statiq.Core.Tests/Modules/IO/CopyFilesFixture.cs b/tests/core/Statiq.Core.Tests/Modules/IO/CopyFilesFixture.cs index f8b900326..d400efb56 100644 --- a/tests/core/Statiq.Core.Tests/Modules/IO/CopyFilesFixture.cs +++ b/tests/core/Statiq.Core.Tests/Modules/IO/CopyFilesFixture.cs @@ -41,12 +41,15 @@ public async Task RecursivePatternCopiesFiles() await ExecuteAsync(context, copyFiles); // Then - Assert.IsTrue(context.FileSystem.GetOutputFile("test-a.txt").Exists); - Assert.IsTrue(context.FileSystem.GetOutputFile("test-b.txt").Exists); - Assert.IsTrue(context.FileSystem.GetOutputFile("Subfolder/test-c.txt").Exists); - Assert.IsTrue(context.FileSystem.GetOutputDirectory("Subfolder").Exists); - Assert.IsFalse(context.FileSystem.GetOutputFile("markdown-x.md").Exists); - Assert.IsFalse(context.FileSystem.GetOutputFile("Subfolder/markdown-y.md").Exists); + Assert.Multiple(() => + { + Assert.That(context.FileSystem.GetOutputFile("test-a.txt").Exists, Is.True); + Assert.That(context.FileSystem.GetOutputFile("test-b.txt").Exists, Is.True); + Assert.That(context.FileSystem.GetOutputFile("Subfolder/test-c.txt").Exists, Is.True); + Assert.That(context.FileSystem.GetOutputDirectory("Subfolder").Exists, Is.True); + Assert.That(context.FileSystem.GetOutputFile("markdown-x.md").Exists, Is.False); + Assert.That(context.FileSystem.GetOutputFile("Subfolder/markdown-y.md").Exists, Is.False); + }); } [Test] @@ -60,12 +63,15 @@ public async Task CopyFilesInTopDirectoryOnly() await ExecuteAsync(context, copyFiles); // Then - Assert.IsTrue(context.FileSystem.GetOutputFile("test-a.txt").Exists); - Assert.IsTrue(context.FileSystem.GetOutputFile("test-b.txt").Exists); - Assert.IsFalse(context.FileSystem.GetOutputFile("Subfolder/test-c.txt").Exists); - Assert.IsFalse(context.FileSystem.GetOutputDirectory("Subfolder").Exists); - Assert.IsFalse(context.FileSystem.GetOutputFile("markdown-x.md").Exists); - Assert.IsFalse(context.FileSystem.GetOutputFile("Subfolder/markdown-y.md").Exists); + Assert.Multiple(() => + { + Assert.That(context.FileSystem.GetOutputFile("test-a.txt").Exists, Is.True); + Assert.That(context.FileSystem.GetOutputFile("test-b.txt").Exists, Is.True); + Assert.That(context.FileSystem.GetOutputFile("Subfolder/test-c.txt").Exists, Is.False); + Assert.That(context.FileSystem.GetOutputDirectory("Subfolder").Exists, Is.False); + Assert.That(context.FileSystem.GetOutputFile("markdown-x.md").Exists, Is.False); + Assert.That(context.FileSystem.GetOutputFile("Subfolder/markdown-y.md").Exists, Is.False); + }); } [Test] @@ -79,12 +85,15 @@ public async Task CopyFilesInSubfolderOnly() await ExecuteAsync(context, copyFiles); // Then - Assert.IsFalse(context.FileSystem.GetOutputFile("test-a.txt").Exists); - Assert.IsFalse(context.FileSystem.GetOutputFile("test-b.txt").Exists); - Assert.IsTrue(context.FileSystem.GetOutputFile("Subfolder/test-c.txt").Exists); - Assert.IsTrue(context.FileSystem.GetOutputDirectory("Subfolder").Exists); - Assert.IsFalse(context.FileSystem.GetOutputFile("markdown-x.md").Exists); - Assert.IsFalse(context.FileSystem.GetOutputFile("Subfolder/markdown-y.md").Exists); + Assert.Multiple(() => + { + Assert.That(context.FileSystem.GetOutputFile("test-a.txt").Exists, Is.False); + Assert.That(context.FileSystem.GetOutputFile("test-b.txt").Exists, Is.False); + Assert.That(context.FileSystem.GetOutputFile("Subfolder/test-c.txt").Exists, Is.True); + Assert.That(context.FileSystem.GetOutputDirectory("Subfolder").Exists, Is.True); + Assert.That(context.FileSystem.GetOutputFile("markdown-x.md").Exists, Is.False); + Assert.That(context.FileSystem.GetOutputFile("Subfolder/markdown-y.md").Exists, Is.False); + }); } [Test] @@ -98,13 +107,16 @@ public async Task DoesNotCopyFilesAboveInputPath() await ExecuteAsync(context, copyFiles); // Then - Assert.IsFalse(context.FileSystem.GetOutputFile("test-a.txt").Exists); - Assert.IsFalse(context.FileSystem.GetOutputFile("test-b.txt").Exists); - Assert.IsFalse(context.FileSystem.GetOutputFile("Subfolder/test-c.txt").Exists); - Assert.IsFalse(context.FileSystem.GetOutputDirectory("Subfolder").Exists); - Assert.IsFalse(context.FileSystem.GetOutputFile("markdown-x.md").Exists); - Assert.IsFalse(context.FileSystem.GetOutputFile("Subfolder/markdown-y.md").Exists); - Assert.IsFalse(context.FileSystem.GetOutputFile("test-above-input.txt").Exists); + Assert.Multiple(() => + { + Assert.That(context.FileSystem.GetOutputFile("test-a.txt").Exists, Is.False); + Assert.That(context.FileSystem.GetOutputFile("test-b.txt").Exists, Is.False); + Assert.That(context.FileSystem.GetOutputFile("Subfolder/test-c.txt").Exists, Is.False); + Assert.That(context.FileSystem.GetOutputDirectory("Subfolder").Exists, Is.False); + Assert.That(context.FileSystem.GetOutputFile("markdown-x.md").Exists, Is.False); + Assert.That(context.FileSystem.GetOutputFile("Subfolder/markdown-y.md").Exists, Is.False); + Assert.That(context.FileSystem.GetOutputFile("test-above-input.txt").Exists, Is.False); + }); } [Test] @@ -118,13 +130,16 @@ public async Task CopyFilesAboveInputPathWithOthers() await ExecuteAsync(context, copyFiles); // Then - Assert.IsTrue(context.FileSystem.GetOutputFile("test-a.txt").Exists); - Assert.IsTrue(context.FileSystem.GetOutputFile("test-b.txt").Exists); - Assert.IsTrue(context.FileSystem.GetOutputFile("Subfolder/test-c.txt").Exists); - Assert.IsTrue(context.FileSystem.GetOutputDirectory("Subfolder").Exists); - Assert.IsFalse(context.FileSystem.GetOutputFile("markdown-x.md").Exists); - Assert.IsFalse(context.FileSystem.GetOutputFile("Subfolder/markdown-y.md").Exists); - Assert.IsFalse(context.FileSystem.GetOutputFile("test-above-input.txt").Exists); // Files outside an input path will not be copied + Assert.Multiple(() => + { + Assert.That(context.FileSystem.GetOutputFile("test-a.txt").Exists, Is.True); + Assert.That(context.FileSystem.GetOutputFile("test-b.txt").Exists, Is.True); + Assert.That(context.FileSystem.GetOutputFile("Subfolder/test-c.txt").Exists, Is.True); + Assert.That(context.FileSystem.GetOutputDirectory("Subfolder").Exists, Is.True); + Assert.That(context.FileSystem.GetOutputFile("markdown-x.md").Exists, Is.False); + Assert.That(context.FileSystem.GetOutputFile("Subfolder/markdown-y.md").Exists, Is.False); + Assert.That(context.FileSystem.GetOutputFile("test-above-input.txt").Exists, Is.False); // Files outside an input path will not be copied + }); } [Test] @@ -138,12 +153,15 @@ public async Task CopyFolderFromAbsolutePath() await ExecuteAsync(context, copyFiles); // Then - Assert.IsTrue(context.FileSystem.GetOutputFile("test-a.txt").Exists); - Assert.IsTrue(context.FileSystem.GetOutputFile("test-b.txt").Exists); - Assert.IsTrue(context.FileSystem.GetOutputFile("Subfolder/test-c.txt").Exists); - Assert.IsTrue(context.FileSystem.GetOutputDirectory("Subfolder").Exists); - Assert.IsFalse(context.FileSystem.GetOutputFile("markdown-x.md").Exists); - Assert.IsFalse(context.FileSystem.GetOutputFile("Subfolder/markdown-y.md").Exists); + Assert.Multiple(() => + { + Assert.That(context.FileSystem.GetOutputFile("test-a.txt").Exists, Is.True); + Assert.That(context.FileSystem.GetOutputFile("test-b.txt").Exists, Is.True); + Assert.That(context.FileSystem.GetOutputFile("Subfolder/test-c.txt").Exists, Is.True); + Assert.That(context.FileSystem.GetOutputDirectory("Subfolder").Exists, Is.True); + Assert.That(context.FileSystem.GetOutputFile("markdown-x.md").Exists, Is.False); + Assert.That(context.FileSystem.GetOutputFile("Subfolder/markdown-y.md").Exists, Is.False); + }); } [Test] @@ -157,12 +175,15 @@ public async Task CopyNonExistingFolder() await ExecuteAsync(context, copyFiles); // Then - Assert.IsFalse(context.FileSystem.GetOutputFile("test-a.txt").Exists); - Assert.IsFalse(context.FileSystem.GetOutputFile("test-b.txt").Exists); - Assert.IsFalse(context.FileSystem.GetOutputFile("Subfolder/test-c.txt").Exists); - Assert.IsFalse(context.FileSystem.GetOutputDirectory("Subfolder").Exists); - Assert.IsFalse(context.FileSystem.GetOutputFile("markdown-x.md").Exists); - Assert.IsFalse(context.FileSystem.GetOutputFile("Subfolder/markdown-y.md").Exists); + Assert.Multiple(() => + { + Assert.That(context.FileSystem.GetOutputFile("test-a.txt").Exists, Is.False); + Assert.That(context.FileSystem.GetOutputFile("test-b.txt").Exists, Is.False); + Assert.That(context.FileSystem.GetOutputFile("Subfolder/test-c.txt").Exists, Is.False); + Assert.That(context.FileSystem.GetOutputDirectory("Subfolder").Exists, Is.False); + Assert.That(context.FileSystem.GetOutputFile("markdown-x.md").Exists, Is.False); + Assert.That(context.FileSystem.GetOutputFile("Subfolder/markdown-y.md").Exists, Is.False); + }); } public async Task ShouldSetSourceAndDestination() diff --git a/tests/core/Statiq.Core.Tests/Modules/IO/ReadWebFixture.cs b/tests/core/Statiq.Core.Tests/Modules/IO/ReadWebFixture.cs index cc7999f91..ca4b425e2 100644 --- a/tests/core/Statiq.Core.Tests/Modules/IO/ReadWebFixture.cs +++ b/tests/core/Statiq.Core.Tests/Modules/IO/ReadWebFixture.cs @@ -41,14 +41,17 @@ public async Task SingleHtmlDownloadGetStream() // Then Dictionary headers = result[Keys.SourceHeaders] as Dictionary; - Assert.IsNotNull(headers, "Header cannot be null"); - Assert.IsTrue(headers.Count > 0, "Headers must contain contents"); - - foreach (KeyValuePair h in headers) + Assert.Multiple(() => { - Assert.IsNotEmpty(h.Key, "Header key cannot be empty"); - Assert.IsNotEmpty(h.Value, "Header value cannot be empty"); - } + Assert.That(headers, Is.Not.Null, "Header cannot be null"); + Assert.That(headers, Is.Not.Empty, "Headers must contain contents"); + + foreach (KeyValuePair h in headers) + { + Assert.That(h.Key, Is.Not.Empty, "Header key cannot be empty"); + Assert.That(h.Value, Is.Not.Empty, "Header value cannot be empty"); + } + }); result.Content.ShouldNotBeEmpty(); } @@ -81,14 +84,17 @@ public async Task MultipleHtmlDownload() { Dictionary headers = result[Keys.SourceHeaders] as Dictionary; - Assert.IsNotNull(headers, "Header cannot be null"); - Assert.IsTrue(headers.Count > 0, "Headers must contain contents"); - - foreach (KeyValuePair h in headers) + Assert.Multiple(() => { - Assert.IsNotEmpty(h.Key, "Header key cannot be empty"); - Assert.IsNotEmpty(h.Value, "Header value cannot be empty"); - } + Assert.That(headers, Is.Not.Null, "Header cannot be null"); + Assert.That(headers, Is.Not.Empty, "Headers must contain contents"); + + foreach (KeyValuePair h in headers) + { + Assert.That(h.Key, Is.Not.Empty, "Header key cannot be empty"); + Assert.That(h.Value, Is.Not.Empty, "Header value cannot be empty"); + } + }); result.Content.ShouldNotBeEmpty(); } diff --git a/tests/core/Statiq.Core.Tests/Statiq.Core.Tests.csproj b/tests/core/Statiq.Core.Tests/Statiq.Core.Tests.csproj index 17cb182c3..601756aa0 100644 --- a/tests/core/Statiq.Core.Tests/Statiq.Core.Tests.csproj +++ b/tests/core/Statiq.Core.Tests/Statiq.Core.Tests.csproj @@ -3,8 +3,6 @@ - - - + \ No newline at end of file diff --git a/tests/core/TestConsoleApp/TestConsoleApp.csproj b/tests/core/TestConsoleApp/TestConsoleApp.csproj index c73e0d169..64218619a 100644 --- a/tests/core/TestConsoleApp/TestConsoleApp.csproj +++ b/tests/core/TestConsoleApp/TestConsoleApp.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp3.1 + net8.0 diff --git a/tests/extensions/Statiq.CodeAnalysis.Tests/AnalyzeCSharpTypesFixture.cs b/tests/extensions/Statiq.CodeAnalysis.Tests/AnalyzeCSharpTypesFixture.cs index bf7654848..ce7de2c8b 100644 --- a/tests/extensions/Statiq.CodeAnalysis.Tests/AnalyzeCSharpTypesFixture.cs +++ b/tests/extensions/Statiq.CodeAnalysis.Tests/AnalyzeCSharpTypesFixture.cs @@ -435,7 +435,11 @@ enum Yellow // Then results.Single(x => x["Name"].Equals("Green"))["SpecificKind"].ShouldBe("Class"); results.Single(x => x["Name"].Equals("Blue"))["SpecificKind"].ShouldBe("Class"); +#if NET8_0_OR_GREATER + results.Single(x => x["Name"].Equals("Red"))["SpecificKind"].ShouldBe("Struct"); +#else results.Single(x => x["Name"].Equals("Red"))["SpecificKind"].ShouldBe("Structure"); +#endif results.Single(x => x["Name"].Equals("Yellow"))["SpecificKind"].ShouldBe("Enum"); }