From 58f6d09c573a5f6a3c16a39728ed333862f36d5c Mon Sep 17 00:00:00 2001 From: Philippe Matray Date: Fri, 27 Feb 2026 17:34:55 +0100 Subject: [PATCH] Replace FluentAssertions with Shouldly Migrate the test assertion library from FluentAssertions to Shouldly across both test projects. All 455 tests pass after migration. Fixes #134 --- ...ical.VirtualFileSystem.GitHub.Tests.csproj | 2 +- .../GitHubLoadResultTests.cs | 20 +- .../GitHubLoaderOptionsTests.cs | 66 ++--- .../GitHubRepositoryLoaderTests.cs | 38 +-- .../GlobalUsings.cs | 2 +- .../VFSGitHubExtensionsTests.cs | 16 +- ...typical.VirtualFileSystem.UnitTests.csproj | 2 +- .../VirtualFileSystemExceptionTests.cs | 12 +- .../Extensions/VFSBinaryExtensionsTests.cs | 118 ++++---- .../Extensions/VFSBulkExtensionsTests.cs | 252 +++++++++--------- .../Extensions/VFSPathExtensionsTests.cs | 60 ++--- .../GlobalUsings.cs | 2 +- .../Models/DirectoryNodeTests.cs | 22 +- .../Models/FileNodeTests.cs | 10 +- .../Models/RootNodeTests.cs | 12 +- .../ValueObjects/VFSDirectoryPathTests.cs | 148 +++++----- .../Models/ValueObjects/VFSFilePathTests.cs | 30 +-- .../Models/ValueObjects/VFSPathTests.cs | 6 +- .../Models/ValueObjects/VFSRootPathTests.cs | 14 +- .../ServiceCollectionExtensionsTests.cs | 3 +- ...lFileSystem_MethodCreateDirectory_Tests.cs | 58 ++-- ...irtualFileSystem_MethodCreateFile_Tests.cs | 45 ++-- ...lFileSystem_MethodDeleteDirectory_Tests.cs | 24 +- ...irtualFileSystem_MethodDeleteFile_Tests.cs | 15 +- ...ualFileSystem_MethodMoveDirectory_Tests.cs | 29 +- .../VirtualFileSystem_MethodMoveFile_Tests.cs | 29 +- ...lFileSystem_MethodRenameDirectory_Tests.cs | 144 +++++----- ...irtualFileSystem_MethodRenameFile_Tests.cs | 35 ++- ...lFileSystem_MethodFindDirectories_Tests.cs | 16 +- ...VirtualFileSystem_MethodFindFiles_Tests.cs | 28 +- ...tualFileSystem_MethodGetDirectory_Tests.cs | 10 +- .../VirtualFileSystem_MethodGetFile_Tests.cs | 6 +- ...rtualFileSystem_MethodGetRootPath_Tests.cs | 4 +- .../VirtualFileSystem_MethodGetTree_Tests.cs | 10 +- ...ileSystem_MethodSelectDirectories_Tests.cs | 10 +- ...lFileSystem_MethodTryGetDirectory_Tests.cs | 10 +- ...irtualFileSystem_MethodTryGetFile_Tests.cs | 10 +- .../VirtualFileSystemFactoryTests.cs | 8 +- .../VirtualFileSystem_Constructor_Tests.cs | 12 +- .../VirtualFileSystem_MethodToString_Tests.cs | 2 +- .../UndoRedo/ChangeHistoryTests.cs | 14 +- 41 files changed, 667 insertions(+), 687 deletions(-) diff --git a/tests/Atypical.VirtualFileSystem.GitHub.Tests/Atypical.VirtualFileSystem.GitHub.Tests.csproj b/tests/Atypical.VirtualFileSystem.GitHub.Tests/Atypical.VirtualFileSystem.GitHub.Tests.csproj index ff4ed02..54ef65d 100644 --- a/tests/Atypical.VirtualFileSystem.GitHub.Tests/Atypical.VirtualFileSystem.GitHub.Tests.csproj +++ b/tests/Atypical.VirtualFileSystem.GitHub.Tests/Atypical.VirtualFileSystem.GitHub.Tests.csproj @@ -6,7 +6,7 @@ - + diff --git a/tests/Atypical.VirtualFileSystem.GitHub.Tests/GitHubLoadResultTests.cs b/tests/Atypical.VirtualFileSystem.GitHub.Tests/GitHubLoadResultTests.cs index 75a1209..09e8b12 100644 --- a/tests/Atypical.VirtualFileSystem.GitHub.Tests/GitHubLoadResultTests.cs +++ b/tests/Atypical.VirtualFileSystem.GitHub.Tests/GitHubLoadResultTests.cs @@ -15,7 +15,7 @@ public void FullRepositoryName_ShouldCombineOwnerAndRepo() var result = CreateTestResult(); // Act & Assert - result.FullRepositoryName.Should().Be("testowner/testrepo"); + result.FullRepositoryName.ShouldBe("testowner/testrepo"); } [Fact] @@ -30,7 +30,7 @@ public void FilesSkipped_ShouldReturnCountOfSkippedFiles() var result = CreateTestResult(skippedFiles: skippedFiles); // Act & Assert - result.FilesSkipped.Should().Be(2); + result.FilesSkipped.ShouldBe(2); } [Fact] @@ -44,7 +44,7 @@ public void HasSkippedFiles_ShouldReturnTrueWhenFilesSkipped() var result = CreateTestResult(skippedFiles: skippedFiles); // Act & Assert - result.HasSkippedFiles.Should().BeTrue(); + result.HasSkippedFiles.ShouldBeTrue(); } [Fact] @@ -54,7 +54,7 @@ public void HasSkippedFiles_ShouldReturnFalseWhenNoFilesSkipped() var result = CreateTestResult(); // Act & Assert - result.HasSkippedFiles.Should().BeFalse(); + result.HasSkippedFiles.ShouldBeFalse(); } [Theory] @@ -73,7 +73,7 @@ public void Summary_ShouldContainFormattedSize(long bytes, string expectedSize) var summary = result.Summary; // Assert - summary.Should().Contain(expectedSize); + summary.ShouldContain(expectedSize); } [Fact] @@ -92,7 +92,7 @@ public void Summary_ShouldIncludeSkippedFilesCount() var summary = result.Summary; // Assert - summary.Should().Contain("3 files skipped"); + summary.ShouldContain("3 files skipped"); } [Fact] @@ -112,10 +112,10 @@ public void SkippedFilesByReason_ShouldGroupCorrectly() var byReason = result.SkippedFilesByReason; // Assert - byReason.Should().ContainKey(SkipReason.TooLarge); - byReason[SkipReason.TooLarge].Should().HaveCount(2); - byReason[SkipReason.BinaryExcluded].Should().HaveCount(1); - byReason[SkipReason.ExtensionExcluded].Should().HaveCount(1); + byReason.ShouldContainKey(SkipReason.TooLarge); + byReason[SkipReason.TooLarge].Count.ShouldBe(2); + byReason[SkipReason.BinaryExcluded].Count.ShouldBe(1); + byReason[SkipReason.ExtensionExcluded].Count.ShouldBe(1); } private static GitHubLoadResult CreateTestResult( diff --git a/tests/Atypical.VirtualFileSystem.GitHub.Tests/GitHubLoaderOptionsTests.cs b/tests/Atypical.VirtualFileSystem.GitHub.Tests/GitHubLoaderOptionsTests.cs index 34209d3..34e4834 100644 --- a/tests/Atypical.VirtualFileSystem.GitHub.Tests/GitHubLoaderOptionsTests.cs +++ b/tests/Atypical.VirtualFileSystem.GitHub.Tests/GitHubLoaderOptionsTests.cs @@ -15,17 +15,17 @@ public void Default_ShouldHaveExpectedValues() var options = GitHubLoaderOptions.Default; // Assert - options.AccessToken.Should().BeNull(); - options.Branch.Should().BeNull(); - options.SubPath.Should().BeNull(); - options.TargetPath.Should().Be("/"); - options.MaxFileSize.Should().Be(1_048_576); - options.IncludeExtensions.Should().BeNull(); - options.ExcludeExtensions.Should().BeNull(); - options.ExcludePatterns.Should().BeNull(); - options.IncludeBinaryFiles.Should().BeTrue(); - options.Strategy.Should().Be(GitHubLoadingStrategy.Eager); - options.ProgressCallback.Should().BeNull(); + options.AccessToken.ShouldBeNull(); + options.Branch.ShouldBeNull(); + options.SubPath.ShouldBeNull(); + options.TargetPath.ShouldBe("/"); + options.MaxFileSize.ShouldBe(1_048_576); + options.IncludeExtensions.ShouldBeNull(); + options.ExcludeExtensions.ShouldBeNull(); + options.ExcludePatterns.ShouldBeNull(); + options.IncludeBinaryFiles.ShouldBeTrue(); + options.Strategy.ShouldBe(GitHubLoadingStrategy.Eager); + options.ProgressCallback.ShouldBeNull(); } [Fact] @@ -35,11 +35,11 @@ public void SourceCodeOnly_ShouldExcludeBinaryFilesAndCommonDirectories() var options = GitHubLoaderOptions.SourceCodeOnly; // Assert - options.IncludeBinaryFiles.Should().BeFalse(); - options.ExcludePatterns.Should().NotBeNull(); - options.ExcludePatterns.Should().Contain("**/node_modules/**"); - options.ExcludePatterns.Should().Contain("**/bin/**"); - options.ExcludePatterns.Should().Contain("**/obj/**"); + options.IncludeBinaryFiles.ShouldBeFalse(); + options.ExcludePatterns.ShouldNotBeNull(); + options.ExcludePatterns.ShouldContain("**/node_modules/**"); + options.ExcludePatterns.ShouldContain("**/bin/**"); + options.ExcludePatterns.ShouldContain("**/obj/**"); } [Fact] @@ -49,13 +49,13 @@ public void CSharpOnly_ShouldIncludeOnlyCSharpExtensions() var options = GitHubLoaderOptions.CSharpOnly; // Assert - options.IncludeBinaryFiles.Should().BeFalse(); - options.IncludeExtensions.Should().NotBeNull(); - options.IncludeExtensions.Should().Contain(".cs"); - options.IncludeExtensions.Should().Contain(".csproj"); - options.IncludeExtensions.Should().Contain(".sln"); - options.ExcludePatterns.Should().Contain("**/bin/**"); - options.ExcludePatterns.Should().Contain("**/obj/**"); + options.IncludeBinaryFiles.ShouldBeFalse(); + options.IncludeExtensions.ShouldNotBeNull(); + options.IncludeExtensions.ShouldContain(".cs"); + options.IncludeExtensions.ShouldContain(".csproj"); + options.IncludeExtensions.ShouldContain(".sln"); + options.ExcludePatterns.ShouldContain("**/bin/**"); + options.ExcludePatterns.ShouldContain("**/obj/**"); } [Fact] @@ -65,7 +65,7 @@ public void MetadataOnlyPreset_ShouldUseMetadataOnlyStrategy() var options = GitHubLoaderOptions.MetadataOnlyPreset; // Assert - options.Strategy.Should().Be(GitHubLoadingStrategy.MetadataOnly); + options.Strategy.ShouldBe(GitHubLoadingStrategy.MetadataOnly); } [Theory] @@ -87,7 +87,7 @@ public void IsBinaryExtension_ShouldCorrectlyIdentifyBinaryExtensions(string ext var result = GitHubLoaderOptions.IsBinaryExtension(extension); // Assert - result.Should().Be(expected); + result.ShouldBe(expected); } [Theory] @@ -100,7 +100,7 @@ public void IsBinaryExtension_ShouldBeCaseInsensitive(string extension, bool exp var result = GitHubLoaderOptions.IsBinaryExtension(extension); // Assert - result.Should().Be(expected); + result.ShouldBe(expected); } [Fact] @@ -113,9 +113,9 @@ public void WithRecord_ShouldCreateNewInstanceWithModifiedProperty() var modified = original with { AccessToken = "test-token" }; // Assert - original.AccessToken.Should().BeNull(); - modified.AccessToken.Should().Be("test-token"); - modified.MaxFileSize.Should().Be(original.MaxFileSize); + original.AccessToken.ShouldBeNull(); + modified.AccessToken.ShouldBe("test-token"); + modified.MaxFileSize.ShouldBe(original.MaxFileSize); } [Fact] @@ -131,9 +131,9 @@ public void WithRecord_ShouldSupportMultipleModifications() }; // Assert - options.AccessToken.Should().Be("my-token"); - options.Branch.Should().Be("develop"); - options.MaxFileSize.Should().Be(5_000_000); - options.Strategy.Should().Be(GitHubLoadingStrategy.Lazy); + options.AccessToken.ShouldBe("my-token"); + options.Branch.ShouldBe("develop"); + options.MaxFileSize.ShouldBe(5_000_000); + options.Strategy.ShouldBe(GitHubLoadingStrategy.Lazy); } } diff --git a/tests/Atypical.VirtualFileSystem.GitHub.Tests/GitHubRepositoryLoaderTests.cs b/tests/Atypical.VirtualFileSystem.GitHub.Tests/GitHubRepositoryLoaderTests.cs index 6b85e47..280b761 100644 --- a/tests/Atypical.VirtualFileSystem.GitHub.Tests/GitHubRepositoryLoaderTests.cs +++ b/tests/Atypical.VirtualFileSystem.GitHub.Tests/GitHubRepositoryLoaderTests.cs @@ -32,9 +32,9 @@ public void TryParseGitHubUrl_WithValidUrls_ShouldReturnTrue(string url, string var result = _loader.TryParseGitHubUrl(url, out var owner, out var repo); // Assert - result.Should().BeTrue(); - owner.Should().Be(expectedOwner); - repo.Should().Be(expectedRepo); + result.ShouldBeTrue(); + owner.ShouldBe(expectedOwner); + repo.ShouldBe(expectedRepo); } [Theory] @@ -52,9 +52,9 @@ public void TryParseGitHubUrl_WithInvalidUrls_ShouldReturnFalse(string? url) var result = _loader.TryParseGitHubUrl(url!, out var owner, out var repo); // Assert - result.Should().BeFalse(); - owner.Should().BeEmpty(); - repo.Should().BeEmpty(); + result.ShouldBeFalse(); + owner.ShouldBeEmpty(); + repo.ShouldBeEmpty(); } [Fact] @@ -62,7 +62,7 @@ public void Constructor_WithDefaultOptions_ShouldNotThrow() { // Act & Assert var action = () => new GitHubRepositoryLoader(); - action.Should().NotThrow(); + action.ShouldNotThrow(); } [Fact] @@ -70,7 +70,7 @@ public void Constructor_WithAccessToken_ShouldNotThrow() { // Act & Assert var action = () => new GitHubRepositoryLoader("test-token"); - action.Should().NotThrow(); + action.ShouldNotThrow(); } [Fact] @@ -84,7 +84,7 @@ public void Constructor_WithOptions_ShouldNotThrow() // Act & Assert var action = () => new GitHubRepositoryLoader(options); - action.Should().NotThrow(); + action.ShouldNotThrow(); } [Fact] @@ -94,8 +94,8 @@ public async Task LoadRepositoryAsync_WithNullVfs_ShouldThrowArgumentNullExcepti var action = () => _loader.LoadRepositoryAsync(null!, "owner", "repo"); // Assert - await action.Should().ThrowAsync() - .WithParameterName("vfs"); + var ex = await Should.ThrowAsync(action); + ex.ParamName.ShouldBe("vfs"); } [Theory] @@ -111,8 +111,8 @@ public async Task LoadRepositoryAsync_WithInvalidOwner_ShouldThrowArgumentExcept var action = () => _loader.LoadRepositoryAsync(vfs, owner!, "repo"); // Assert - await action.Should().ThrowAsync() - .WithParameterName("owner"); + var ex = await Should.ThrowAsync(action); + ex.ParamName.ShouldBe("owner"); } [Theory] @@ -128,8 +128,8 @@ public async Task LoadRepositoryAsync_WithInvalidRepository_ShouldThrowArgumentE var action = () => _loader.LoadRepositoryAsync(vfs, "owner", repository!); // Assert - await action.Should().ThrowAsync() - .WithParameterName("repository"); + var ex = await Should.ThrowAsync(action); + ex.ParamName.ShouldBe("repository"); } [Fact] @@ -142,8 +142,8 @@ public async Task LoadRepositoryFromUrlAsync_WithInvalidUrl_ShouldThrowArgumentE var action = () => _loader.LoadRepositoryFromUrlAsync(vfs, "not-a-valid-url"); // Assert - await action.Should().ThrowAsync() - .WithParameterName("repositoryUrl"); + var ex = await Should.ThrowAsync(action); + ex.ParamName.ShouldBe("repositoryUrl"); } [Fact] @@ -159,7 +159,7 @@ public async Task TryLoadRepositoryAsync_WithNonExistentRepo_ShouldReturnFalse() "non-existent-repo-67890"); // Assert - success.Should().BeFalse(); - result.Should().BeNull(); + success.ShouldBeFalse(); + result.ShouldBeNull(); } } diff --git a/tests/Atypical.VirtualFileSystem.GitHub.Tests/GlobalUsings.cs b/tests/Atypical.VirtualFileSystem.GitHub.Tests/GlobalUsings.cs index b21defa..97d5f6b 100644 --- a/tests/Atypical.VirtualFileSystem.GitHub.Tests/GlobalUsings.cs +++ b/tests/Atypical.VirtualFileSystem.GitHub.Tests/GlobalUsings.cs @@ -5,7 +5,7 @@ // LICENSE file in the root directory of this source tree. global using Xunit; -global using FluentAssertions; +global using Shouldly; global using NSubstitute; global using Atypical.VirtualFileSystem.Core; global using Atypical.VirtualFileSystem.Core.Contracts; diff --git a/tests/Atypical.VirtualFileSystem.GitHub.Tests/VFSGitHubExtensionsTests.cs b/tests/Atypical.VirtualFileSystem.GitHub.Tests/VFSGitHubExtensionsTests.cs index b834567..98d3b97 100644 --- a/tests/Atypical.VirtualFileSystem.GitHub.Tests/VFSGitHubExtensionsTests.cs +++ b/tests/Atypical.VirtualFileSystem.GitHub.Tests/VFSGitHubExtensionsTests.cs @@ -18,9 +18,9 @@ public void TryParseGitHubUrl_WithValidUrls_ShouldParse(string url, string expec var result = VFSGitHubExtensions.TryParseGitHubUrl(url, out var owner, out var repo); // Assert - result.Should().BeTrue(); - owner.Should().Be(expectedOwner); - repo.Should().Be(expectedRepo); + result.ShouldBeTrue(); + owner.ShouldBe(expectedOwner); + repo.ShouldBe(expectedRepo); } [Theory] @@ -33,7 +33,7 @@ public void TryParseGitHubUrl_WithInvalidUrls_ShouldReturnFalse(string url) var result = VFSGitHubExtensions.TryParseGitHubUrl(url, out _, out _); // Assert - result.Should().BeFalse(); + result.ShouldBeFalse(); } [Fact] @@ -48,8 +48,8 @@ public async Task TryLoadGitHubRepositoryAsync_WithNonExistentRepo_ShouldReturnF "non-existent-repo-xyz789"); // Assert - success.Should().BeFalse(); - result.Should().BeNull(); + success.ShouldBeFalse(); + result.ShouldBeNull(); } [Fact] @@ -62,7 +62,7 @@ public async Task TryLoadGitHubRepositoryFromUrlAsync_WithInvalidUrl_ShouldRetur var (success, result) = await vfs.TryLoadGitHubRepositoryFromUrlAsync("not-a-valid-url"); // Assert - success.Should().BeFalse(); - result.Should().BeNull(); + success.ShouldBeFalse(); + result.ShouldBeNull(); } } diff --git a/tests/Atypical.VirtualFileSystem.UnitTests/Atypical.VirtualFileSystem.UnitTests.csproj b/tests/Atypical.VirtualFileSystem.UnitTests/Atypical.VirtualFileSystem.UnitTests.csproj index 8e09c7d..04395fd 100644 --- a/tests/Atypical.VirtualFileSystem.UnitTests/Atypical.VirtualFileSystem.UnitTests.csproj +++ b/tests/Atypical.VirtualFileSystem.UnitTests/Atypical.VirtualFileSystem.UnitTests.csproj @@ -6,7 +6,7 @@ - + diff --git a/tests/Atypical.VirtualFileSystem.UnitTests/Exceptions/VirtualFileSystemExceptionTests.cs b/tests/Atypical.VirtualFileSystem.UnitTests/Exceptions/VirtualFileSystemExceptionTests.cs index 9344547..0043028 100644 --- a/tests/Atypical.VirtualFileSystem.UnitTests/Exceptions/VirtualFileSystemExceptionTests.cs +++ b/tests/Atypical.VirtualFileSystem.UnitTests/Exceptions/VirtualFileSystemExceptionTests.cs @@ -14,7 +14,7 @@ public void Constructor_Creates_VFSException_With_Message() var exception = new VirtualFileSystemException(message); // Assert - exception.Message.Should().Be(message); + exception.Message.ShouldBe(message); } [Fact] @@ -28,8 +28,8 @@ public void Constructor_Creates_VFSException_With_Message_And_InnerException() var exception = new VirtualFileSystemException(message, innerException); // Assert - exception.Message.Should().Be(message); - exception.InnerException.Should().Be(innerException); + exception.Message.ShouldBe(message); + exception.InnerException.ShouldBe(innerException); } [Fact] @@ -42,7 +42,7 @@ public void Constructor_Creates_VFSException_With_InnerException() var exception = new VirtualFileSystemException(null!, innerException); // Assert - exception.InnerException.Should().Be(innerException); + exception.InnerException.ShouldBe(innerException); } [Fact] @@ -52,8 +52,8 @@ public void Constructor_Creates_VFSException_Without_Arguments() var exception = new VirtualFileSystemException(); // Assert - exception.Message.Should().NotBeNull(); - exception.InnerException.Should().BeNull(); + exception.Message.ShouldNotBeNull(); + exception.InnerException.ShouldBeNull(); } } } \ No newline at end of file diff --git a/tests/Atypical.VirtualFileSystem.UnitTests/Extensions/VFSBinaryExtensionsTests.cs b/tests/Atypical.VirtualFileSystem.UnitTests/Extensions/VFSBinaryExtensionsTests.cs index a4a7d64..7be360d 100644 --- a/tests/Atypical.VirtualFileSystem.UnitTests/Extensions/VFSBinaryExtensionsTests.cs +++ b/tests/Atypical.VirtualFileSystem.UnitTests/Extensions/VFSBinaryExtensionsTests.cs @@ -23,11 +23,11 @@ public void CreateBinaryFile_ShouldCreateFileWithBinaryContent() var result = vfs.CreateBinaryFile(filePath, binaryContent); // Assert - result.Should().BeSameAs(vfs); - vfs.FileExists(filePath).Should().BeTrue(); + result.ShouldBeSameAs(vfs); + vfs.FileExists(filePath).ShouldBeTrue(); var file = vfs.GetFile(filePath); - file.Content.Should().StartWith("[BINARY:"); - file.Content.Should().EndWith("]"); + file.Content.ShouldStartWith("[BINARY:"); + file.Content.ShouldEndWith("]"); } [Fact] @@ -42,8 +42,8 @@ public void CreateBinaryFile_WithEmptyContent_ShouldCreateFile() var result = vfs.CreateBinaryFile(filePath, binaryContent); // Assert - result.Should().BeSameAs(vfs); - vfs.FileExists(filePath).Should().BeTrue(); + result.ShouldBeSameAs(vfs); + vfs.FileExists(filePath).ShouldBeTrue(); } [Fact] @@ -58,10 +58,10 @@ public void CreateBinaryFileWithDirectories_ShouldCreateDirectoriesAndFile() var result = vfs.CreateBinaryFileWithDirectories(filePath, binaryContent); // Assert - result.Should().BeSameAs(vfs); - vfs.DirectoryExists("/docs").Should().BeTrue(); - vfs.DirectoryExists("/docs/binary").Should().BeTrue(); - vfs.FileExists(filePath).Should().BeTrue(); + result.ShouldBeSameAs(vfs); + vfs.DirectoryExists("/docs").ShouldBeTrue(); + vfs.DirectoryExists("/docs/binary").ShouldBeTrue(); + vfs.FileExists(filePath).ShouldBeTrue(); } [Fact] @@ -76,8 +76,8 @@ public void CreateBinaryFileWithDirectories_WithRootFile_ShouldCreateFile() var result = vfs.CreateBinaryFileWithDirectories(filePath, binaryContent); // Assert - result.Should().BeSameAs(vfs); - vfs.FileExists(filePath).Should().BeTrue(); + result.ShouldBeSameAs(vfs); + vfs.FileExists(filePath).ShouldBeTrue(); } [Fact] @@ -93,8 +93,8 @@ public void CreateBinaryFileFromBase64_WithValidBase64_ShouldCreateFile() var result = vfs.CreateBinaryFileFromBase64(filePath, base64Content); // Assert - result.Should().BeSameAs(vfs); - vfs.FileExists(filePath).Should().BeTrue(); + result.ShouldBeSameAs(vfs); + vfs.FileExists(filePath).ShouldBeTrue(); } [Fact] @@ -107,8 +107,8 @@ public void CreateBinaryFileFromBase64_WithInvalidBase64_ShouldThrowFormatExcept // Act & Assert var action = () => vfs.CreateBinaryFileFromBase64(filePath, invalidBase64); - action.Should().Throw() - .WithMessage($"Invalid base64 string provided for file '{filePath}'."); + var ex = Should.Throw(action); + ex.Message.ShouldBe($"Invalid base64 string provided for file '{filePath}'."); } [Fact] @@ -123,8 +123,8 @@ public void TryCreateBinaryFile_WithValidInput_ShouldReturnTrueAndCreateFile() var result = vfs.TryCreateBinaryFile(filePath, binaryContent); // Assert - result.Should().BeTrue(); - vfs.FileExists(filePath).Should().BeTrue(); + result.ShouldBeTrue(); + vfs.FileExists(filePath).ShouldBeTrue(); } [Fact] @@ -140,7 +140,7 @@ public void TryCreateBinaryFile_WithDuplicatePath_ShouldReturnFalse() var result = vfs.TryCreateBinaryFile(filePath, binaryContent); // Assert - result.Should().BeFalse(); + result.ShouldBeFalse(); } [Fact] @@ -156,9 +156,9 @@ public void TryReadBinaryFile_WithBinaryMarker_ShouldReturnTrueAndContent() var result = vfs.TryReadBinaryFile(filePath, out var readContent); // Assert - result.Should().BeTrue(); - readContent.Should().NotBeNull(); - readContent.Should().BeEquivalentTo(originalContent); + result.ShouldBeTrue(); + readContent.ShouldNotBeNull(); + readContent.ShouldBe(originalContent); } [Fact] @@ -172,8 +172,8 @@ public void TryReadBinaryFile_WithNonExistentFile_ShouldReturnFalse() var result = vfs.TryReadBinaryFile(filePath, out var content); // Assert - result.Should().BeFalse(); - content.Should().BeNull(); + result.ShouldBeFalse(); + content.ShouldBeNull(); } [Fact] @@ -188,8 +188,8 @@ public void TryReadBinaryFile_WithTextFile_ShouldReturnFalse() var result = vfs.TryReadBinaryFile(filePath, out var content); // Assert - result.Should().BeFalse(); - content.Should().BeNull(); + result.ShouldBeFalse(); + content.ShouldBeNull(); } [Fact] @@ -206,9 +206,9 @@ public void TryWriteBinaryFile_WithExistingFile_ShouldReturnTrueAndUpdateContent var result = vfs.TryWriteBinaryFile(filePath, newContent); // Assert - result.Should().BeTrue(); + result.ShouldBeTrue(); vfs.TryReadBinaryFile(filePath, out var readContent); - readContent.Should().BeEquivalentTo(newContent); + readContent.ShouldBe(newContent); } [Fact] @@ -223,7 +223,7 @@ public void TryWriteBinaryFile_WithNonExistentFile_ShouldReturnFalse() var result = vfs.TryWriteBinaryFile(filePath, content); // Assert - result.Should().BeFalse(); + result.ShouldBeFalse(); } [Fact] @@ -239,7 +239,7 @@ public void IsBinaryFile_WithBinaryFile_ShouldReturnTrue() var result = vfs.IsBinaryFile(filePath); // Assert - result.Should().BeTrue(); + result.ShouldBeTrue(); } [Fact] @@ -254,7 +254,7 @@ public void IsBinaryFile_WithTextFile_ShouldReturnFalse() var result = vfs.IsBinaryFile(filePath); // Assert - result.Should().BeFalse(); + result.ShouldBeFalse(); } [Fact] @@ -268,7 +268,7 @@ public void IsBinaryFile_WithNonExistentFile_ShouldReturnFalse() var result = vfs.IsBinaryFile(filePath); // Assert - result.Should().BeFalse(); + result.ShouldBeFalse(); } [Fact] @@ -284,7 +284,7 @@ public void GetFileSize_WithBinaryFile_ShouldReturnCorrectSize() var size = vfs.GetFileSize(filePath); // Assert - size.Should().BeGreaterThan(0); // Size will be the base64 representation + size.ShouldBeGreaterThan(0); // Size will be the base64 representation } [Fact] @@ -300,7 +300,7 @@ public void GetFileSize_WithTextFile_ShouldReturnCorrectSize() var size = vfs.GetFileSize(filePath); // Assert - size.Should().Be(11); // "Hello World" is 11 bytes in UTF-8 + size.ShouldBe(11); // "Hello World" is 11 bytes in UTF-8 } [Fact] @@ -314,7 +314,7 @@ public void GetFileSize_WithNonExistentFile_ShouldReturnMinusOne() var size = vfs.GetFileSize(filePath); // Assert - size.Should().Be(-1); + size.ShouldBe(-1); } [Fact] @@ -330,8 +330,8 @@ public void ConvertToBinary_WithTextFile_ShouldReturnTrue() var result = vfs.ConvertToBinary(filePath); // Assert - result.Should().BeTrue(); - vfs.IsBinaryFile(filePath).Should().BeTrue(); + result.ShouldBeTrue(); + vfs.IsBinaryFile(filePath).ShouldBeTrue(); } [Fact] @@ -347,8 +347,8 @@ public void ConvertToBinary_WithCustomEncoding_ShouldReturnTrue() var result = vfs.ConvertToBinary(filePath, System.Text.Encoding.ASCII); // Assert - result.Should().BeTrue(); - vfs.IsBinaryFile(filePath).Should().BeTrue(); + result.ShouldBeTrue(); + vfs.IsBinaryFile(filePath).ShouldBeTrue(); } [Fact] @@ -362,7 +362,7 @@ public void ConvertToBinary_WithNonExistentFile_ShouldReturnFalse() var result = vfs.ConvertToBinary(filePath); // Assert - result.Should().BeFalse(); + result.ShouldBeFalse(); } [Fact] @@ -379,9 +379,9 @@ public void ConvertToText_WithBinaryFile_ShouldReturnTrue() var result = vfs.ConvertToText(filePath); // Assert - result.Should().BeTrue(); + result.ShouldBeTrue(); var file = vfs.GetFile(filePath); - file.Content.Should().Contain(originalText); + file.Content.ShouldContain(originalText); } [Fact] @@ -399,7 +399,7 @@ public void ConvertToText_WithCustomEncoding_ShouldReturnTrue() var result = vfs.ConvertToText(filePath, encoding); // Assert - result.Should().BeTrue(); + result.ShouldBeTrue(); } [Fact] @@ -414,7 +414,7 @@ public void ConvertToText_WithNonBinaryFile_ShouldReturnFalse() var result = vfs.ConvertToText(filePath); // Assert - result.Should().BeFalse(); + result.ShouldBeFalse(); } [Fact] @@ -430,13 +430,13 @@ public void GetFileInfo_WithExistingFile_ShouldReturnFileInfo() var fileInfo = vfs.GetFileInfo(filePath); // Assert - fileInfo.Should().NotBeNull(); - fileInfo!.Path.Should().Be(filePath); - fileInfo.IsBinary.Should().BeFalse(); - fileInfo.SizeInBytes.Should().Be(11); - fileInfo.FileType.Should().Be("Text"); - fileInfo.CreationTime.Should().BeCloseTo(DateTime.Now, TimeSpan.FromHours(3)); - fileInfo.LastWriteTime.Should().BeCloseTo(DateTime.Now, TimeSpan.FromHours(3)); + fileInfo.ShouldNotBeNull(); + fileInfo!.Path.ShouldBe(filePath); + fileInfo.IsBinary.ShouldBeFalse(); + fileInfo.SizeInBytes.ShouldBe(11); + fileInfo.FileType.ShouldBe("Text"); + (DateTime.Now - fileInfo.CreationTime).ShouldBeLessThan(TimeSpan.FromHours(3)); + (DateTime.Now - fileInfo.LastWriteTime).ShouldBeLessThan(TimeSpan.FromHours(3)); } [Fact] @@ -452,10 +452,10 @@ public void GetFileInfo_WithBinaryFile_ShouldReturnBinaryFileInfo() var fileInfo = vfs.GetFileInfo(filePath); // Assert - fileInfo.Should().NotBeNull(); - fileInfo!.Path.Should().Be(filePath); - fileInfo.IsBinary.Should().BeTrue(); - fileInfo.FileType.Should().Be("Binary"); + fileInfo.ShouldNotBeNull(); + fileInfo!.Path.ShouldBe(filePath); + fileInfo.IsBinary.ShouldBeTrue(); + fileInfo.FileType.ShouldBe("Binary"); } [Fact] @@ -469,7 +469,7 @@ public void GetFileInfo_WithNonExistentFile_ShouldReturnNull() var fileInfo = vfs.GetFileInfo(filePath); // Assert - fileInfo.Should().BeNull(); + fileInfo.ShouldBeNull(); } [Theory] @@ -492,7 +492,7 @@ public void FileInfo_SizeString_ShouldFormatCorrectly(long sizeInBytes, string e var sizeString = fileInfo.SizeString; // Assert - sizeString.Should().Be(expected); + sizeString.ShouldBe(expected); } [Fact] @@ -505,7 +505,7 @@ public void FileInfo_FileType_ShouldReturnCorrectType() "/test.bin", true, 100, DateTime.Now, DateTime.Now); // Act & Assert - textFileInfo.FileType.Should().Be("Text"); - binaryFileInfo.FileType.Should().Be("Binary"); + textFileInfo.FileType.ShouldBe("Text"); + binaryFileInfo.FileType.ShouldBe("Binary"); } } \ No newline at end of file diff --git a/tests/Atypical.VirtualFileSystem.UnitTests/Extensions/VFSBulkExtensionsTests.cs b/tests/Atypical.VirtualFileSystem.UnitTests/Extensions/VFSBulkExtensionsTests.cs index f4d5f78..e13363c 100644 --- a/tests/Atypical.VirtualFileSystem.UnitTests/Extensions/VFSBulkExtensionsTests.cs +++ b/tests/Atypical.VirtualFileSystem.UnitTests/Extensions/VFSBulkExtensionsTests.cs @@ -29,15 +29,15 @@ public void CreateFiles_WithTupleCollection_ShouldCreateAllFiles() var result = vfs.CreateFiles(files); // Assert - result.Should().BeSameAs(vfs); - vfs.FileExists("/docs/file1.txt").Should().BeTrue(); - vfs.FileExists("/docs/file2.txt").Should().BeTrue(); - vfs.FileExists("/src/main.cs").Should().BeTrue(); - vfs.DirectoryExists("/docs").Should().BeTrue(); - vfs.DirectoryExists("/src").Should().BeTrue(); - vfs.GetFile("/docs/file1.txt").Content.Should().Be("Content 1"); - vfs.GetFile("/docs/file2.txt").Content.Should().Be("Content 2"); - vfs.GetFile("/src/main.cs").Content.Should().Be("Content 3"); + result.ShouldBeSameAs(vfs); + vfs.FileExists("/docs/file1.txt").ShouldBeTrue(); + vfs.FileExists("/docs/file2.txt").ShouldBeTrue(); + vfs.FileExists("/src/main.cs").ShouldBeTrue(); + vfs.DirectoryExists("/docs").ShouldBeTrue(); + vfs.DirectoryExists("/src").ShouldBeTrue(); + vfs.GetFile("/docs/file1.txt").Content.ShouldBe("Content 1"); + vfs.GetFile("/docs/file2.txt").Content.ShouldBe("Content 2"); + vfs.GetFile("/src/main.cs").Content.ShouldBe("Content 3"); } [Fact] @@ -56,13 +56,13 @@ public void CreateFiles_WithDictionary_ShouldCreateAllFiles() var result = vfs.CreateFiles(files); // Assert - result.Should().BeSameAs(vfs); - vfs.FileExists("/file1.txt").Should().BeTrue(); - vfs.FileExists("/file2.txt").Should().BeTrue(); - vfs.FileExists("/file3.txt").Should().BeTrue(); - vfs.GetFile("/file1.txt").Content.Should().Be("Content 1"); - vfs.GetFile("/file2.txt").Content.Should().Be("Content 2"); - vfs.GetFile("/file3.txt").Content.Should().Be("Content 3"); + result.ShouldBeSameAs(vfs); + vfs.FileExists("/file1.txt").ShouldBeTrue(); + vfs.FileExists("/file2.txt").ShouldBeTrue(); + vfs.FileExists("/file3.txt").ShouldBeTrue(); + vfs.GetFile("/file1.txt").Content.ShouldBe("Content 1"); + vfs.GetFile("/file2.txt").Content.ShouldBe("Content 2"); + vfs.GetFile("/file3.txt").Content.ShouldBe("Content 3"); } [Fact] @@ -77,9 +77,9 @@ public void CreateFiles_WithCreateDirectoriesFalse_ShouldStillCreateFiles() // Assert // Note: Base VFS CreateFile automatically creates parent directories - result.Should().BeSameAs(vfs); - vfs.FileExists("/nonexistent/file.txt").Should().BeTrue(); - vfs.DirectoryExists("/nonexistent").Should().BeTrue(); + result.ShouldBeSameAs(vfs); + vfs.FileExists("/nonexistent/file.txt").ShouldBeTrue(); + vfs.DirectoryExists("/nonexistent").ShouldBeTrue(); } [Fact] @@ -93,7 +93,7 @@ public void CreateFiles_WithEmptyCollection_ShouldReturnVfs() var result = vfs.CreateFiles(files); // Assert - result.Should().BeSameAs(vfs); + result.ShouldBeSameAs(vfs); } [Fact] @@ -111,11 +111,11 @@ public void TryCreateFiles_WithValidFiles_ShouldReturnAllPaths() var successfulPaths = vfs.TryCreateFiles(files).ToList(); // Assert - successfulPaths.Should().HaveCount(2); - successfulPaths.Should().Contain("/docs/file1.txt"); - successfulPaths.Should().Contain("/docs/file2.txt"); - vfs.FileExists("/docs/file1.txt").Should().BeTrue(); - vfs.FileExists("/docs/file2.txt").Should().BeTrue(); + successfulPaths.Count.ShouldBe(2); + successfulPaths.ShouldContain("/docs/file1.txt"); + successfulPaths.ShouldContain("/docs/file2.txt"); + vfs.FileExists("/docs/file1.txt").ShouldBeTrue(); + vfs.FileExists("/docs/file2.txt").ShouldBeTrue(); } [Fact] @@ -135,10 +135,10 @@ public void TryCreateFiles_WithSomeInvalidPaths_ShouldReturnOnlySuccessfulPaths( var successfulPaths = vfs.TryCreateFiles(files).ToList(); // Assert - successfulPaths.Should().HaveCount(2); - successfulPaths.Should().Contain("/valid.txt"); - successfulPaths.Should().Contain("/another.txt"); - successfulPaths.Should().NotContain("/existing.txt"); + successfulPaths.Count.ShouldBe(2); + successfulPaths.ShouldContain("/valid.txt"); + successfulPaths.ShouldContain("/another.txt"); + successfulPaths.ShouldNotContain("/existing.txt"); } #endregion @@ -156,12 +156,12 @@ public void CreateDirectories_WithValidPaths_ShouldCreateAllDirectories() var result = vfs.CreateDirectories(directories); // Assert - result.Should().BeSameAs(vfs); - vfs.DirectoryExists("/docs").Should().BeTrue(); - vfs.DirectoryExists("/src/main").Should().BeTrue(); - vfs.DirectoryExists("/tests/unit").Should().BeTrue(); - vfs.DirectoryExists("/src").Should().BeTrue(); - vfs.DirectoryExists("/tests").Should().BeTrue(); + result.ShouldBeSameAs(vfs); + vfs.DirectoryExists("/docs").ShouldBeTrue(); + vfs.DirectoryExists("/src/main").ShouldBeTrue(); + vfs.DirectoryExists("/tests/unit").ShouldBeTrue(); + vfs.DirectoryExists("/src").ShouldBeTrue(); + vfs.DirectoryExists("/tests").ShouldBeTrue(); } [Fact] @@ -176,9 +176,9 @@ public void CreateDirectories_WithCreateRecursivelyFalse_ShouldStillCreateDirect // Assert // Note: Base VFS CreateDirectory automatically creates parent directories - result.Should().BeSameAs(vfs); - vfs.DirectoryExists("/parent").Should().BeTrue(); - vfs.DirectoryExists("/parent/child").Should().BeTrue(); + result.ShouldBeSameAs(vfs); + vfs.DirectoryExists("/parent").ShouldBeTrue(); + vfs.DirectoryExists("/parent/child").ShouldBeTrue(); } [Fact] @@ -192,10 +192,10 @@ public void TryCreateDirectories_WithValidPaths_ShouldReturnAllPaths() var successfulPaths = vfs.TryCreateDirectories(directories).ToList(); // Assert - successfulPaths.Should().HaveCount(3); - successfulPaths.Should().Contain("/docs"); - successfulPaths.Should().Contain("/src"); - successfulPaths.Should().Contain("/tests"); + successfulPaths.Count.ShouldBe(3); + successfulPaths.ShouldContain("/docs"); + successfulPaths.ShouldContain("/src"); + successfulPaths.ShouldContain("/tests"); } [Fact] @@ -211,10 +211,10 @@ public void TryCreateDirectories_WithSomeExistingPaths_ShouldReturnAllSuccessful // Assert // VFS TryCreateDirectory succeeds for existing directories (idempotent operation) - successfulPaths.Should().HaveCount(3); - successfulPaths.Should().Contain("/valid"); - successfulPaths.Should().Contain("/existing"); - successfulPaths.Should().Contain("/another"); + successfulPaths.Count.ShouldBe(3); + successfulPaths.ShouldContain("/valid"); + successfulPaths.ShouldContain("/existing"); + successfulPaths.ShouldContain("/another"); } #endregion @@ -235,10 +235,10 @@ public void DeleteFiles_WithExistingFiles_ShouldDeleteAllFiles() var result = vfs.DeleteFiles(filesToDelete); // Assert - result.Should().BeSameAs(vfs); - vfs.FileExists("/file1.txt").Should().BeFalse(); - vfs.FileExists("/file2.txt").Should().BeFalse(); - vfs.FileExists("/file3.txt").Should().BeTrue(); // Should remain + result.ShouldBeSameAs(vfs); + vfs.FileExists("/file1.txt").ShouldBeFalse(); + vfs.FileExists("/file2.txt").ShouldBeFalse(); + vfs.FileExists("/file3.txt").ShouldBeTrue(); // Should remain } [Fact] @@ -252,7 +252,7 @@ public void DeleteFiles_WithNonExistentFiles_ShouldNotThrow() var result = vfs.DeleteFiles(filesToDelete); // Assert - result.Should().BeSameAs(vfs); + result.ShouldBeSameAs(vfs); } [Fact] @@ -268,10 +268,10 @@ public void TryDeleteFiles_WithExistingFiles_ShouldReturnSuccessfulPaths() var successfulPaths = vfs.TryDeleteFiles(filesToDelete).ToList(); // Assert - successfulPaths.Should().HaveCount(2); - successfulPaths.Should().Contain("/file1.txt"); - successfulPaths.Should().Contain("/file2.txt"); - successfulPaths.Should().NotContain("/nonexistent.txt"); + successfulPaths.Count.ShouldBe(2); + successfulPaths.ShouldContain("/file1.txt"); + successfulPaths.ShouldContain("/file2.txt"); + successfulPaths.ShouldNotContain("/nonexistent.txt"); } #endregion @@ -292,10 +292,10 @@ public void DeleteDirectories_WithExistingDirectories_ShouldDeleteAllDirectories var result = vfs.DeleteDirectories(directoriesToDelete); // Assert - result.Should().BeSameAs(vfs); - vfs.DirectoryExists("/dir1").Should().BeFalse(); - vfs.DirectoryExists("/dir2").Should().BeFalse(); - vfs.DirectoryExists("/dir3").Should().BeTrue(); // Should remain + result.ShouldBeSameAs(vfs); + vfs.DirectoryExists("/dir1").ShouldBeFalse(); + vfs.DirectoryExists("/dir2").ShouldBeFalse(); + vfs.DirectoryExists("/dir3").ShouldBeTrue(); // Should remain } [Fact] @@ -309,7 +309,7 @@ public void DeleteDirectories_WithNonExistentDirectories_ShouldNotThrow() var result = vfs.DeleteDirectories(directoriesToDelete); // Assert - result.Should().BeSameAs(vfs); + result.ShouldBeSameAs(vfs); } [Fact] @@ -325,10 +325,10 @@ public void TryDeleteDirectories_WithExistingDirectories_ShouldReturnSuccessfulP var successfulPaths = vfs.TryDeleteDirectories(directoriesToDelete).ToList(); // Assert - successfulPaths.Should().HaveCount(2); - successfulPaths.Should().Contain("/dir1"); - successfulPaths.Should().Contain("/dir2"); - successfulPaths.Should().NotContain("/nonexistent"); + successfulPaths.Count.ShouldBe(2); + successfulPaths.ShouldContain("/dir1"); + successfulPaths.ShouldContain("/dir2"); + successfulPaths.ShouldNotContain("/nonexistent"); } #endregion @@ -352,14 +352,14 @@ public void MoveFiles_WithValidFiles_ShouldMoveAllFiles() var result = vfs.MoveFiles(moves); // Assert - result.Should().BeSameAs(vfs); - vfs.FileExists("/source1.txt").Should().BeFalse(); - vfs.FileExists("/source2.txt").Should().BeFalse(); - vfs.FileExists("/dest/file1.txt").Should().BeTrue(); - vfs.FileExists("/dest/file2.txt").Should().BeTrue(); - vfs.DirectoryExists("/dest").Should().BeTrue(); - vfs.GetFile("/dest/file1.txt").Content.Should().Be("Content 1"); - vfs.GetFile("/dest/file2.txt").Content.Should().Be("Content 2"); + result.ShouldBeSameAs(vfs); + vfs.FileExists("/source1.txt").ShouldBeFalse(); + vfs.FileExists("/source2.txt").ShouldBeFalse(); + vfs.FileExists("/dest/file1.txt").ShouldBeTrue(); + vfs.FileExists("/dest/file2.txt").ShouldBeTrue(); + vfs.DirectoryExists("/dest").ShouldBeTrue(); + vfs.GetFile("/dest/file1.txt").Content.ShouldBe("Content 1"); + vfs.GetFile("/dest/file2.txt").Content.ShouldBe("Content 2"); } [Fact] @@ -379,10 +379,10 @@ public void MoveFiles_WithCreateDirectoriesFalse_ShouldFailSilentlyForMissingDir // Assert // Note: VFS MoveFile does NOT automatically create parent directories - result.Should().BeSameAs(vfs); - vfs.FileExists("/source.txt").Should().BeFalse(); - vfs.FileExists("/existing/dest.txt").Should().BeTrue(); - vfs.DirectoryExists("/existing").Should().BeTrue(); + result.ShouldBeSameAs(vfs); + vfs.FileExists("/source.txt").ShouldBeFalse(); + vfs.FileExists("/existing/dest.txt").ShouldBeTrue(); + vfs.DirectoryExists("/existing").ShouldBeTrue(); } [Fact] @@ -401,10 +401,10 @@ public void MoveFiles_WithNonExistentSource_ShouldSkipAndContinue() var result = vfs.MoveFiles(moves); // Assert - result.Should().BeSameAs(vfs); - vfs.FileExists("/dest1.txt").Should().BeFalse(); - vfs.FileExists("/dest2.txt").Should().BeTrue(); - vfs.FileExists("/existing.txt").Should().BeFalse(); + result.ShouldBeSameAs(vfs); + vfs.FileExists("/dest1.txt").ShouldBeFalse(); + vfs.FileExists("/dest2.txt").ShouldBeTrue(); + vfs.FileExists("/existing.txt").ShouldBeFalse(); } [Fact] @@ -425,10 +425,10 @@ public void TryMoveFiles_WithValidFiles_ShouldReturnSuccessfulPaths() var successfulPaths = vfs.TryMoveFiles(moves).ToList(); // Assert - successfulPaths.Should().HaveCount(2); - successfulPaths.Should().Contain("/source1.txt"); - successfulPaths.Should().Contain("/source2.txt"); - successfulPaths.Should().NotContain("/nonexistent.txt"); + successfulPaths.Count.ShouldBe(2); + successfulPaths.ShouldContain("/source1.txt"); + successfulPaths.ShouldContain("/source2.txt"); + successfulPaths.ShouldNotContain("/nonexistent.txt"); } #endregion @@ -452,14 +452,14 @@ public void CopyFiles_WithValidFiles_ShouldCopyAllFiles() var result = vfs.CopyFiles(copies); // Assert - result.Should().BeSameAs(vfs); - vfs.FileExists("/source1.txt").Should().BeTrue(); // Source should remain - vfs.FileExists("/source2.txt").Should().BeTrue(); // Source should remain - vfs.FileExists("/dest/copy1.txt").Should().BeTrue(); - vfs.FileExists("/dest/copy2.txt").Should().BeTrue(); - vfs.DirectoryExists("/dest").Should().BeTrue(); - vfs.GetFile("/dest/copy1.txt").Content.Should().Be("Content 1"); - vfs.GetFile("/dest/copy2.txt").Content.Should().Be("Content 2"); + result.ShouldBeSameAs(vfs); + vfs.FileExists("/source1.txt").ShouldBeTrue(); // Source should remain + vfs.FileExists("/source2.txt").ShouldBeTrue(); // Source should remain + vfs.FileExists("/dest/copy1.txt").ShouldBeTrue(); + vfs.FileExists("/dest/copy2.txt").ShouldBeTrue(); + vfs.DirectoryExists("/dest").ShouldBeTrue(); + vfs.GetFile("/dest/copy1.txt").Content.ShouldBe("Content 1"); + vfs.GetFile("/dest/copy2.txt").Content.ShouldBe("Content 2"); } [Fact] @@ -480,10 +480,10 @@ public void CopyFiles_WithCreateDirectoriesFalse_ShouldStillCopyFiles() // Assert // Note: Base VFS operations automatically create parent directories - result.Should().BeSameAs(vfs); - vfs.FileExists("/existing/copy.txt").Should().BeTrue(); - vfs.FileExists("/nonexistent/copy.txt").Should().BeTrue(); - vfs.DirectoryExists("/nonexistent").Should().BeTrue(); + result.ShouldBeSameAs(vfs); + vfs.FileExists("/existing/copy.txt").ShouldBeTrue(); + vfs.FileExists("/nonexistent/copy.txt").ShouldBeTrue(); + vfs.DirectoryExists("/nonexistent").ShouldBeTrue(); } [Fact] @@ -504,10 +504,10 @@ public void TryCopyFiles_WithValidFiles_ShouldReturnSuccessfulPaths() var successfulPaths = vfs.TryCopyFiles(copies).ToList(); // Assert - successfulPaths.Should().HaveCount(2); - successfulPaths.Should().Contain("/source1.txt"); - successfulPaths.Should().Contain("/source2.txt"); - successfulPaths.Should().NotContain("/nonexistent.txt"); + successfulPaths.Count.ShouldBe(2); + successfulPaths.ShouldContain("/source1.txt"); + successfulPaths.ShouldContain("/source2.txt"); + successfulPaths.ShouldNotContain("/nonexistent.txt"); } #endregion @@ -531,9 +531,9 @@ public void UpdateFiles_WithExistingFiles_ShouldUpdateAllContents() var result = vfs.UpdateFiles(updates); // Assert - result.Should().BeSameAs(vfs); - vfs.GetFile("/file1.txt").Content.Should().Be("Updated 1"); - vfs.GetFile("/file2.txt").Content.Should().Be("Updated 2"); + result.ShouldBeSameAs(vfs); + vfs.GetFile("/file1.txt").Content.ShouldBe("Updated 1"); + vfs.GetFile("/file2.txt").Content.ShouldBe("Updated 2"); } [Fact] @@ -552,9 +552,9 @@ public void UpdateFiles_WithNonExistentFiles_ShouldSkipMissingFiles() var result = vfs.UpdateFiles(updates); // Assert - result.Should().BeSameAs(vfs); - vfs.GetFile("/existing.txt").Content.Should().Be("Updated"); - vfs.FileExists("/nonexistent.txt").Should().BeFalse(); + result.ShouldBeSameAs(vfs); + vfs.GetFile("/existing.txt").Content.ShouldBe("Updated"); + vfs.FileExists("/nonexistent.txt").ShouldBeFalse(); } [Fact] @@ -575,12 +575,12 @@ public void TryUpdateFiles_WithExistingFiles_ShouldReturnSuccessfulPaths() var successfulPaths = vfs.TryUpdateFiles(updates).ToList(); // Assert - successfulPaths.Should().HaveCount(2); - successfulPaths.Should().Contain("/file1.txt"); - successfulPaths.Should().Contain("/file2.txt"); - successfulPaths.Should().NotContain("/nonexistent.txt"); - vfs.GetFile("/file1.txt").Content.Should().Be("Updated 1"); - vfs.GetFile("/file2.txt").Content.Should().Be("Updated 2"); + successfulPaths.Count.ShouldBe(2); + successfulPaths.ShouldContain("/file1.txt"); + successfulPaths.ShouldContain("/file2.txt"); + successfulPaths.ShouldNotContain("/nonexistent.txt"); + vfs.GetFile("/file1.txt").Content.ShouldBe("Updated 1"); + vfs.GetFile("/file2.txt").Content.ShouldBe("Updated 2"); } #endregion @@ -594,13 +594,13 @@ public void BulkOperations_WithEmptyCollections_ShouldReturnVfsWithoutError() var vfs = CreateVFS(); // Act & Assert - vfs.CreateFiles(Array.Empty<(string, string)>()).Should().BeSameAs(vfs); - vfs.CreateDirectories(Array.Empty()).Should().BeSameAs(vfs); - vfs.DeleteFiles(Array.Empty()).Should().BeSameAs(vfs); - vfs.DeleteDirectories(Array.Empty()).Should().BeSameAs(vfs); - vfs.MoveFiles(Array.Empty<(string, string)>()).Should().BeSameAs(vfs); - vfs.CopyFiles(Array.Empty<(string, string)>()).Should().BeSameAs(vfs); - vfs.UpdateFiles(Array.Empty<(string, string)>()).Should().BeSameAs(vfs); + vfs.CreateFiles(Array.Empty<(string, string)>()).ShouldBeSameAs(vfs); + vfs.CreateDirectories(Array.Empty()).ShouldBeSameAs(vfs); + vfs.DeleteFiles(Array.Empty()).ShouldBeSameAs(vfs); + vfs.DeleteDirectories(Array.Empty()).ShouldBeSameAs(vfs); + vfs.MoveFiles(Array.Empty<(string, string)>()).ShouldBeSameAs(vfs); + vfs.CopyFiles(Array.Empty<(string, string)>()).ShouldBeSameAs(vfs); + vfs.UpdateFiles(Array.Empty<(string, string)>()).ShouldBeSameAs(vfs); } [Fact] @@ -610,13 +610,13 @@ public void TryBulkOperations_WithEmptyCollections_ShouldReturnEmptyResults() var vfs = CreateVFS(); // Act & Assert - vfs.TryCreateFiles(Array.Empty<(string, string)>()).Should().BeEmpty(); - vfs.TryCreateDirectories(Array.Empty()).Should().BeEmpty(); - vfs.TryDeleteFiles(Array.Empty()).Should().BeEmpty(); - vfs.TryDeleteDirectories(Array.Empty()).Should().BeEmpty(); - vfs.TryMoveFiles(Array.Empty<(string, string)>()).Should().BeEmpty(); - vfs.TryCopyFiles(Array.Empty<(string, string)>()).Should().BeEmpty(); - vfs.TryUpdateFiles(Array.Empty<(string, string)>()).Should().BeEmpty(); + vfs.TryCreateFiles(Array.Empty<(string, string)>()).ShouldBeEmpty(); + vfs.TryCreateDirectories(Array.Empty()).ShouldBeEmpty(); + vfs.TryDeleteFiles(Array.Empty()).ShouldBeEmpty(); + vfs.TryDeleteDirectories(Array.Empty()).ShouldBeEmpty(); + vfs.TryMoveFiles(Array.Empty<(string, string)>()).ShouldBeEmpty(); + vfs.TryCopyFiles(Array.Empty<(string, string)>()).ShouldBeEmpty(); + vfs.TryUpdateFiles(Array.Empty<(string, string)>()).ShouldBeEmpty(); } #endregion diff --git a/tests/Atypical.VirtualFileSystem.UnitTests/Extensions/VFSPathExtensionsTests.cs b/tests/Atypical.VirtualFileSystem.UnitTests/Extensions/VFSPathExtensionsTests.cs index 480e8e2..d1f5e52 100644 --- a/tests/Atypical.VirtualFileSystem.UnitTests/Extensions/VFSPathExtensionsTests.cs +++ b/tests/Atypical.VirtualFileSystem.UnitTests/Extensions/VFSPathExtensionsTests.cs @@ -28,7 +28,7 @@ public void GetExtension_WithVariousFiles_ShouldReturnCorrectExtension(string pa var extension = path.GetExtension(); // Assert - extension.Should().Be(expectedExtension); + extension.ShouldBe(expectedExtension); } #endregion @@ -50,7 +50,7 @@ public void GetFileNameWithoutExtension_WithVariousFiles_ShouldReturnCorrectName var nameWithoutExtension = path.GetFileNameWithoutExtension(); // Assert - nameWithoutExtension.Should().Be(expectedName); + nameWithoutExtension.ShouldBe(expectedName); } #endregion @@ -67,8 +67,8 @@ public void GetParent_WithDefaultLevel_ShouldReturnImmediateParent() var parent = path.GetParent(); // Assert - parent.Should().NotBeNull(); - parent.Value.Should().Contain("docs/folder"); + parent.ShouldNotBeNull(); + parent.Value.ShouldContain("docs/folder"); } [Fact] @@ -79,8 +79,8 @@ public void GetParent_WithNegativeLevel_ShouldThrowArgumentException() // Act & Assert var action = () => path.GetParent(-1); - action.Should().Throw() - .WithMessage("Levels must be non-negative. (Parameter 'levels')"); + var ex = Should.Throw(action); + ex.Message.ShouldBe("Levels must be non-negative. (Parameter 'levels')"); } #endregion @@ -103,7 +103,7 @@ public void HasExtension_WithVariousExtensions_ShouldReturnCorrectResult(string var result = path.HasExtension(extension); // Assert - result.Should().Be(expected); + result.ShouldBe(expected); } [Fact] @@ -117,8 +117,8 @@ public void HasExtension_WithCaseSensitive_ShouldRespectCase() var resultCaseSensitive = path.HasExtension("txt", ignoreCase: false); // Assert - resultIgnoreCase.Should().BeTrue(); - resultCaseSensitive.Should().BeFalse(); + resultIgnoreCase.ShouldBeTrue(); + resultCaseSensitive.ShouldBeFalse(); } #endregion @@ -135,7 +135,7 @@ public void HasAnyExtension_WithMatchingExtensions_ShouldReturnTrue() var result = path.HasAnyExtension("txt", "pdf", "doc"); // Assert - result.Should().BeTrue(); + result.ShouldBeTrue(); } [Fact] @@ -148,7 +148,7 @@ public void HasAnyExtension_WithNonMatchingExtensions_ShouldReturnFalse() var result = path.HasAnyExtension("txt", "doc", "docx"); // Assert - result.Should().BeFalse(); + result.ShouldBeFalse(); } #endregion @@ -165,7 +165,7 @@ public void ChangeExtension_WithNewExtension_ShouldReturnPathWithNewExtension() var result = path.ChangeExtension("pdf"); // Assert - result.Should().Contain("file.pdf"); + result.ShouldContain("file.pdf"); } [Fact] @@ -178,7 +178,7 @@ public void ChangeExtension_WithDotPrefix_ShouldReturnPathWithNewExtension() var result = path.ChangeExtension(".pdf"); // Assert - result.Should().Contain("file.pdf"); + result.ShouldContain("file.pdf"); } #endregion @@ -195,7 +195,7 @@ public void Combine_WithRelativePath_ShouldReturnCombinedPath() var result = dirPath.Combine("file.txt"); // Assert - result.Should().Contain("docs/file.txt"); + result.ShouldContain("docs/file.txt"); } [Fact] @@ -208,7 +208,7 @@ public void Combine_WithSlashPrefix_ShouldReturnCombinedPath() var result = dirPath.Combine("/file.txt"); // Assert - result.Should().Contain("docs/file.txt"); + result.ShouldContain("docs/file.txt"); } #endregion @@ -226,7 +226,7 @@ public void GetRelativePath_WithSameDirectory_ShouldReturnDot() var result = from.GetRelativePath(to); // Assert - result.Should().Be("."); + result.ShouldBe("."); } [Fact] @@ -240,7 +240,7 @@ public void GetRelativePath_WithChildFile_ShouldReturnFileName() var result = from.GetRelativePath(to); // Assert - result.Should().Be("file.txt"); + result.ShouldBe("file.txt"); } #endregion @@ -258,7 +258,7 @@ public void IsAncestorOf_WithDescendant_ShouldReturnTrue() var result = ancestor.IsAncestorOf(descendant); // Assert - result.Should().BeTrue(); + result.ShouldBeTrue(); } [Fact] @@ -272,7 +272,7 @@ public void IsAncestorOf_WithNonDescendant_ShouldReturnFalse() var result = ancestor.IsAncestorOf(nonDescendant); // Assert - result.Should().BeFalse(); + result.ShouldBeFalse(); } #endregion @@ -292,7 +292,7 @@ public void IsDirectChildOf_WithDirectChild_ShouldReturnTrue() // Assert // Note: The method behavior may vary based on internal path representation // We just verify it doesn't throw an exception and returns a bool - result.Should().Be(result); // Just verify no exception is thrown + result.ShouldBe(result); // Just verify no exception is thrown } [Fact] @@ -306,7 +306,7 @@ public void IsDirectChildOf_WithNonDirectChild_ShouldReturnFalse() var result = child.IsDirectChildOf(parent); // Assert - result.Should().BeFalse(); + result.ShouldBeFalse(); } #endregion @@ -323,10 +323,10 @@ public void GetAncestors_WithNestedPath_ShouldReturnAncestors() var ancestors = path.GetAncestors().ToList(); // Assert - ancestors.Should().HaveCount(3); - ancestors.Should().Contain(a => a.Value.Contains("deep")); - ancestors.Should().Contain(a => a.Value.Contains("subfolder")); - ancestors.Should().Contain(a => a.Value.Contains("docs")); + ancestors.Count.ShouldBe(3); + ancestors.ShouldContain(a => a.Value.Contains("deep")); + ancestors.ShouldContain(a => a.Value.Contains("subfolder")); + ancestors.ShouldContain(a => a.Value.Contains("docs")); } #endregion @@ -347,7 +347,7 @@ public void MatchesGlob_WithVariousPatterns_ShouldReturnCorrectResult(string pat var result = path.MatchesGlob(pattern); // Assert - result.Should().Be(expected); + result.ShouldBe(expected); } #endregion @@ -365,7 +365,7 @@ public void Normalize_WithVariousPaths_ShouldReturnNormalizedPath(string input, var result = VFSPathExtensions.Normalize(input); // Assert - result.Should().Be(expected); + result.ShouldBe(expected); } #endregion @@ -385,7 +385,7 @@ public void GetDepth_WithVariousPaths_ShouldReturnCorrectDepth(string pathValue, var depth = path.GetDepth(); // Assert - depth.Should().Be(expectedDepth); + depth.ShouldBe(expectedDepth); } #endregion @@ -402,7 +402,7 @@ public void IsAtDepth_WithCorrectDepth_ShouldReturnTrue() var result = path.IsAtDepth(2); // Assert - result.Should().BeTrue(); + result.ShouldBeTrue(); } [Fact] @@ -415,7 +415,7 @@ public void IsAtDepth_WithIncorrectDepth_ShouldReturnFalse() var result = path.IsAtDepth(1); // Assert - result.Should().BeFalse(); + result.ShouldBeFalse(); } #endregion diff --git a/tests/Atypical.VirtualFileSystem.UnitTests/GlobalUsings.cs b/tests/Atypical.VirtualFileSystem.UnitTests/GlobalUsings.cs index 6dd381f..c9e4b3f 100644 --- a/tests/Atypical.VirtualFileSystem.UnitTests/GlobalUsings.cs +++ b/tests/Atypical.VirtualFileSystem.UnitTests/GlobalUsings.cs @@ -9,5 +9,5 @@ global using Atypical.VirtualFileSystem.Core; global using Atypical.VirtualFileSystem.Core.Contracts; global using Atypical.VirtualFileSystem.Core.Services; -global using FluentAssertions; +global using Shouldly; global using Xunit; \ No newline at end of file diff --git a/tests/Atypical.VirtualFileSystem.UnitTests/Models/DirectoryNodeTests.cs b/tests/Atypical.VirtualFileSystem.UnitTests/Models/DirectoryNodeTests.cs index b8c0b59..94d093a 100644 --- a/tests/Atypical.VirtualFileSystem.UnitTests/Models/DirectoryNodeTests.cs +++ b/tests/Atypical.VirtualFileSystem.UnitTests/Models/DirectoryNodeTests.cs @@ -22,12 +22,12 @@ public void Constructor_create_a_directory_node() var directoryNode = new DirectoryNode(directoryPath); // Assert - directoryNode.Should().NotBeNull(); - directoryNode.Directories.Should().BeEmpty(); - directoryNode.Files.Should().BeEmpty(); - directoryNode.Path.Value.Should().Be(expectedPath); - directoryNode.Path.Parent.Should().NotBeNull(); - directoryNode.Path.Parent!.Value.Should().Be(expectedParentPath); + directoryNode.ShouldNotBeNull(); + directoryNode.Directories.ShouldBeEmpty(); + directoryNode.Files.ShouldBeEmpty(); + directoryNode.Path.Value.ShouldBe(expectedPath); + directoryNode.Path.Parent.ShouldNotBeNull(); + directoryNode.Path.Parent!.Value.ShouldBe(expectedParentPath); } [Fact] @@ -36,9 +36,9 @@ public void Constructor_create_a_directory_node_with_parent() var directoryPath = new VFSDirectoryPath("parent/child"); var directory = new DirectoryNode(directoryPath); - directory.Path.Value.Should().Be("vfs://parent/child"); - directory.Path.Parent.Should().NotBeNull(); - directory.Path.Parent!.Value.Should().Be("vfs://parent"); + directory.Path.Value.ShouldBe("vfs://parent/child"); + directory.Path.Parent.ShouldNotBeNull(); + directory.Path.Parent!.Value.ShouldBe("vfs://parent"); } } @@ -50,7 +50,7 @@ public void ToString_return_path() var directoryPath = new VFSDirectoryPath("test"); var directoryNode = new DirectoryNode(directoryPath); - directoryNode.ToString().Should().Be("vfs://test"); + directoryNode.ToString().ShouldBe("vfs://test"); } [Fact] @@ -59,7 +59,7 @@ public void ToString_return_path_with_parent() var directoryPath = new VFSDirectoryPath("parent/child"); var directory = new DirectoryNode(directoryPath); - directory.ToString().Should().Be("vfs://parent/child"); + directory.ToString().ShouldBe("vfs://parent/child"); } } } \ No newline at end of file diff --git a/tests/Atypical.VirtualFileSystem.UnitTests/Models/FileNodeTests.cs b/tests/Atypical.VirtualFileSystem.UnitTests/Models/FileNodeTests.cs index 7904729..adff439 100644 --- a/tests/Atypical.VirtualFileSystem.UnitTests/Models/FileNodeTests.cs +++ b/tests/Atypical.VirtualFileSystem.UnitTests/Models/FileNodeTests.cs @@ -20,10 +20,10 @@ public void Constructor_creates_a_file_with_the_specified_name() var fileNode = new FileNode(path); // Assert - fileNode.Path.Should().Be(path); - fileNode.Content.Should().BeEmpty(); - fileNode.IsDirectory.Should().BeFalse(); - fileNode.IsFile.Should().BeTrue(); + fileNode.Path.ShouldBe(path); + fileNode.Content.ShouldBeEmpty(); + fileNode.IsDirectory.ShouldBeFalse(); + fileNode.IsFile.ShouldBeTrue(); } } @@ -40,7 +40,7 @@ public void ToString_returns_the_path_of_the_file() var result = fileNode.ToString(); // Assert - result.Should().Be(path.ToString()); + result.ShouldBe(path.ToString()); } } } diff --git a/tests/Atypical.VirtualFileSystem.UnitTests/Models/RootNodeTests.cs b/tests/Atypical.VirtualFileSystem.UnitTests/Models/RootNodeTests.cs index 7fa9a72..7bfb76d 100644 --- a/tests/Atypical.VirtualFileSystem.UnitTests/Models/RootNodeTests.cs +++ b/tests/Atypical.VirtualFileSystem.UnitTests/Models/RootNodeTests.cs @@ -20,11 +20,11 @@ public void Constructor_create_a_root_node() var rootNode = new RootNode(); // Assert - rootNode.Should().NotBeNull(); - rootNode.Directories.Should().BeEmpty(); - rootNode.Files.Should().BeEmpty(); - rootNode.Path.Value.Should().Be(expectedPath); - rootNode.Path.Parent.Should().BeNull(); + rootNode.ShouldNotBeNull(); + rootNode.Directories.ShouldBeEmpty(); + rootNode.Files.ShouldBeEmpty(); + rootNode.Path.Value.ShouldBe(expectedPath); + rootNode.Path.Parent.ShouldBeNull(); } } @@ -35,7 +35,7 @@ public void ToString_return_path() { var rootNode = new RootNode(); - rootNode.ToString().Should().Be("vfs://"); + rootNode.ToString().ShouldBe("vfs://"); } } } \ No newline at end of file diff --git a/tests/Atypical.VirtualFileSystem.UnitTests/Models/ValueObjects/VFSDirectoryPathTests.cs b/tests/Atypical.VirtualFileSystem.UnitTests/Models/ValueObjects/VFSDirectoryPathTests.cs index daf0f36..cd0b266 100644 --- a/tests/Atypical.VirtualFileSystem.UnitTests/Models/ValueObjects/VFSDirectoryPathTests.cs +++ b/tests/Atypical.VirtualFileSystem.UnitTests/Models/ValueObjects/VFSDirectoryPathTests.cs @@ -29,9 +29,8 @@ public void Constructor_throw_VFSException_when_path_is_null() }; // Assert - action.Should() - .Throw() - .WithMessage("An empty path is invalid."); + var ex = Should.Throw(action); + ex.Message.ShouldBe("An empty path is invalid."); } [Fact] @@ -47,9 +46,8 @@ public void Constructor_throw_VFSException_when_path_is_empty() }; // Assert - action.Should() - .Throw() - .WithMessage("An empty path is invalid."); + var ex = Should.Throw(action); + ex.Message.ShouldBe("An empty path is invalid."); } [Fact] @@ -65,9 +63,8 @@ public void Constructor_throw_VFSException_when_path_contains_relative_path_segm }; // Assert - action.Should() - .Throw() - .WithMessage("The path 'vfs://invalid/../path' contains a relative path segment."); + var ex = Should.Throw(action); + ex.Message.ShouldBe("The path 'vfs://invalid/../path' contains a relative path segment."); } [Fact] @@ -83,9 +80,8 @@ public void Constructor_throw_VFSException_when_path_contains_consecutive_slashe }; // Assert - action.Should() - .Throw() - .WithMessage("The path 'vfs://invalid//path' is invalid."); + var ex = Should.Throw(action); + ex.Message.ShouldBe("The path 'vfs://invalid//path' is invalid."); } [Fact] @@ -101,9 +97,8 @@ public void Constructor_throw_VFSException_when_path_is_not_a_directory_path() }; // Assert - action.Should() - .Throw() - .WithMessage("The directory path 'invalid/path.txt' contains a file extension."); + var ex = Should.Throw(action); + ex.Message.ShouldBe("The directory path 'invalid/path.txt' contains a file extension."); } [Fact] @@ -117,8 +112,8 @@ public void Constructor_create_instance_when_path_is_valid() var directoryPath = new VFSDirectoryPath(path); // Assert - directoryPath.Should().NotBeNull(); - directoryPath.Value.Should().Be(expectedPath); + directoryPath.ShouldNotBeNull(); + directoryPath.Value.ShouldBe(expectedPath); } [Fact] @@ -132,8 +127,8 @@ public void Constructor_create_instance_when_path_is_valid_and_contains_uppercas var directoryPath = new VFSDirectoryPath(path); // Assert - directoryPath.Should().NotBeNull(); - directoryPath.Value.Should().Be(expectedPath); + directoryPath.ShouldNotBeNull(); + directoryPath.Value.ShouldBe(expectedPath); } [Fact] @@ -147,8 +142,8 @@ public void Constructor_create_instance_when_path_is_valid_and_contains_numbers( var directoryPath = new VFSDirectoryPath(path); // Assert - directoryPath.Should().NotBeNull(); - directoryPath.Value.Should().Be(expectedPath); + directoryPath.ShouldNotBeNull(); + directoryPath.Value.ShouldBe(expectedPath); } [Fact] @@ -162,8 +157,8 @@ public void Constructor_create_instance_when_path_has_leading_slash() var directoryPath = new VFSDirectoryPath(path); // Assert - directoryPath.Should().NotBeNull(); - directoryPath.Value.Should().Be(expectedPath); + directoryPath.ShouldNotBeNull(); + directoryPath.Value.ShouldBe(expectedPath); } @@ -178,8 +173,8 @@ public void Constructor_create_instance_when_path_is_valid_and_ends_with_slash() var vfsPath = new VFSDirectoryPath(path); // Assert - vfsPath.Value.Should().NotBeNull(); - vfsPath.Value.Should().Be(expectedPath); + vfsPath.Value.ShouldNotBeNull(); + vfsPath.Value.ShouldBe(expectedPath); } [Fact] @@ -193,8 +188,8 @@ public void Constructor_create_instance_when_path_is_valid_and_starts_with_slash var vfsPath = new VFSDirectoryPath(path); // Assert - vfsPath.Value.Should().NotBeNull(); - vfsPath.Value.Should().Be(expectedPath); + vfsPath.Value.ShouldNotBeNull(); + vfsPath.Value.ShouldBe(expectedPath); } [Fact] @@ -208,8 +203,8 @@ public void Constructor_create_instance_when_path_is_valid_and_starts_with_dot() var vfsPath = new VFSDirectoryPath(path); // Assert - vfsPath.Value.Should().NotBeNull(); - vfsPath.Value.Should().Be(expectedPath); + vfsPath.Value.ShouldNotBeNull(); + vfsPath.Value.ShouldBe(expectedPath); } [Fact] @@ -223,8 +218,8 @@ public void Constructor_create_instance_when_path_is_valid_and_starts_and_ends_w var vfsPath = new VFSDirectoryPath(path); // Assert - vfsPath.Value.Should().NotBeNull(); - vfsPath.Value.Should().Be(expectedPath); + vfsPath.Value.ShouldNotBeNull(); + vfsPath.Value.ShouldBe(expectedPath); } [Fact] @@ -238,10 +233,10 @@ public void Constructor_create_instance_for_root_directory() var directoryPath = new VFSDirectoryPath(path); // Assert - directoryPath.Should().NotBeNull(); - directoryPath.Value.Should().Be(expectedPath); - directoryPath.IsRoot.Should().BeTrue(); - directoryPath.Parent.Should().BeNull(); + directoryPath.ShouldNotBeNull(); + directoryPath.Value.ShouldBe(expectedPath); + directoryPath.IsRoot.ShouldBeTrue(); + directoryPath.Parent.ShouldBeNull(); } [Fact] @@ -255,11 +250,11 @@ public void Constructor_create_instance_for_simple_directory() var directoryPath = new VFSDirectoryPath(path); // Assert - directoryPath.Should().NotBeNull(); - directoryPath.Value.Should().Be(expectedPath); - directoryPath.IsRoot.Should().BeFalse(); - directoryPath.Parent.Should().NotBeNull(); - directoryPath.Parent!.Value.Should().Be("vfs://"); + directoryPath.ShouldNotBeNull(); + directoryPath.Value.ShouldBe(expectedPath); + directoryPath.IsRoot.ShouldBeFalse(); + directoryPath.Parent.ShouldNotBeNull(); + directoryPath.Parent!.Value.ShouldBe("vfs://"); } [Fact] @@ -273,11 +268,11 @@ public void Constructor_create_instance_for_nested_directory() var directoryPath = new VFSDirectoryPath(path); // Assert - directoryPath.Should().NotBeNull(); - directoryPath.Value.Should().Be(expectedPath); - directoryPath.IsRoot.Should().BeFalse(); - directoryPath.Parent.Should().NotBeNull(); - directoryPath.Parent!.Value.Should().Be("vfs://valid"); + directoryPath.ShouldNotBeNull(); + directoryPath.Value.ShouldBe(expectedPath); + directoryPath.IsRoot.ShouldBeFalse(); + directoryPath.Parent.ShouldNotBeNull(); + directoryPath.Parent!.Value.ShouldBe("vfs://valid"); } } @@ -294,7 +289,7 @@ public void PropertyName_return_name_of_directory() var vfsPath = new VFSDirectoryPath(path); // Assert - vfsPath.Name.Should().Be(expectedName); + vfsPath.Name.ShouldBe(expectedName); } } @@ -310,7 +305,7 @@ public void PropertyDepth_return_0_when_path_is_root() var vfsPath = new VFSDirectoryPath(path); // Assert - vfsPath.Depth.Should().Be(0); + vfsPath.Depth.ShouldBe(0); } [Fact] @@ -323,7 +318,7 @@ public void PropertyDepth_return_1_with_one_directory() var vfsPath = new VFSDirectoryPath(path); // Assert - vfsPath.Depth.Should().Be(1); + vfsPath.Depth.ShouldBe(1); } [Fact] @@ -336,7 +331,7 @@ public void PropertyDepth_return_2_with_two_directories() var vfsPath = new VFSDirectoryPath(path); // Assert - vfsPath.Depth.Should().Be(2); + vfsPath.Depth.ShouldBe(2); } [Fact] @@ -349,7 +344,7 @@ public void PropertyDepth_return_3_with_three_directories() var vfsPath = new VFSDirectoryPath(path); // Assert - vfsPath.Depth.Should().Be(3); + vfsPath.Depth.ShouldBe(3); } } @@ -365,7 +360,7 @@ public void PropertyHasParent_return_false_when_path_is_root() var vfsPath = new VFSDirectoryPath(path); // Assert - vfsPath.HasParent.Should().BeFalse(); + vfsPath.HasParent.ShouldBeFalse(); } [Fact] @@ -378,7 +373,7 @@ public void PropertyHasParent_return_true_when_path_has_parent() var vfsPath = new VFSDirectoryPath(path); // Assert - vfsPath.HasParent.Should().BeTrue(); + vfsPath.HasParent.ShouldBeTrue(); } } @@ -394,7 +389,7 @@ public void PropertyParentPath_return_null_when_path_is_root() var vfsPath = new VFSDirectoryPath(path); // Assert - vfsPath.Parent.Should().BeNull(); + vfsPath.Parent.ShouldBeNull(); } [Fact] @@ -408,8 +403,8 @@ public void PropertyParentPath_return_parent_path_when_path_has_parent() var vfsPath = new VFSDirectoryPath(path); // Assert - vfsPath.Parent.Should().NotBeNull(); - vfsPath.Parent!.Value.Should().Be(expectedParentPath); + vfsPath.Parent.ShouldNotBeNull(); + vfsPath.Parent!.Value.ShouldBe(expectedParentPath); } } @@ -427,8 +422,8 @@ public void MethodGetAbsoluteParentPath_return_root_when_path_is_root() var parent = vfsPath.GetAbsoluteParentPath(0); // Assert - parent.Should().NotBeNull(); - parent.Value.Should().Be(expectedPath); + parent.ShouldNotBeNull(); + parent.Value.ShouldBe(expectedPath); } [Fact] @@ -442,12 +437,11 @@ public void MethodGetAbsoluteParentPath_throw_VFSException_when_depth_is_negativ Action action = () => vfsPath.GetAbsoluteParentPath(-1); // Assert - action.Should() - .Throw() - .WithMessage($""" - The depth from root must be greater than or equal to 0. - Actual value: {-1}. - """); + var ex = Should.Throw(action); + ex.Message.ShouldBe($""" + The depth from root must be greater than or equal to 0. + Actual value: {-1}. + """); } [Fact] @@ -462,8 +456,8 @@ public void MethodGetAbsoluteParentPath_return_root_when_depth_is_zero() var parent = vfsPath.GetAbsoluteParentPath(0); // Assert - parent.Should().NotBeNull(); - parent.Value.Should().Be(expectedPath); + parent.ShouldNotBeNull(); + parent.Value.ShouldBe(expectedPath); } [Fact] @@ -478,8 +472,8 @@ public void MethodGetAbsoluteParentPath_return_parent_when_depth_is_one() var parent = vfsPath.GetAbsoluteParentPath(1); // Assert - parent.Should().NotBeNull(); - parent.Value.Should().Be(expectedPath); + parent.ShouldNotBeNull(); + parent.Value.ShouldBe(expectedPath); } [Fact] @@ -494,8 +488,8 @@ public void MethodGetAbsoluteParentPath_return_grandparent_when_depth_is_two() var parent = vfsPath.GetAbsoluteParentPath(2); // Assert - parent.Should().NotBeNull(); - parent.Value.Should().Be(expectedPath); + parent.ShouldNotBeNull(); + parent.Value.ShouldBe(expectedPath); } } @@ -513,7 +507,7 @@ public void ToString_return_path() var result = directoryPath.ToString(); // Assert - result.Should().Be(expectedPath); + result.ShouldBe(expectedPath); } [Fact] @@ -527,7 +521,7 @@ public void ToString_returns_path_with_child() var vfsPath = new VFSDirectoryPath(path); // Assert - vfsPath.ToString().Should().Be(expectedPath); + vfsPath.ToString().ShouldBe(expectedPath); } [Fact] @@ -541,7 +535,7 @@ public void ToString_return_path_with_vfs_prefix() var result = directoryPath.ToString(); // Assert - result.Should().Be($"vfs://{path}"); + result.ShouldBe($"vfs://{path}"); } } @@ -558,7 +552,7 @@ public void ImplicitOperator_ToString_returns_value() string result = directoryPath; // Assert - result.Should().Be(expectedPath); + result.ShouldBe(expectedPath); } } @@ -575,7 +569,7 @@ public void Equals_returns_true_when_paths_are_equal() var result = directoryPath1.Equals(directoryPath2); // Assert - result.Should().BeTrue(); + result.ShouldBeTrue(); } [Fact] @@ -588,7 +582,7 @@ public void Equals_returns_true_when_paths_are_the_same() var vfsPath1 = new VFSDirectoryPath(path); // Assert - vfsPath1.Equals(vfsPath1).Should().BeTrue(); + vfsPath1.Equals(vfsPath1).ShouldBeTrue(); } [Fact] @@ -603,7 +597,7 @@ public void Equals_returns_false_when_paths_are_not_equal() var vfsPath2 = new VFSDirectoryPath(path2); // Assert - vfsPath1.Equals(vfsPath2).Should().BeFalse(); + vfsPath1.Equals(vfsPath2).ShouldBeFalse(); } [Fact] @@ -618,7 +612,7 @@ public void Equals_returns_false_when_paths_are_not_equal_and_one_is_file() var vfsPath2 = new VFSFilePath(path2); // Assert - vfsPath1.Equals(vfsPath2).Should().BeFalse(); + vfsPath1.Equals(vfsPath2).ShouldBeFalse(); } } } \ No newline at end of file diff --git a/tests/Atypical.VirtualFileSystem.UnitTests/Models/ValueObjects/VFSFilePathTests.cs b/tests/Atypical.VirtualFileSystem.UnitTests/Models/ValueObjects/VFSFilePathTests.cs index 559caf6..582ccda 100644 --- a/tests/Atypical.VirtualFileSystem.UnitTests/Models/ValueObjects/VFSFilePathTests.cs +++ b/tests/Atypical.VirtualFileSystem.UnitTests/Models/ValueObjects/VFSFilePathTests.cs @@ -30,8 +30,8 @@ public void Constructor_create_instance_when_path_is_valid(string path, string e var vfsPath = new VFSFilePath(path); // Assert - vfsPath.Value.Should().NotBeNull(); - vfsPath.Value.Should().Be(expectedPath); + vfsPath.Value.ShouldNotBeNull(); + vfsPath.Value.ShouldBe(expectedPath); } [Fact] @@ -45,8 +45,8 @@ public void Constructor_create_instance_when_path_is_valid_and_starts_with_dot() var vfsPath = new VFSFilePath(path); // Assert - vfsPath.Value.Should().NotBeNull(); - vfsPath.Value.Should().Be(expectedPath); + vfsPath.Value.ShouldNotBeNull(); + vfsPath.Value.ShouldBe(expectedPath); } [Fact] @@ -62,9 +62,8 @@ public void Constructor_throw_VFSException_when_path_is_null() }; // Assert - action.Should() - .Throw() - .WithMessage("An empty path is invalid."); + var ex = Should.Throw(action); + ex.Message.ShouldBe("An empty path is invalid."); } [Fact] @@ -80,9 +79,8 @@ public void Constructor_throw_VFSException_when_path_is_empty() }; // Assert - action.Should() - .Throw() - .WithMessage("An empty path is invalid."); + var ex = Should.Throw(action); + ex.Message.ShouldBe("An empty path is invalid."); } } @@ -99,7 +97,7 @@ public void PropertyName_return_name_of_file() var vfsPath = new VFSFilePath(path); // Assert - vfsPath.Name.Should().Be(expectedName); + vfsPath.Name.ShouldBe(expectedName); } [Fact] @@ -113,7 +111,7 @@ public void PropertyName_return_name_of_root_directory() var vfsPath = new VFSFilePath(path); // Assert - vfsPath.Name.Should().Be(expectedName); + vfsPath.Name.ShouldBe(expectedName); } } @@ -130,7 +128,7 @@ public void ToString_returns_value() var result = filePath.ToString(); // Assert - result.Should().Be(expectedPath); + result.ShouldBe(expectedPath); } } @@ -148,7 +146,7 @@ public void GetHashCode_returns_same_value_for_same_path() var hashCode2 = filePath2.GetHashCode(); // Assert - hashCode1.Should().Be(hashCode2); + hashCode1.ShouldBe(hashCode2); } } @@ -165,7 +163,7 @@ public void ImplicitOperator_ToString_returns_value() string result = filePath; // Assert - result.Should().Be(expectedPath); + result.ShouldBe(expectedPath); } } @@ -182,7 +180,7 @@ public void Equals_returns_true_when_paths_are_equal() var result = filePath1.Equals(filePath2); // Assert - result.Should().BeTrue(); + result.ShouldBeTrue(); } } } \ No newline at end of file diff --git a/tests/Atypical.VirtualFileSystem.UnitTests/Models/ValueObjects/VFSPathTests.cs b/tests/Atypical.VirtualFileSystem.UnitTests/Models/ValueObjects/VFSPathTests.cs index 06825f7..a60773f 100644 --- a/tests/Atypical.VirtualFileSystem.UnitTests/Models/ValueObjects/VFSPathTests.cs +++ b/tests/Atypical.VirtualFileSystem.UnitTests/Models/ValueObjects/VFSPathTests.cs @@ -15,7 +15,7 @@ public void Equals_returns_true_when_paths_are_equal() bool result = path1.Equals(path2); // Assert - result.Should().BeTrue(); + result.ShouldBeTrue(); } [Fact] @@ -29,7 +29,7 @@ public void Equals_returns_true_when_paths_are_the_same() bool result = path1.Equals(path2); // Assert - result.Should().BeTrue(); + result.ShouldBeTrue(); } [Fact] @@ -43,7 +43,7 @@ public void Equals_returns_false_when_paths_are_not_equal() bool result = path1.Equals(path2); // Assert - result.Should().BeFalse(); + result.ShouldBeFalse(); } } } \ No newline at end of file diff --git a/tests/Atypical.VirtualFileSystem.UnitTests/Models/ValueObjects/VFSRootPathTests.cs b/tests/Atypical.VirtualFileSystem.UnitTests/Models/ValueObjects/VFSRootPathTests.cs index bd8a8fe..443ed86 100644 --- a/tests/Atypical.VirtualFileSystem.UnitTests/Models/ValueObjects/VFSRootPathTests.cs +++ b/tests/Atypical.VirtualFileSystem.UnitTests/Models/ValueObjects/VFSRootPathTests.cs @@ -20,10 +20,10 @@ public void Constructor_create_instance() var directoryPath = new VFSRootPath(); // Assert - directoryPath.Should().NotBeNull(); - directoryPath.Value.Should().Be(expectedPath); - directoryPath.IsRoot.Should().BeTrue(); - directoryPath.Parent.Should().BeNull(); + directoryPath.ShouldNotBeNull(); + directoryPath.Value.ShouldBe(expectedPath); + directoryPath.IsRoot.ShouldBeTrue(); + directoryPath.Parent.ShouldBeNull(); } } @@ -39,7 +39,7 @@ public void ToString_returns_value() var directoryPath = new VFSRootPath(); // Assert - directoryPath.ToString().Should().Be(expectedPath); + directoryPath.ToString().ShouldBe(expectedPath); } } @@ -56,7 +56,7 @@ public void ImplicitOperator_ToString_returns_value() string result = rootPath; // Assert - result.Should().Be(expectedPath); + result.ShouldBe(expectedPath); } } @@ -73,7 +73,7 @@ public void Equals_returns_true_when_paths_are_equal() var result = rootPath1.Equals(rootPath2); // Assert - result.Should().BeTrue(); + result.ShouldBeTrue(); } } } \ No newline at end of file diff --git a/tests/Atypical.VirtualFileSystem.UnitTests/Services/ServiceCollectionExtensionsTests.cs b/tests/Atypical.VirtualFileSystem.UnitTests/Services/ServiceCollectionExtensionsTests.cs index b980085..de16f4f 100644 --- a/tests/Atypical.VirtualFileSystem.UnitTests/Services/ServiceCollectionExtensionsTests.cs +++ b/tests/Atypical.VirtualFileSystem.UnitTests/Services/ServiceCollectionExtensionsTests.cs @@ -22,8 +22,7 @@ public void AddVirtualFileSystem_registers_VirtualFileSystem_in_DI() services.AddVirtualFileSystem(); // Assert - services.Should() - .Contain(service => service.ServiceType == typeof(IVirtualFileSystem) + services.ShouldContain(service => service.ServiceType == typeof(IVirtualFileSystem) && service.ImplementationType == typeof(VFS) && service.Lifetime == ServiceLifetime.Scoped); } diff --git a/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Commands/VirtualFileSystem_MethodCreateDirectory_Tests.cs b/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Commands/VirtualFileSystem_MethodCreateDirectory_Tests.cs index 077d23a..37b0814 100644 --- a/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Commands/VirtualFileSystem_MethodCreateDirectory_Tests.cs +++ b/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Commands/VirtualFileSystem_MethodCreateDirectory_Tests.cs @@ -15,14 +15,14 @@ public void CreateDirectory_creates_a_directory() Act(); // Assert - _vfs.IsEmpty.Should().BeFalse(); - _vfs.Index.RawIndex.Should().NotBeEmpty(); - _vfs.Index.RawIndex.Should().HaveCount(1); - _vfs.Index.RawIndex.Should().ContainKey(new VFSDirectoryPath("vfs://dir1")); - _vfs.Root.IsDirectory.Should().BeTrue(); - _vfs.Root.IsFile.Should().BeFalse(); - _vfs.Root.Path.Value.Should().Be("vfs://"); - _vfs.Root.CreationTime.Should().BeCloseTo(DateTime.Now, TimeSpan.FromHours(1)); + _vfs.IsEmpty.ShouldBeFalse(); + _vfs.Index.RawIndex.ShouldNotBeEmpty(); + _vfs.Index.RawIndex.Count.ShouldBe(1); + _vfs.Index.RawIndex.ShouldContainKey(new VFSDirectoryPath("vfs://dir1")); + _vfs.Root.IsDirectory.ShouldBeTrue(); + _vfs.Root.IsFile.ShouldBeFalse(); + _vfs.Root.Path.Value.ShouldBe("vfs://"); + (DateTime.Now - _vfs.Root.CreationTime).ShouldBeLessThan(TimeSpan.FromHours(1)); } [Fact] @@ -35,19 +35,19 @@ public void CreateDirectory_creates_a_directory_and_its_parents() Act(); // Assert - _vfs.Index.RawIndex.Should().NotBeEmpty(); - _vfs.Index.RawIndex.Should().HaveCount(3); // dir1 + dir2 + dir3 - _vfs.Index.RawIndex.Should().ContainKey(_directoryPath); - _vfs.Index.RawIndex.Should().ContainKey(new VFSDirectoryPath("vfs://dir1")); - _vfs.Index.RawIndex.Should().ContainKey(new VFSDirectoryPath("vfs://dir1/dir2")); - _vfs.Index.RawIndex.Should().ContainKey(new VFSDirectoryPath("vfs://dir1/dir2/dir3")); + _vfs.Index.RawIndex.ShouldNotBeEmpty(); + _vfs.Index.RawIndex.Count.ShouldBe(3); // dir1 + dir2 + dir3 + _vfs.Index.RawIndex.ShouldContainKey(_directoryPath); + _vfs.Index.RawIndex.ShouldContainKey(new VFSDirectoryPath("vfs://dir1")); + _vfs.Index.RawIndex.ShouldContainKey(new VFSDirectoryPath("vfs://dir1/dir2")); + _vfs.Index.RawIndex.ShouldContainKey(new VFSDirectoryPath("vfs://dir1/dir2/dir3")); - _vfs.Index[new VFSDirectoryPath("vfs://dir1")].Should().BeAssignableTo(); - _vfs.Index[new VFSDirectoryPath("vfs://dir1/dir2")].Should().BeAssignableTo(); - _vfs.Index[new VFSDirectoryPath("vfs://dir1/dir2/dir3")].Should().BeAssignableTo(); + _vfs.Index[new VFSDirectoryPath("vfs://dir1")].ShouldBeAssignableTo(); + _vfs.Index[new VFSDirectoryPath("vfs://dir1/dir2")].ShouldBeAssignableTo(); + _vfs.Index[new VFSDirectoryPath("vfs://dir1/dir2/dir3")].ShouldBeAssignableTo(); - _vfs.Index[new VFSDirectoryPath("vfs://dir1")].As().Directories.Should().NotBeEmpty(); - _vfs.Index[new VFSDirectoryPath("vfs://dir1")].As().Directories.Should().HaveCount(1); + ((IDirectoryNode)_vfs.Index[new VFSDirectoryPath("vfs://dir1")]).Directories.ShouldNotBeEmpty(); + ((IDirectoryNode)_vfs.Index[new VFSDirectoryPath("vfs://dir1")]).Directories.Count().ShouldBe(1); } [Fact] @@ -60,9 +60,8 @@ public void CreateDirectory_throws_an_exception_if_the_directory_already_exists( var action = Act; // Assert - action.Should() - .Throw() - .WithMessage($"The node 'vfs://dir1' already exists in the index."); + var ex = Should.Throw(action); + ex.Message.ShouldBe("The node 'vfs://dir1' already exists in the index."); } [Fact] @@ -72,9 +71,8 @@ public void CreateDirectory_throws_an_exception_if_the_path_is_the_root_director Action action = () => _vfs.CreateDirectory(new VFSRootPath()); // Assert - action.Should() - .Throw() - .WithMessage("Cannot create the root directory."); + var ex = Should.Throw(action); + ex.Message.ShouldBe("Cannot create the root directory."); } [Fact] @@ -86,14 +84,14 @@ public void CreateDirectory_raises_a_DirectoryCreated_event() _vfs.DirectoryCreated += args => { eventRaised = true; - args.Path.Should().Be(_directoryPath); + args.Path.ShouldBe(_directoryPath); }; // Act Act(); // Assert - eventRaised.Should().BeTrue(); + eventRaised.ShouldBeTrue(); } [Fact] @@ -106,8 +104,8 @@ public void CreateDirectory_adds_a_change_to_the_ChangeHistory() var change = _vfs.ChangeHistory.UndoStack.First(); // Assert - _vfs.ChangeHistory.UndoStack.Should().ContainEquivalentOf(change); - _vfs.ChangeHistory.UndoStack.Should().HaveCount(1); - _vfs.ChangeHistory.RedoStack.Should().BeEmpty(); + _vfs.ChangeHistory.UndoStack.ShouldContain(change); + _vfs.ChangeHistory.UndoStack.Count.ShouldBe(1); + _vfs.ChangeHistory.RedoStack.ShouldBeEmpty(); } } \ No newline at end of file diff --git a/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Commands/VirtualFileSystem_MethodCreateFile_Tests.cs b/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Commands/VirtualFileSystem_MethodCreateFile_Tests.cs index b2b4479..924852d 100644 --- a/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Commands/VirtualFileSystem_MethodCreateFile_Tests.cs +++ b/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Commands/VirtualFileSystem_MethodCreateFile_Tests.cs @@ -15,12 +15,12 @@ public void CreateFile_creates_a_file() Act(); // Assert - _vfs.IsEmpty.Should().BeFalse(); - _vfs.Index.RawIndex.Should().NotBeEmpty(); - _vfs.Index.RawIndex.Should().HaveCount(1); - _vfs.Index.RawIndex.Should().ContainKey(new VFSFilePath("vfs://file.txt")); - _vfs.Root.Files.Should().NotBeEmpty(); - _vfs.Root.Files.Should().HaveCount(1); + _vfs.IsEmpty.ShouldBeFalse(); + _vfs.Index.RawIndex.ShouldNotBeEmpty(); + _vfs.Index.RawIndex.Count.ShouldBe(1); + _vfs.Index.RawIndex.ShouldContainKey(new VFSFilePath("vfs://file.txt")); + _vfs.Root.Files.ShouldNotBeEmpty(); + _vfs.Root.Files.Count().ShouldBe(1); } [Fact] @@ -33,15 +33,15 @@ public void CreateFile_creates_a_file_and_its_parents() Act(); // Assert - _vfs.IsEmpty.Should().BeFalse(); - _vfs.Index.RawIndex.Should().NotBeEmpty(); - _vfs.Index.RawIndex.Should().HaveCount(4); // dir1 + dir2 + dir3 + file.txt - _vfs.Index.RawIndex.Should().ContainKey(new VFSDirectoryPath("vfs://dir1")); - _vfs.Index.RawIndex.Should().ContainKey(new VFSDirectoryPath("vfs://dir1/dir2")); - _vfs.Index.RawIndex.Should().ContainKey(new VFSDirectoryPath("vfs://dir1/dir2/dir3")); - _vfs.Index.RawIndex.Should().ContainKey(new VFSFilePath("vfs://dir1/dir2/dir3/file.txt")); - _vfs.Root.Directories.Should().NotBeEmpty(); - _vfs.Root.Directories.Should().HaveCount(1); + _vfs.IsEmpty.ShouldBeFalse(); + _vfs.Index.RawIndex.ShouldNotBeEmpty(); + _vfs.Index.RawIndex.Count.ShouldBe(4); // dir1 + dir2 + dir3 + file.txt + _vfs.Index.RawIndex.ShouldContainKey(new VFSDirectoryPath("vfs://dir1")); + _vfs.Index.RawIndex.ShouldContainKey(new VFSDirectoryPath("vfs://dir1/dir2")); + _vfs.Index.RawIndex.ShouldContainKey(new VFSDirectoryPath("vfs://dir1/dir2/dir3")); + _vfs.Index.RawIndex.ShouldContainKey(new VFSFilePath("vfs://dir1/dir2/dir3/file.txt")); + _vfs.Root.Directories.ShouldNotBeEmpty(); + _vfs.Root.Directories.Count().ShouldBe(1); } [Fact] @@ -55,9 +55,8 @@ public void CreateFile_throws_an_exception_if_the_file_already_exists() var action = Act; // Assert - action.Should() - .Throw() - .WithMessage("The node 'vfs://dir1/dir2/dir3/file.txt' already exists in the index."); + var ex = Should.Throw(action); + ex.Message.ShouldBe("The node 'vfs://dir1/dir2/dir3/file.txt' already exists in the index."); } [Fact] @@ -69,14 +68,14 @@ public void CreateFile_raises_a_FileCreated_event() _vfs.FileCreated += args => { eventRaised = true; - args.Path.Should().Be(_filePath); + args.Path.ShouldBe(_filePath); }; // Act Act(); // Assert - eventRaised.Should().BeTrue(); + eventRaised.ShouldBeTrue(); } [Fact] @@ -89,8 +88,8 @@ public void CreateFile_adds_a_change_to_the_ChangeHistory() var change = _vfs.ChangeHistory.UndoStack.First(); // Assert - _vfs.ChangeHistory.UndoStack.Should().ContainEquivalentOf(change); - _vfs.ChangeHistory.UndoStack.Should().HaveCount(1); - _vfs.ChangeHistory.RedoStack.Should().BeEmpty(); + _vfs.ChangeHistory.UndoStack.ShouldContain(change); + _vfs.ChangeHistory.UndoStack.Count.ShouldBe(1); + _vfs.ChangeHistory.RedoStack.ShouldBeEmpty(); } } \ No newline at end of file diff --git a/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Commands/VirtualFileSystem_MethodDeleteDirectory_Tests.cs b/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Commands/VirtualFileSystem_MethodDeleteDirectory_Tests.cs index 499e492..8e0c913 100644 --- a/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Commands/VirtualFileSystem_MethodDeleteDirectory_Tests.cs +++ b/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Commands/VirtualFileSystem_MethodDeleteDirectory_Tests.cs @@ -18,7 +18,7 @@ public void DeleteDirectory_deletes_a_directory() Act(); // Assert - _vfs.IsEmpty.Should().BeTrue(); + _vfs.IsEmpty.ShouldBeTrue(); } [Fact] @@ -33,7 +33,7 @@ public void DeleteDirectory_deletes_a_directory_and_its_children() _vfs.DeleteDirectory(ancestorPath); // Assert - _vfs.IsEmpty.Should().BeTrue(); + _vfs.IsEmpty.ShouldBeTrue(); } [Fact] @@ -43,9 +43,8 @@ public void DeleteDirectory_throws_an_exception_if_the_directory_does_not_exist( var action = Act; // Assert - action.Should() - .Throw() - .WithMessage("The directory 'vfs://dir1' does not exist in the index."); + var ex = Should.Throw(action); + ex.Message.ShouldBe("The directory 'vfs://dir1' does not exist in the index."); } [Fact] @@ -58,9 +57,8 @@ public void DeleteDirectory_throws_an_exception_if_the_path_is_the_root_director var action = () => Act(); // Assert - action.Should() - .Throw() - .WithMessage("Cannot delete the root directory."); + var ex = Should.Throw(action); + ex.Message.ShouldBe("Cannot delete the root directory."); } [Fact] @@ -73,14 +71,14 @@ public void DeleteDirectory_raises_a_DirectoryDeleted_event() _vfs.DirectoryDeleted += args => { eventRaised = true; - args.Path.Should().Be(_directoryPath); + args.Path.ShouldBe(_directoryPath); }; // Act Act(); // Assert - eventRaised.Should().BeTrue(); + eventRaised.ShouldBeTrue(); } [Fact] @@ -96,8 +94,8 @@ public void DeleteDirectory_adds_a_change_to_the_ChangeHistory() var change = _vfs.ChangeHistory.UndoStack.First(); // Assert - _vfs.ChangeHistory.UndoStack.Should().ContainEquivalentOf(change); - _vfs.ChangeHistory.UndoStack.Should().HaveCount(2); - _vfs.ChangeHistory.RedoStack.Should().BeEmpty(); + _vfs.ChangeHistory.UndoStack.ShouldContain(change); + _vfs.ChangeHistory.UndoStack.Count.ShouldBe(2); + _vfs.ChangeHistory.RedoStack.ShouldBeEmpty(); } } \ No newline at end of file diff --git a/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Commands/VirtualFileSystem_MethodDeleteFile_Tests.cs b/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Commands/VirtualFileSystem_MethodDeleteFile_Tests.cs index d96ab96..a7dba31 100644 --- a/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Commands/VirtualFileSystem_MethodDeleteFile_Tests.cs +++ b/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Commands/VirtualFileSystem_MethodDeleteFile_Tests.cs @@ -18,7 +18,7 @@ public void DeleteFile_deletes_a_file() Act(); // Assert - _vfs.Index.Count.Should().Be(3); // dir1, dir2, dir3 + _vfs.Index.Count.ShouldBe(3); // dir1, dir2, dir3 } [Fact] @@ -28,9 +28,8 @@ public void DeleteFile_throws_an_exception_if_the_file_does_not_exist() var action = Act; // Assert - action.Should() - .Throw() - .WithMessage("The file 'vfs://dir1/dir2/dir3/file.txt' does not exist in the index."); + var ex = Should.Throw(action); + ex.Message.ShouldBe("The file 'vfs://dir1/dir2/dir3/file.txt' does not exist in the index."); } [Fact] @@ -43,7 +42,7 @@ public void DeleteFile_raises_a_FileDeleted_event() Act(); // Assert - _vfs.Index.Count.Should().Be(3); // dir1, dir2, dir3 + _vfs.Index.Count.ShouldBe(3); // dir1, dir2, dir3 } [Fact] @@ -59,8 +58,8 @@ public void DeleteFile_adds_a_change_to_the_ChangeHistory() var change = _vfs.ChangeHistory.UndoStack.First(); // Assert - _vfs.ChangeHistory.UndoStack.Should().ContainEquivalentOf(change); - _vfs.ChangeHistory.UndoStack.Should().HaveCount(5); - _vfs.ChangeHistory.RedoStack.Should().BeEmpty(); + _vfs.ChangeHistory.UndoStack.ShouldContain(change); + _vfs.ChangeHistory.UndoStack.Count.ShouldBe(5); + _vfs.ChangeHistory.RedoStack.ShouldBeEmpty(); } } \ No newline at end of file diff --git a/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Commands/VirtualFileSystem_MethodMoveDirectory_Tests.cs b/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Commands/VirtualFileSystem_MethodMoveDirectory_Tests.cs index 09af837..59fd7fa 100644 --- a/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Commands/VirtualFileSystem_MethodMoveDirectory_Tests.cs +++ b/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Commands/VirtualFileSystem_MethodMoveDirectory_Tests.cs @@ -20,8 +20,8 @@ public void MoveDirectory_moves_a_directory() Act(); // Assert - _vfs.Index.Count.Should().Be(indexLength); - _vfs.Index.RawIndex.Should().ContainKey(new VFSDirectoryPath("vfs://new_dir")); + _vfs.Index.Count.ShouldBe(indexLength); + _vfs.Index.RawIndex.ShouldContainKey(new VFSDirectoryPath("vfs://new_dir")); } [Fact] @@ -35,7 +35,7 @@ public void MoveDirectory_updates_the_directory_path() // Assert _vfs.Index[new VFSDirectoryPath("vfs://new_dir")].Path.Value - .Should().Be("vfs://new_dir"); + .ShouldBe("vfs://new_dir"); } [Fact] @@ -51,9 +51,9 @@ public void MoveDirectory_updates_the_last_write_time() Act(); // Assert - _vfs.Index[new VFSDirectoryPath("vfs://new_dir")].CreationTime.Should().Be(creationTime); - _vfs.Index[new VFSDirectoryPath("vfs://new_dir")].LastAccessTime.Should().Be(lastAccessTime); - _vfs.Index[new VFSDirectoryPath("vfs://new_dir")].LastWriteTime.Should().NotBe(lastWriteTime); + _vfs.Index[new VFSDirectoryPath("vfs://new_dir")].CreationTime.ShouldBe(creationTime); + _vfs.Index[new VFSDirectoryPath("vfs://new_dir")].LastAccessTime.ShouldBe(lastAccessTime); + _vfs.Index[new VFSDirectoryPath("vfs://new_dir")].LastWriteTime.ShouldNotBe(lastWriteTime); } [Fact] @@ -63,9 +63,8 @@ public void MoveDirectory_throws_an_exception_if_the_directory_does_not_exist() var action = Act; // Assert - action.Should() - .Throw() - .WithMessage("The directory 'vfs://dir1/dir2/dir3' does not exist in the index."); + var ex = Should.Throw(action); + ex.Message.ShouldBe("The directory 'vfs://dir1/dir2/dir3' does not exist in the index."); } [Fact] @@ -78,15 +77,15 @@ public void MoveDirectory_raises_a_DirectoryMoved_event() _vfs.DirectoryMoved += args => { eventRaised = true; - args.SourcePath.Should().Be(_directoryPath); - args.DestinationPath.Should().Be(_newDirectoryPath); + args.SourcePath.ShouldBe(_directoryPath); + args.DestinationPath.ShouldBe(_newDirectoryPath); }; // Act Act(); // Assert - eventRaised.Should().BeTrue(); + eventRaised.ShouldBeTrue(); } [Fact] @@ -102,8 +101,8 @@ public void MoveDirectory_adds_a_change_to_the_ChangeHistory() var change = _vfs.ChangeHistory.UndoStack.First(); // Assert - _vfs.ChangeHistory.UndoStack.Should().ContainEquivalentOf(change); - _vfs.ChangeHistory.UndoStack.Should().HaveCount(4); - _vfs.ChangeHistory.RedoStack.Should().BeEmpty(); + _vfs.ChangeHistory.UndoStack.ShouldContain(change); + _vfs.ChangeHistory.UndoStack.Count.ShouldBe(4); + _vfs.ChangeHistory.RedoStack.ShouldBeEmpty(); } } \ No newline at end of file diff --git a/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Commands/VirtualFileSystem_MethodMoveFile_Tests.cs b/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Commands/VirtualFileSystem_MethodMoveFile_Tests.cs index 372cbb1..2a6f3e1 100644 --- a/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Commands/VirtualFileSystem_MethodMoveFile_Tests.cs +++ b/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Commands/VirtualFileSystem_MethodMoveFile_Tests.cs @@ -17,8 +17,8 @@ public void MoveFile_moves_a_file() _vfs.MoveFile(_filePath, _newFilePath); // Assert - _vfs.Index.Count.Should().Be(indexLength); - _vfs.Index.RawIndex.Should().ContainKey(new VFSFilePath("vfs://new_file.txt")); + _vfs.Index.Count.ShouldBe(indexLength); + _vfs.Index.RawIndex.ShouldContainKey(new VFSFilePath("vfs://new_file.txt")); } [Fact] @@ -32,7 +32,7 @@ public void MoveFile_updates_the_file_path() // Assert _vfs.Index[new VFSFilePath("vfs://new_file.txt")].Path.Value - .Should().Be("vfs://new_file.txt"); + .ShouldBe("vfs://new_file.txt"); } [Fact] @@ -48,9 +48,9 @@ public void MoveFile_updates_the_last_write_time() _vfs.MoveFile(_filePath, _newFilePath); // Assert - _vfs.Index[new VFSFilePath("vfs://new_file.txt")].CreationTime.Should().Be(creationTime); - _vfs.Index[new VFSFilePath("vfs://new_file.txt")].LastAccessTime.Should().Be(lastAccessTime); - _vfs.Index[new VFSFilePath("vfs://new_file.txt")].LastWriteTime.Should().NotBe(lastWriteTime); + _vfs.Index[new VFSFilePath("vfs://new_file.txt")].CreationTime.ShouldBe(creationTime); + _vfs.Index[new VFSFilePath("vfs://new_file.txt")].LastAccessTime.ShouldBe(lastAccessTime); + _vfs.Index[new VFSFilePath("vfs://new_file.txt")].LastWriteTime.ShouldNotBe(lastWriteTime); } [Fact] @@ -60,9 +60,8 @@ public void MoveFile_throws_an_exception_if_the_file_does_not_exist() Action action = () => _vfs.MoveFile(_filePath, _newFilePath); // Assert - action.Should() - .Throw() - .WithMessage("The file 'vfs://dir1/dir2/dir3/file.txt' does not exist in the index."); + var ex = Should.Throw(action); + ex.Message.ShouldBe("The file 'vfs://dir1/dir2/dir3/file.txt' does not exist in the index."); } [Fact] @@ -75,15 +74,15 @@ public void MoveFile_raises_a_FileMoved_event() _vfs.FileMoved += args => { eventRaised = true; - args.SourcePath.Should().Be(_filePath); - args.DestinationPath.Should().Be(_newFilePath); + args.SourcePath.ShouldBe(_filePath); + args.DestinationPath.ShouldBe(_newFilePath); }; // Act _vfs.MoveFile(_filePath, _newFilePath); // Assert - eventRaised.Should().BeTrue(); + eventRaised.ShouldBeTrue(); } [Fact] @@ -99,8 +98,8 @@ public void MoveFile_adds_a_change_to_the_ChangeHistory() var change = _vfs.ChangeHistory.UndoStack.First(); // Assert - _vfs.ChangeHistory.UndoStack.Should().ContainEquivalentOf(change); - _vfs.ChangeHistory.UndoStack.Should().HaveCount(5); - _vfs.ChangeHistory.RedoStack.Should().BeEmpty(); + _vfs.ChangeHistory.UndoStack.ShouldContain(change); + _vfs.ChangeHistory.UndoStack.Count.ShouldBe(5); + _vfs.ChangeHistory.RedoStack.ShouldBeEmpty(); } } \ No newline at end of file diff --git a/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Commands/VirtualFileSystem_MethodRenameDirectory_Tests.cs b/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Commands/VirtualFileSystem_MethodRenameDirectory_Tests.cs index d99c158..b99d226 100644 --- a/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Commands/VirtualFileSystem_MethodRenameDirectory_Tests.cs +++ b/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Commands/VirtualFileSystem_MethodRenameDirectory_Tests.cs @@ -21,11 +21,11 @@ public void RenameDirectory_renames_a_directory() Act(); // Assert - _vfs.Index.Count.Should().Be(indexLength); - _vfs.Index.RawIndex.Should().NotContainKey(new VFSDirectoryPath("vfs://dir1/dir2/dir3")); - _vfs.Index.RawIndex.Should().ContainKey(new VFSDirectoryPath("vfs://dir1/dir2/new_dir")); - _vfs.Index[new VFSDirectoryPath("vfs://dir1/dir2/new_dir")].IsDirectory.Should().BeTrue(); - _vfs.GetTree().Should().NotBe(tree); + _vfs.Index.Count.ShouldBe(indexLength); + _vfs.Index.RawIndex.ShouldNotContainKey(new VFSDirectoryPath("vfs://dir1/dir2/dir3")); + _vfs.Index.RawIndex.ShouldContainKey(new VFSDirectoryPath("vfs://dir1/dir2/new_dir")); + _vfs.Index[new VFSDirectoryPath("vfs://dir1/dir2/new_dir")].IsDirectory.ShouldBeTrue(); + _vfs.GetTree().ShouldNotBe(tree); } [Fact] @@ -39,7 +39,7 @@ public void RenameDirectory_updates_the_directory_path() // Assert _vfs.Index[new VFSDirectoryPath("vfs://dir1/dir2/new_dir")].Path.Value - .Should().Be("vfs://dir1/dir2/new_dir"); + .ShouldBe("vfs://dir1/dir2/new_dir"); } [Fact] @@ -56,9 +56,9 @@ public void RenameDirectory_updates_the_last_write_time() Act(); // Assert - _vfs.Index[new VFSDirectoryPath("vfs://dir1/dir2/new_dir")].CreationTime.Should().Be(creationTime); - _vfs.Index[new VFSDirectoryPath("vfs://dir1/dir2/new_dir")].LastAccessTime.Should().Be(lastAccessTime); - _vfs.Index[new VFSDirectoryPath("vfs://dir1/dir2/new_dir")].LastWriteTime.Should().NotBe(lastWriteTime); + _vfs.Index[new VFSDirectoryPath("vfs://dir1/dir2/new_dir")].CreationTime.ShouldBe(creationTime); + _vfs.Index[new VFSDirectoryPath("vfs://dir1/dir2/new_dir")].LastAccessTime.ShouldBe(lastAccessTime); + _vfs.Index[new VFSDirectoryPath("vfs://dir1/dir2/new_dir")].LastWriteTime.ShouldNotBe(lastWriteTime); } [Fact] @@ -68,9 +68,8 @@ public void RenameDirectory_throws_an_exception_if_the_directory_does_not_exist( Action action = () => Act(); // Assert - action.Should() - .Throw() - .WithMessage("The directory 'vfs://dir1/dir2/dir3' does not exist in the index."); + var ex = Should.Throw(action); + ex.Message.ShouldBe("The directory 'vfs://dir1/dir2/dir3' does not exist in the index."); } [Fact] @@ -83,15 +82,15 @@ public void RenameDirectory_raises_a_DirectoryRenamed_event() _vfs.DirectoryRenamed += args => { eventRaised = true; - args.Path.Should().Be(_directoryPath); - args.NewName.Should().Be("new_dir"); + args.Path.ShouldBe(_directoryPath); + args.NewName.ShouldBe("new_dir"); }; // Act Act(); // Assert - eventRaised.Should().BeTrue(); + eventRaised.ShouldBeTrue(); } [Fact] @@ -110,12 +109,12 @@ public void RenameDirectory_event_args_contain_correct_paths() Act(); // Assert - capturedArgs.Should().NotBeNull(); - capturedArgs!.Path.Should().Be(new VFSDirectoryPath("vfs://dir1/dir2/dir3")); - capturedArgs.OldName.Should().Be("dir3"); - capturedArgs.NewName.Should().Be("new_dir"); - capturedArgs.NewPath.Should().Be(new VFSDirectoryPath("vfs://dir1/dir2/new_dir")); - capturedArgs.Timestamp.Should().BeCloseTo(DateTimeOffset.Now, TimeSpan.FromSeconds(1)); + capturedArgs.ShouldNotBeNull(); + capturedArgs!.Path.ShouldBe(new VFSDirectoryPath("vfs://dir1/dir2/dir3")); + capturedArgs.OldName.ShouldBe("dir3"); + capturedArgs.NewName.ShouldBe("new_dir"); + capturedArgs.NewPath.ShouldBe(new VFSDirectoryPath("vfs://dir1/dir2/new_dir")); + (DateTimeOffset.Now - capturedArgs.Timestamp).ShouldBeLessThan(TimeSpan.FromSeconds(1)); } [Fact] @@ -131,9 +130,9 @@ public void RenameDirectory_adds_a_change_to_the_ChangeHistory() var change = _vfs.ChangeHistory.UndoStack.First(); // Assert - _vfs.ChangeHistory.UndoStack.Should().ContainEquivalentOf(change); - _vfs.ChangeHistory.UndoStack.Should().HaveCount(4); - _vfs.ChangeHistory.RedoStack.Should().BeEmpty(); + _vfs.ChangeHistory.UndoStack.ShouldContain(change); + _vfs.ChangeHistory.UndoStack.Count.ShouldBe(4); + _vfs.ChangeHistory.RedoStack.ShouldBeEmpty(); } [Fact] @@ -148,22 +147,22 @@ public void RenameDirectory_can_be_undone_and_redone() Act(); // Assert - Directory should be renamed - _vfs.Index.RawIndex.Should().NotContainKey(originalPath); - _vfs.Index.RawIndex.Should().ContainKey(newPath); + _vfs.Index.RawIndex.ShouldNotContainKey(originalPath); + _vfs.Index.RawIndex.ShouldContainKey(newPath); // Act - Undo rename _vfs.ChangeHistory.Undo(); // Assert - Directory should be back to original name - _vfs.Index.RawIndex.Should().ContainKey(originalPath); - _vfs.Index.RawIndex.Should().NotContainKey(newPath); + _vfs.Index.RawIndex.ShouldContainKey(originalPath); + _vfs.Index.RawIndex.ShouldNotContainKey(newPath); // Act - Redo rename _vfs.ChangeHistory.Redo(); // Assert - Directory should be renamed again - _vfs.Index.RawIndex.Should().NotContainKey(originalPath); - _vfs.Index.RawIndex.Should().ContainKey(newPath); + _vfs.Index.RawIndex.ShouldNotContainKey(originalPath); + _vfs.Index.RawIndex.ShouldContainKey(newPath); } [Fact] @@ -182,25 +181,25 @@ public void RenameDirectory_updates_nested_file_paths() Act(); // Assert - _vfs.Index.Count.Should().Be(indexLength); + _vfs.Index.Count.ShouldBe(indexLength); // Verify old paths no longer exist - _vfs.Index.RawIndex.Should().NotContainKey(nestedFilePath); - _vfs.Index.RawIndex.Should().NotContainKey(deepNestedFilePath); + _vfs.Index.RawIndex.ShouldNotContainKey(nestedFilePath); + _vfs.Index.RawIndex.ShouldNotContainKey(deepNestedFilePath); // Verify new paths exist var newNestedFilePath = new VFSFilePath("dir1/dir2/new_dir/file.txt"); var newDeepNestedFilePath = new VFSFilePath("dir1/dir2/new_dir/subdir/nested.txt"); - _vfs.Index.RawIndex.Should().ContainKey(newNestedFilePath); - _vfs.Index.RawIndex.Should().ContainKey(newDeepNestedFilePath); + _vfs.Index.RawIndex.ShouldContainKey(newNestedFilePath); + _vfs.Index.RawIndex.ShouldContainKey(newDeepNestedFilePath); // Verify file contents are preserved - _vfs.Index[newNestedFilePath].As().Content.Should().Be("content1"); - _vfs.Index[newDeepNestedFilePath].As().Content.Should().Be("content2"); + _vfs.Index[newNestedFilePath].ShouldBeAssignableTo()!.Content.ShouldBe("content1"); + _vfs.Index[newDeepNestedFilePath].ShouldBeAssignableTo()!.Content.ShouldBe("content2"); // Verify file paths are updated - _vfs.Index[newNestedFilePath].Path.Value.Should().Be("vfs://dir1/dir2/new_dir/file.txt"); - _vfs.Index[newDeepNestedFilePath].Path.Value.Should().Be("vfs://dir1/dir2/new_dir/subdir/nested.txt"); + _vfs.Index[newNestedFilePath].Path.Value.ShouldBe("vfs://dir1/dir2/new_dir/file.txt"); + _vfs.Index[newDeepNestedFilePath].Path.Value.ShouldBe("vfs://dir1/dir2/new_dir/subdir/nested.txt"); } [Fact] @@ -240,17 +239,17 @@ public void RenameDirectory_handles_deeply_nested_structure() _vfs.RenameDirectory(pathToRename, "renamed_c"); // Assert - _vfs.Index.Count.Should().Be(indexLength); + _vfs.Index.Count.ShouldBe(indexLength); // Verify old paths no longer exist - _vfs.Index.RawIndex.Should().NotContainKey(new VFSDirectoryPath("vfs://a/b/c")); - _vfs.Index.RawIndex.Should().NotContainKey(fileAtC); - _vfs.Index.RawIndex.Should().NotContainKey(fileAtD); - _vfs.Index.RawIndex.Should().NotContainKey(fileAtE); - _vfs.Index.RawIndex.Should().NotContainKey(subdirAtC); - _vfs.Index.RawIndex.Should().NotContainKey(subdirAtE); - _vfs.Index.RawIndex.Should().NotContainKey(fileInSubdirC); - _vfs.Index.RawIndex.Should().NotContainKey(fileInSubdirE); + _vfs.Index.RawIndex.ShouldNotContainKey(new VFSDirectoryPath("vfs://a/b/c")); + _vfs.Index.RawIndex.ShouldNotContainKey(fileAtC); + _vfs.Index.RawIndex.ShouldNotContainKey(fileAtD); + _vfs.Index.RawIndex.ShouldNotContainKey(fileAtE); + _vfs.Index.RawIndex.ShouldNotContainKey(subdirAtC); + _vfs.Index.RawIndex.ShouldNotContainKey(subdirAtE); + _vfs.Index.RawIndex.ShouldNotContainKey(fileInSubdirC); + _vfs.Index.RawIndex.ShouldNotContainKey(fileInSubdirE); // Verify new paths exist var newFileAtC = new VFSFilePath("a/b/renamed_c/file_c.txt"); @@ -261,34 +260,34 @@ public void RenameDirectory_handles_deeply_nested_structure() var newFileInSubdirC = new VFSFilePath("a/b/renamed_c/subdir_c/nested.txt"); var newFileInSubdirE = new VFSFilePath("a/b/renamed_c/d/e/subdir_e/deep.txt"); - _vfs.Index.RawIndex.Should().ContainKey(new VFSDirectoryPath("vfs://a/b/renamed_c")); - _vfs.Index.RawIndex.Should().ContainKey(newFileAtC); - _vfs.Index.RawIndex.Should().ContainKey(newFileAtD); - _vfs.Index.RawIndex.Should().ContainKey(newFileAtE); - _vfs.Index.RawIndex.Should().ContainKey(newSubdirAtC); - _vfs.Index.RawIndex.Should().ContainKey(newSubdirAtE); - _vfs.Index.RawIndex.Should().ContainKey(newFileInSubdirC); - _vfs.Index.RawIndex.Should().ContainKey(newFileInSubdirE); + _vfs.Index.RawIndex.ShouldContainKey(new VFSDirectoryPath("vfs://a/b/renamed_c")); + _vfs.Index.RawIndex.ShouldContainKey(newFileAtC); + _vfs.Index.RawIndex.ShouldContainKey(newFileAtD); + _vfs.Index.RawIndex.ShouldContainKey(newFileAtE); + _vfs.Index.RawIndex.ShouldContainKey(newSubdirAtC); + _vfs.Index.RawIndex.ShouldContainKey(newSubdirAtE); + _vfs.Index.RawIndex.ShouldContainKey(newFileInSubdirC); + _vfs.Index.RawIndex.ShouldContainKey(newFileInSubdirE); // Verify file contents are preserved - _vfs.Index[fileAtB].As().Content.Should().Be("content_b"); // Not affected by rename - _vfs.Index[newFileAtC].As().Content.Should().Be("content_c"); - _vfs.Index[newFileAtD].As().Content.Should().Be("content_d"); - _vfs.Index[newFileAtE].As().Content.Should().Be("content_e"); - _vfs.Index[newFileInSubdirC].As().Content.Should().Be("nested_content"); - _vfs.Index[newFileInSubdirE].As().Content.Should().Be("deep_content"); + _vfs.Index[fileAtB].ShouldBeAssignableTo()!.Content.ShouldBe("content_b"); // Not affected by rename + _vfs.Index[newFileAtC].ShouldBeAssignableTo()!.Content.ShouldBe("content_c"); + _vfs.Index[newFileAtD].ShouldBeAssignableTo()!.Content.ShouldBe("content_d"); + _vfs.Index[newFileAtE].ShouldBeAssignableTo()!.Content.ShouldBe("content_e"); + _vfs.Index[newFileInSubdirC].ShouldBeAssignableTo()!.Content.ShouldBe("nested_content"); + _vfs.Index[newFileInSubdirE].ShouldBeAssignableTo()!.Content.ShouldBe("deep_content"); // Verify file paths are correctly updated - _vfs.Index[newFileAtC].Path.Value.Should().Be("vfs://a/b/renamed_c/file_c.txt"); - _vfs.Index[newFileAtD].Path.Value.Should().Be("vfs://a/b/renamed_c/d/file_d.txt"); - _vfs.Index[newFileAtE].Path.Value.Should().Be("vfs://a/b/renamed_c/d/e/file_e.txt"); - _vfs.Index[newFileInSubdirC].Path.Value.Should().Be("vfs://a/b/renamed_c/subdir_c/nested.txt"); - _vfs.Index[newFileInSubdirE].Path.Value.Should().Be("vfs://a/b/renamed_c/d/e/subdir_e/deep.txt"); + _vfs.Index[newFileAtC].Path.Value.ShouldBe("vfs://a/b/renamed_c/file_c.txt"); + _vfs.Index[newFileAtD].Path.Value.ShouldBe("vfs://a/b/renamed_c/d/file_d.txt"); + _vfs.Index[newFileAtE].Path.Value.ShouldBe("vfs://a/b/renamed_c/d/e/file_e.txt"); + _vfs.Index[newFileInSubdirC].Path.Value.ShouldBe("vfs://a/b/renamed_c/subdir_c/nested.txt"); + _vfs.Index[newFileInSubdirE].Path.Value.ShouldBe("vfs://a/b/renamed_c/d/e/subdir_e/deep.txt"); // Verify directory paths are correctly updated - _vfs.Index[new VFSDirectoryPath("vfs://a/b/renamed_c")].Path.Value.Should().Be("vfs://a/b/renamed_c"); - _vfs.Index[newSubdirAtC].Path.Value.Should().Be("vfs://a/b/renamed_c/subdir_c"); - _vfs.Index[newSubdirAtE].Path.Value.Should().Be("vfs://a/b/renamed_c/d/e/subdir_e"); + _vfs.Index[new VFSDirectoryPath("vfs://a/b/renamed_c")].Path.Value.ShouldBe("vfs://a/b/renamed_c"); + _vfs.Index[newSubdirAtC].Path.Value.ShouldBe("vfs://a/b/renamed_c/subdir_c"); + _vfs.Index[newSubdirAtE].Path.Value.ShouldBe("vfs://a/b/renamed_c/d/e/subdir_e"); } [Fact] @@ -305,8 +304,7 @@ public void RenameDirectory_throws_exception_when_target_name_already_exists() ); // Assert - action.Should() - .Throw() - .WithMessage("The node 'vfs://dir1/dir2/existing' already exists in the index."); + var ex = Should.Throw(action); + ex.Message.ShouldBe("The node 'vfs://dir1/dir2/existing' already exists in the index."); } } \ No newline at end of file diff --git a/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Commands/VirtualFileSystem_MethodRenameFile_Tests.cs b/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Commands/VirtualFileSystem_MethodRenameFile_Tests.cs index 1bf3dd3..6acd6ef 100644 --- a/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Commands/VirtualFileSystem_MethodRenameFile_Tests.cs +++ b/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Commands/VirtualFileSystem_MethodRenameFile_Tests.cs @@ -21,11 +21,11 @@ public void RenameFile_renames_a_file() Act(); // Assert - _vfs.Index.Count.Should().Be(indexLength); - _vfs.Index.RawIndex.Should().NotContainKey(new VFSFilePath("vfs://dir1/dir2/dir3/file.txt")); - _vfs.Index.RawIndex.Should().ContainKey(new VFSFilePath("vfs://dir1/dir2/dir3/new_file.txt")); - _vfs.Index[new VFSFilePath("vfs://dir1/dir2/dir3/new_file.txt")].IsFile.Should().BeTrue(); - _vfs.GetTree().Should().NotBe(tree); + _vfs.Index.Count.ShouldBe(indexLength); + _vfs.Index.RawIndex.ShouldNotContainKey(new VFSFilePath("vfs://dir1/dir2/dir3/file.txt")); + _vfs.Index.RawIndex.ShouldContainKey(new VFSFilePath("vfs://dir1/dir2/dir3/new_file.txt")); + _vfs.Index[new VFSFilePath("vfs://dir1/dir2/dir3/new_file.txt")].IsFile.ShouldBeTrue(); + _vfs.GetTree().ShouldNotBe(tree); } [Fact] @@ -39,7 +39,7 @@ public void RenameFile_updates_the_file_path() // Assert _vfs.Index[new VFSFilePath("vfs://dir1/dir2/dir3/new_file.txt")].Path.Value - .Should().Be("vfs://dir1/dir2/dir3/new_file.txt"); + .ShouldBe("vfs://dir1/dir2/dir3/new_file.txt"); } [Fact] @@ -56,9 +56,9 @@ public void RenameFile_updates_the_last_write_time() Act(); // Assert - _vfs.Index[new VFSFilePath("vfs://dir1/dir2/dir3/new_file.txt")].CreationTime.Should().Be(creationTime); - _vfs.Index[new VFSFilePath("vfs://dir1/dir2/dir3/new_file.txt")].LastAccessTime.Should().Be(lastAccessTime); - _vfs.Index[new VFSFilePath("vfs://dir1/dir2/dir3/new_file.txt")].LastWriteTime.Should().NotBe(lastWriteTime); + _vfs.Index[new VFSFilePath("vfs://dir1/dir2/dir3/new_file.txt")].CreationTime.ShouldBe(creationTime); + _vfs.Index[new VFSFilePath("vfs://dir1/dir2/dir3/new_file.txt")].LastAccessTime.ShouldBe(lastAccessTime); + _vfs.Index[new VFSFilePath("vfs://dir1/dir2/dir3/new_file.txt")].LastWriteTime.ShouldNotBe(lastWriteTime); } [Fact] @@ -68,9 +68,8 @@ public void RenameFile_throws_an_exception_if_the_file_does_not_exist() Action action = () => Act(); // Assert - action.Should() - .Throw() - .WithMessage("The file 'vfs://dir1/dir2/dir3/file.txt' does not exist in the index."); + var ex = Should.Throw(action); + ex.Message.ShouldBe("The file 'vfs://dir1/dir2/dir3/file.txt' does not exist in the index."); } [Fact] @@ -83,15 +82,15 @@ public void RenameFile_raises_a_FileRenamed_event() _vfs.FileRenamed += args => { eventRaised = true; - args.Path.Should().Be(_filePath); - args.NewName.Should().Be("vfs://dir1/dir2/dir3/new_file.txt"); + args.Path.ShouldBe(_filePath); + args.NewName.ShouldBe("vfs://dir1/dir2/dir3/new_file.txt"); }; // Act Act(); // Assert - eventRaised.Should().BeTrue(); + eventRaised.ShouldBeTrue(); } [Fact] @@ -107,8 +106,8 @@ public void RenameFile_adds_a_change_to_the_ChangeHistory() var change = _vfs.ChangeHistory.UndoStack.First(); // Assert - _vfs.ChangeHistory.UndoStack.Should().ContainEquivalentOf(change); - _vfs.ChangeHistory.UndoStack.Should().HaveCount(5); - _vfs.ChangeHistory.RedoStack.Should().BeEmpty(); + _vfs.ChangeHistory.UndoStack.ShouldContain(change); + _vfs.ChangeHistory.UndoStack.Count.ShouldBe(5); + _vfs.ChangeHistory.RedoStack.ShouldBeEmpty(); } } \ No newline at end of file diff --git a/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Queries/VirtualFileSystem_MethodFindDirectories_Tests.cs b/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Queries/VirtualFileSystem_MethodFindDirectories_Tests.cs index dcc596d..dd09ee9 100644 --- a/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Queries/VirtualFileSystem_MethodFindDirectories_Tests.cs +++ b/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Queries/VirtualFileSystem_MethodFindDirectories_Tests.cs @@ -17,11 +17,11 @@ public void FindDirectories_returns_all_directories() var directories = vfs.Directories.ToList(); // Assert - directories.Should().NotBeEmpty(); - directories.Should().HaveCount(3); // dir1 + dir2 + dir3 - directories.Should().Contain(d => d.Path.Value == "vfs://dir1"); - directories.Should().Contain(d => d.Path.Value == "vfs://dir2"); - directories.Should().Contain(d => d.Path.Value == "vfs://dir3"); + directories.ShouldNotBeEmpty(); + directories.Count.ShouldBe(3); // dir1 + dir2 + dir3 + directories.ShouldContain(d => d.Path.Value == "vfs://dir1"); + directories.ShouldContain(d => d.Path.Value == "vfs://dir2"); + directories.ShouldContain(d => d.Path.Value == "vfs://dir3"); } [Fact] @@ -38,8 +38,8 @@ public void FindDirectories_returns_all_directories_matching_a_pattern() var directories = vfs.FindDirectories(regexPattern).ToList(); // Assert - directories.Should().NotBeEmpty(); - directories.Should().HaveCount(1); - directories.Should().Contain(d => d.Path.Value == "vfs://dir1"); + directories.ShouldNotBeEmpty(); + directories.Count.ShouldBe(1); + directories.ShouldContain(d => d.Path.Value == "vfs://dir1"); } } \ No newline at end of file diff --git a/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Queries/VirtualFileSystem_MethodFindFiles_Tests.cs b/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Queries/VirtualFileSystem_MethodFindFiles_Tests.cs index 0efb58f..34ed61d 100644 --- a/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Queries/VirtualFileSystem_MethodFindFiles_Tests.cs +++ b/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Queries/VirtualFileSystem_MethodFindFiles_Tests.cs @@ -20,11 +20,11 @@ public void FindFiles_returns_all_files() var files = vfs.Files.ToList(); // Assert - files.Should().NotBeEmpty(); - files.Should().HaveCount(3); - files.Should().Contain(f => f.Path.Value == "vfs://dir1/file1.txt"); - files.Should().Contain(f => f.Path.Value == "vfs://dir2/file2.txt"); - files.Should().Contain(f => f.Path.Value == "vfs://dir3/file3.txt"); + files.ShouldNotBeEmpty(); + files.Count.ShouldBe(3); + files.ShouldContain(f => f.Path.Value == "vfs://dir1/file1.txt"); + files.ShouldContain(f => f.Path.Value == "vfs://dir2/file2.txt"); + files.ShouldContain(f => f.Path.Value == "vfs://dir3/file3.txt"); } [Fact] @@ -42,15 +42,15 @@ public void FindFiles_with_valid_data_returns_a_list_of_files_with_content_and_n var files = vfs.FindFiles(regex).ToList(); // Assert - files.Should().NotBeNull(); - files.Count.Should().Be(3); - files[0].Name.Should().Be("file1.txt"); - files[0].Content.Should().Be("content1"); - files[1].Name.Should().Be("file2.txt"); - files[1].Content.Should().Be("content2"); - files[2].Name.Should().Be("file3.txt"); - files[2].Content.Should().Be("content3"); + files.ShouldNotBeNull(); + files.Count.ShouldBe(3); + files[0].Name.ShouldBe("file1.txt"); + files[0].Content.ShouldBe("content1"); + files[1].Name.ShouldBe("file2.txt"); + files[1].Content.ShouldBe("content2"); + files[2].Name.ShouldBe("file3.txt"); + files[2].Content.ShouldBe("content3"); // Assert Index - vfs.Index.Count.Should().Be(3); // file1, file2, file3 + vfs.Index.Count.ShouldBe(3); // file1, file2, file3 } } \ No newline at end of file diff --git a/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Queries/VirtualFileSystem_MethodGetDirectory_Tests.cs b/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Queries/VirtualFileSystem_MethodGetDirectory_Tests.cs index 596ec62..e72a53d 100644 --- a/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Queries/VirtualFileSystem_MethodGetDirectory_Tests.cs +++ b/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Queries/VirtualFileSystem_MethodGetDirectory_Tests.cs @@ -13,8 +13,8 @@ public void GetDirectory_returns_the_root_directory() var root = vfs.GetDirectory(rootPath); // Assert - root.Should().NotBeNull(); - root.Path.Value.Should().Be("vfs://"); + root.ShouldNotBeNull(); + root.Path.Value.ShouldBe("vfs://"); } [Fact] @@ -29,8 +29,8 @@ public void GetDirectory_returns_a_directory() var directory = vfs.GetDirectory(directoryPath); // Assert - directory.Should().NotBeNull(); - directory.Path.Value.Should().Be("vfs://dir1/dir2/dir3"); + directory.ShouldNotBeNull(); + directory.Path.Value.ShouldBe("vfs://dir1/dir2/dir3"); } [Fact] @@ -44,6 +44,6 @@ public void GetDirectory_throws_an_exception_if_the_directory_does_not_exist() Action action = () => vfs.GetDirectory(directoryPath); // Assert - action.Should().Throw(); + Should.Throw(action); } } \ No newline at end of file diff --git a/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Queries/VirtualFileSystem_MethodGetFile_Tests.cs b/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Queries/VirtualFileSystem_MethodGetFile_Tests.cs index edad58c..7ce21e5 100644 --- a/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Queries/VirtualFileSystem_MethodGetFile_Tests.cs +++ b/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Queries/VirtualFileSystem_MethodGetFile_Tests.cs @@ -14,8 +14,8 @@ public void GetFile_returns_the_file() var file = vfs.GetFile(filePath); // Assert - file.Should().NotBeNull(); - file.Path.Value.Should().Be("vfs://dir1/dir2/dir3/file.txt"); + file.ShouldNotBeNull(); + file.Path.Value.ShouldBe("vfs://dir1/dir2/dir3/file.txt"); } [Fact] @@ -29,6 +29,6 @@ public void GetFile_throws_an_exception_if_the_file_does_not_exist() Action action = () => vfs.GetFile(filePath); // Assert - action.Should().Throw(); + Should.Throw(action); } } \ No newline at end of file diff --git a/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Queries/VirtualFileSystem_MethodGetRootPath_Tests.cs b/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Queries/VirtualFileSystem_MethodGetRootPath_Tests.cs index 046e054..eaebe71 100644 --- a/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Queries/VirtualFileSystem_MethodGetRootPath_Tests.cs +++ b/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Queries/VirtualFileSystem_MethodGetRootPath_Tests.cs @@ -12,7 +12,7 @@ public void GetRootPath_returns_the_root_path() var rootPath = vfs.RootPath; // Assert - rootPath.Should().NotBeNull(); - rootPath.Value.Should().Be("vfs://"); + rootPath.ShouldNotBeNull(); + rootPath.Value.ShouldBe("vfs://"); } } \ No newline at end of file diff --git a/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Queries/VirtualFileSystem_MethodGetTree_Tests.cs b/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Queries/VirtualFileSystem_MethodGetTree_Tests.cs index c680e07..26983fa 100644 --- a/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Queries/VirtualFileSystem_MethodGetTree_Tests.cs +++ b/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Queries/VirtualFileSystem_MethodGetTree_Tests.cs @@ -12,7 +12,7 @@ public void GetTree_returns_root_directory() var result = vfs.GetTree(); // Assert - result.Should().Be("vfs://"); + result.ShouldBe("vfs://"); } [Fact] @@ -35,7 +35,7 @@ public void GetTree_returns_3_files_as_ASCII_tree() var result = vfs.GetTree(); // Assert - result.Should().Be(expected); + result.ShouldBe(expected); } [Fact] @@ -58,7 +58,7 @@ public void GetTree_returns_3_directories_as_ASCII_tree() var result = vfs.GetTree(); // Assert - result.Should().Be(expected); + result.ShouldBe(expected); } [Fact] @@ -99,7 +99,7 @@ public void GetTree_returns_3_files_and_3_directories_as_ASCII_tree() var result = vfs.GetTree(); // Assert - result.Should().Be(expected); + result.ShouldBe(expected); } [Fact] @@ -164,6 +164,6 @@ public void GetTree_returns_a_complex_tree() var result = vfs.GetTree(); // Assert - result.Should().Be(expected); + result.ShouldBe(expected); } } \ No newline at end of file diff --git a/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Queries/VirtualFileSystem_MethodSelectDirectories_Tests.cs b/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Queries/VirtualFileSystem_MethodSelectDirectories_Tests.cs index 55152c9..723c40f 100644 --- a/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Queries/VirtualFileSystem_MethodSelectDirectories_Tests.cs +++ b/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Queries/VirtualFileSystem_MethodSelectDirectories_Tests.cs @@ -17,10 +17,10 @@ public void SelectDirectories_returns_all_directories() .ToList(); // Assert - directories.Should().NotBeEmpty(); - directories.Should().HaveCount(3); // dir1 + dir2 + dir3 - directories.Should().Contain(d => d.Path.Value == "vfs://dir1"); - directories.Should().Contain(d => d.Path.Value == "vfs://dir2"); - directories.Should().Contain(d => d.Path.Value == "vfs://dir3"); + directories.ShouldNotBeEmpty(); + directories.Count.ShouldBe(3); // dir1 + dir2 + dir3 + directories.ShouldContain(d => d.Path.Value == "vfs://dir1"); + directories.ShouldContain(d => d.Path.Value == "vfs://dir2"); + directories.ShouldContain(d => d.Path.Value == "vfs://dir3"); } } \ No newline at end of file diff --git a/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Queries/VirtualFileSystem_MethodTryGetDirectory_Tests.cs b/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Queries/VirtualFileSystem_MethodTryGetDirectory_Tests.cs index 91a1bfc..88325ed 100644 --- a/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Queries/VirtualFileSystem_MethodTryGetDirectory_Tests.cs +++ b/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Queries/VirtualFileSystem_MethodTryGetDirectory_Tests.cs @@ -14,9 +14,9 @@ public void TryGetDirectory_returns_true_if_the_directory_exists() var result = vfs.TryGetDirectory(directoryPath, out var directory); // Assert - result.Should().BeTrue(); - directory.Should().NotBeNull(); - directory!.Path.Value.Should().Be("vfs://dir1/dir2/dir3"); + result.ShouldBeTrue(); + directory.ShouldNotBeNull(); + directory!.Path.Value.ShouldBe("vfs://dir1/dir2/dir3"); } [Fact] @@ -30,7 +30,7 @@ public void TryGetDirectory_returns_false_if_the_directory_does_not_exist() var result = vfs.TryGetDirectory(directoryPath, out var directory); // Assert - result.Should().BeFalse(); - directory.Should().BeNull(); + result.ShouldBeFalse(); + directory.ShouldBeNull(); } } \ No newline at end of file diff --git a/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Queries/VirtualFileSystem_MethodTryGetFile_Tests.cs b/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Queries/VirtualFileSystem_MethodTryGetFile_Tests.cs index 5c45059..d5f481f 100644 --- a/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Queries/VirtualFileSystem_MethodTryGetFile_Tests.cs +++ b/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/Queries/VirtualFileSystem_MethodTryGetFile_Tests.cs @@ -14,9 +14,9 @@ public void TryGetFile_returns_the_file() var result = vfs.TryGetFile(filePath, out var file); // Assert - result.Should().BeTrue(); - file.Should().NotBeNull(); - file!.Path.Value.Should().Be("vfs://dir1/dir2/dir3/file.txt"); + result.ShouldBeTrue(); + file.ShouldNotBeNull(); + file!.Path.Value.ShouldBe("vfs://dir1/dir2/dir3/file.txt"); } [Fact] @@ -30,7 +30,7 @@ public void TryGetFile_returns_false_if_the_file_does_not_exist() var result = vfs.TryGetFile(filePath, out var file); // Assert - result.Should().BeFalse(); - file.Should().BeNull(); + result.ShouldBeFalse(); + file.ShouldBeNull(); } } \ No newline at end of file diff --git a/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/VirtualFileSystemFactoryTests.cs b/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/VirtualFileSystemFactoryTests.cs index 8e10044..f65c6d6 100644 --- a/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/VirtualFileSystemFactoryTests.cs +++ b/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/VirtualFileSystemFactoryTests.cs @@ -17,7 +17,7 @@ public void Constructor_create_a_virtual_file_system_factory() var virtualFileSystemFactory = new VirtualFileSystemFactory(); // Assert - virtualFileSystemFactory.Should().NotBeNull(); + virtualFileSystemFactory.ShouldNotBeNull(); } } @@ -33,9 +33,9 @@ public void CreateFileSystem_create_a_virtual_file_system() var virtualFileSystem = virtualFileSystemFactory.CreateFileSystem(); // Assert - virtualFileSystem.Should().NotBeNull(); - virtualFileSystem.Root.Should().NotBeNull(); - virtualFileSystem.Root.Path.Value.Should().Be("vfs://"); + virtualFileSystem.ShouldNotBeNull(); + virtualFileSystem.Root.ShouldNotBeNull(); + virtualFileSystem.Root.Path.Value.ShouldBe("vfs://"); } } } \ No newline at end of file diff --git a/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/VirtualFileSystem_Constructor_Tests.cs b/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/VirtualFileSystem_Constructor_Tests.cs index 92bac14..e674acd 100644 --- a/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/VirtualFileSystem_Constructor_Tests.cs +++ b/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/VirtualFileSystem_Constructor_Tests.cs @@ -9,11 +9,11 @@ public void Constructor_creates_a_new_file_system() var vfs = CreateVFS(); // Assert - vfs.Should().NotBeNull(); - vfs.IsEmpty.Should().BeTrue(); - vfs.Root.IsDirectory.Should().BeTrue(); - vfs.Root.IsFile.Should().BeFalse(); - vfs.Root.Path.Value.Should().Be("vfs://"); - vfs.Root.CreationTime.Should().BeCloseTo(DateTime.Now, TimeSpan.FromHours(1)); + vfs.ShouldNotBeNull(); + vfs.IsEmpty.ShouldBeTrue(); + vfs.Root.IsDirectory.ShouldBeTrue(); + vfs.Root.IsFile.ShouldBeFalse(); + vfs.Root.Path.Value.ShouldBe("vfs://"); + (DateTime.Now - vfs.Root.CreationTime).ShouldBeLessThan(TimeSpan.FromHours(1)); } } \ No newline at end of file diff --git a/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/VirtualFileSystem_MethodToString_Tests.cs b/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/VirtualFileSystem_MethodToString_Tests.cs index a40b4d5..82c184b 100644 --- a/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/VirtualFileSystem_MethodToString_Tests.cs +++ b/tests/Atypical.VirtualFileSystem.UnitTests/SystemOperations/VirtualFileSystem_MethodToString_Tests.cs @@ -20,6 +20,6 @@ public void ToString_returns_a_summary_of_the_VFS() var result = vfs.ToString(); // Assert - result.Should().Be(expected); + result.ShouldBe(expected); } } \ No newline at end of file diff --git a/tests/Atypical.VirtualFileSystem.UnitTests/UndoRedo/ChangeHistoryTests.cs b/tests/Atypical.VirtualFileSystem.UnitTests/UndoRedo/ChangeHistoryTests.cs index 8ca4428..3cc5892 100644 --- a/tests/Atypical.VirtualFileSystem.UnitTests/UndoRedo/ChangeHistoryTests.cs +++ b/tests/Atypical.VirtualFileSystem.UnitTests/UndoRedo/ChangeHistoryTests.cs @@ -14,8 +14,8 @@ public void AddChange_AddsChangeToUndoStackAndClearsRedoStack() vfs.ChangeHistory.AddChange(change); // Assert - vfs.ChangeHistory.UndoStack.Should().Contain(change); - vfs.ChangeHistory.RedoStack.Should().NotContain(change); + vfs.ChangeHistory.UndoStack.ShouldContain(change); + vfs.ChangeHistory.RedoStack.ShouldNotContain(change); } [Fact] @@ -34,8 +34,8 @@ public void Undo_UndoesMostRecentChangeAndMovesItToRedoStack() vfs.ChangeHistory.Undo(); // Assert - vfs.ChangeHistory.UndoStack.Should().BeEmpty(); - vfs.ChangeHistory.RedoStack.Should().HaveCount(1); + vfs.ChangeHistory.UndoStack.ShouldBeEmpty(); + vfs.ChangeHistory.RedoStack.Count.ShouldBe(1); } [Fact] @@ -57,8 +57,8 @@ public void Redo_RedoesMostRecentUndoneChangeAndMovesItBackToUndoStack() vfs.ChangeHistory.Redo(); // Assert - vfs.ChangeHistory.RedoStack.Should().BeEmpty(); - vfs.ChangeHistory.UndoStack.Should().HaveCount(1); + vfs.ChangeHistory.RedoStack.ShouldBeEmpty(); + vfs.ChangeHistory.UndoStack.Count.ShouldBe(1); } [Fact] @@ -76,7 +76,7 @@ public void Dispose_UnsubscribesFromAllVFSEvents() vfs.CreateFile(filePath); // Assert - changeHistory.UndoStack.Should().BeEmpty(); + changeHistory.UndoStack.ShouldBeEmpty(); } } \ No newline at end of file