Skip to content

Commit ae791ba

Browse files
chore: replace FluentAssertions with Shouldly (#54)
1 parent 3fd01ab commit ae791ba

File tree

7 files changed

+41
-39
lines changed

7 files changed

+41
-39
lines changed

src-Arius5/Arius.Core.Tests/Arius.Core.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<PrivateAssets>all</PrivateAssets>
1616
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1717
</PackageReference>
18-
<PackageReference Include="FluentAssertions" Version="7.2.0" />
18+
<PackageReference Include="Shouldly" Version="4.3.0" />
1919
<PackageReference Include="JunitXml.TestLogger" Version="6.1.0" />
2020
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="9.0.8" />
2121
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.8" />

src-Arius5/Arius.Core.Tests/Commands/ArchiveCommandHandlerContextTests.cs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
using Arius.Core.Models;
33
using Arius.Core.Repositories;
44
using Arius.Core.Services;
5-
using FluentAssertions;
65
using Microsoft.Extensions.Logging.Abstractions;
76
using Microsoft.Extensions.Logging.Testing;
87
using NSubstitute;
8+
using Shouldly;
99

1010
namespace Arius.Core.Tests.Commands;
1111

@@ -63,17 +63,17 @@ public async Task CreateAsync_WhenNoRemoteStateExists_ShouldCreateNewStateFile()
6363
tempStateDirectory);
6464

6565
// Assert
66-
context.Should().NotBeNull();
67-
context.Request.Should().Be(testCommand);
68-
context.BlobStorage.Should().Be(mockBlobStorage);
69-
context.StateRepo.Should().NotBeNull();
70-
context.Hasher.Should().NotBeNull();
71-
context.FileSystem.Should().NotBeNull();
66+
context.ShouldNotBeNull();
67+
context.Request.ShouldBe(testCommand);
68+
context.BlobStorage.ShouldBe(mockBlobStorage);
69+
context.StateRepo.ShouldNotBeNull();
70+
context.Hasher.ShouldNotBeNull();
71+
context.FileSystem.ShouldNotBeNull();
7272

7373
// Verify a new state file was created (with current timestamp format)
7474
var stateFiles = tempStateDirectory.GetFiles("*.db");
75-
stateFiles.Should().HaveCount(1);
76-
stateFiles[0].Name.Should().MatchRegex(@"\d{4}-\d{2}-\d{2}T\d{2}-\d{2}-\d{2}\.db");
75+
stateFiles.Length.ShouldBe(1);
76+
stateFiles[0].Name.ShouldMatch(@"\d{4}-\d{2}-\d{2}T\d{2}-\d{2}-\d{2}\.db");
7777

7878
// Verify no download was attempted since no remote state exists
7979
await mockBlobStorage.DidNotReceive().DownloadStateAsync(Arg.Any<string>(), Arg.Any<FileInfo>(), Arg.Any<CancellationToken>());
@@ -104,9 +104,9 @@ public async Task CreateAsync_WhenRemoteStateExistsButNotLocally_ShouldDownloadA
104104
tempStateDirectory);
105105

106106
// Assert
107-
context.Should().NotBeNull();
108-
context.Request.Should().Be(testCommand);
109-
context.BlobStorage.Should().Be(mockBlobStorage);
107+
context.ShouldNotBeNull();
108+
context.Request.ShouldBe(testCommand);
109+
context.BlobStorage.ShouldBe(mockBlobStorage);
110110

111111
// Verify the remote state was downloaded
112112
await mockBlobStorage.Received(1).DownloadStateAsync(
@@ -116,15 +116,15 @@ await mockBlobStorage.Received(1).DownloadStateAsync(
116116

117117
// Verify a new state file was created (with current timestamp format)
118118
var stateFiles = tempStateDirectory.GetFiles("*.db");
119-
stateFiles.Should().HaveCountGreaterThan(0);
119+
stateFiles.Length.ShouldBeGreaterThan(0);
120120

121121
// Should have the downloaded state file and the new version
122122
var downloadedStateFile = stateFiles.FirstOrDefault(f => f.Name == $"{existingStateName}.db");
123-
downloadedStateFile.Should().NotBeNull("the downloaded state file should exist");
123+
downloadedStateFile.ShouldNotBeNull("the downloaded state file should exist");
124124

125125
var newStateFile = stateFiles.FirstOrDefault(f => f.Name != $"{existingStateName}.db");
126-
newStateFile.Should().NotBeNull("a new state file should be created");
127-
newStateFile.Name.Should().MatchRegex(@"\d{4}-\d{2}-\d{2}T\d{2}-\d{2}-\d{2}\.db");
126+
newStateFile.ShouldNotBeNull("a new state file should be created");
127+
newStateFile.Name.ShouldMatch(@"\d{4}-\d{2}-\d{2}T\d{2}-\d{2}-\d{2}\.db");
128128
}
129129

130130
[Fact]
@@ -147,24 +147,24 @@ public async Task CreateAsync_WhenRemoteStateExistsAndIsPresentLocally_ShouldNot
147147
tempStateDirectory);
148148

149149
// Assert
150-
context.Should().NotBeNull();
151-
context.Request.Should().Be(testCommand);
152-
context.BlobStorage.Should().Be(mockBlobStorage);
150+
context.ShouldNotBeNull();
151+
context.Request.ShouldBe(testCommand);
152+
context.BlobStorage.ShouldBe(mockBlobStorage);
153153

154154
// Verify no download was attempted since the file already exists locally
155155
await mockBlobStorage.DidNotReceive().DownloadStateAsync(Arg.Any<string>(), Arg.Any<FileInfo>(), Arg.Any<CancellationToken>());
156156

157157
// Verify a new state file was created (with current timestamp format)
158158
var stateFiles = tempStateDirectory.GetFiles("*.db");
159-
stateFiles.Should().HaveCountGreaterThan(1);
159+
stateFiles.Length.ShouldBeGreaterThan(1);
160160

161161
// Should have the existing state file and the new version
162162
var existingFile = stateFiles.FirstOrDefault(f => f.Name == $"{existingStateName}.db");
163-
existingFile.Should().NotBeNull("the existing state file should still exist");
163+
existingFile.ShouldNotBeNull("the existing state file should still exist");
164164

165165
var newStateFile = stateFiles.FirstOrDefault(f => f.Name != $"{existingStateName}.db");
166-
newStateFile.Should().NotBeNull("a new state file should be created");
167-
newStateFile.Name.Should().MatchRegex(@"\d{4}-\d{2}-\d{2}T\d{2}-\d{2}-\d{2}\.db");
166+
newStateFile.ShouldNotBeNull("a new state file should be created");
167+
newStateFile.Name.ShouldMatch(@"\d{4}-\d{2}-\d{2}T\d{2}-\d{2}-\d{2}\.db");
168168
}
169169

170170
public void Dispose()

src-Arius5/Arius.Core.Tests/Commands/ArchiveCommandHandlerErrorTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using Arius.Core.Commands;
22
using Arius.Core.Models;
3-
using FluentAssertions;
43
using Microsoft.Extensions.Logging.Abstractions;
54
using Microsoft.Extensions.Logging.Testing;
5+
using Shouldly;
66

77
namespace Arius.Core.Tests.Commands;
88

@@ -50,8 +50,8 @@ public async Task Handle_WithInvalidAzureCredentials_ShouldFail()
5050
var act = () => handler.Handle(command, CancellationToken.None);
5151

5252
// Assert
53-
var e = await act.Should().ThrowAsync<FormatException>();
54-
e.Which.Message.Should().Contain("No valid combination of account information found.");
53+
var e = await Should.ThrowAsync<FormatException>(act);
54+
e.Message.ShouldContain("No valid combination of account information found.");
5555
}
5656

5757
public void Dispose()

src-Arius5/Arius.Core.Tests/Models/FilePairFileSystemTests.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using Arius.Core.Models;
2-
using FluentAssertions;
2+
using Shouldly;
33
using Zio;
44

55
namespace Arius.Core.Tests.Models;
@@ -47,6 +47,8 @@ public async Task EnumerateFileEntries_ShouldEnumerateFilePairsButSkipHiddenFile
4747
Assert.NotNull(files);
4848
Assert.Equal(expectedRelativePaths.Length, files.Count);
4949

50-
files.Select(fe => fe.FullName).Should().BeEquivalentTo(expectedRelativePaths);
50+
files.Select(fe => fe.FullName)
51+
.OrderBy(p => p)
52+
.ShouldBe(expectedRelativePaths.OrderBy(p => p));
5153
}
5254
}
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using Arius.Core.Models;
2-
using FluentAssertions;
2+
using Shouldly;
33

44
namespace Arius.Core.Tests.Models;
55

@@ -11,10 +11,10 @@ public void Equals_SameValue_ShouldBeEqual()
1111
Hash h1 = "ABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCD";
1212
Hash h2 = "ABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCD";
1313

14-
h1.Equals(h2).Should().BeTrue();
15-
h1.GetHashCode().Should().Be(h2.GetHashCode());
14+
h1.Equals(h2).ShouldBeTrue();
15+
h1.GetHashCode().ShouldBe(h2.GetHashCode());
1616

17-
(h1 == h2).Should().BeTrue();
17+
(h1 == h2).ShouldBeTrue();
1818
}
1919

2020
[Fact]
@@ -23,7 +23,7 @@ public void Equals_LowerValue_ShouldBeEqual()
2323
Hash h1 = "ABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCD";
2424
Hash h2 = "ABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCD".ToLowerInvariant();
2525

26-
h1.Equals(h2).Should().BeTrue();
27-
h1.GetHashCode().Should().Be(h2.GetHashCode());
26+
h1.Equals(h2).ShouldBeTrue();
27+
h1.GetHashCode().ShouldBe(h2.GetHashCode());
2828
}
2929
}

src-Arius5/Arius.Core.Tests/Services/Sha256HasherTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using Arius.Core.Models;
22
using Arius.Core.Services;
3-
using FluentAssertions;
3+
using Shouldly;
44
using Zio;
55
using Zio.FileSystems;
66

@@ -18,7 +18,7 @@ public async Task GetHashAsync_Bytes_ProducesConsistentHash()
1818
var hash1 = await hasher.GetHashAsync(zeroBytes);
1919

2020
var arius3HasherHash = (Hash)"88e667ac1167d96e7c42ec65daf9c096d374263a313c60b6d307ec3938300f98";
21-
hash1.Should().Be(arius3HasherHash);
21+
hash1.ShouldBe(arius3HasherHash);
2222
}
2323

2424
[Fact]
@@ -38,6 +38,6 @@ public async Task GetHashAsync_Stream_ProducesConsistentHash()
3838
var hash1 = await hasher.GetHashAsync(bf);
3939

4040
var arius3HasherHash = (Hash)"88e667ac1167d96e7c42ec65daf9c096d374263a313c60b6d307ec3938300f98";
41-
hash1.Should().Be(arius3HasherHash);
41+
hash1.ShouldBe(arius3HasherHash);
4242
}
4343
}

src-Arius5/CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,4 @@ The CLI application requires configuration via user secrets:
7474
- **Azure.Storage.Blobs**: Azure Blob Storage client
7575
- **Entity Framework Core**: SQLite persistence
7676
- **Spectre.Console**: Rich console UI with progress reporting
77-
- **xUnit**: Test framework with FluentAssertions and NSubstitute
77+
- **xUnit**: Test framework with Shouldly and NSubstitute

0 commit comments

Comments
 (0)