Skip to content

Commit 5e266f4

Browse files
committed
Removed FluentAssertions from Sharpify.Test
1 parent 3c1ef56 commit 5e266f4

24 files changed

Lines changed: 206 additions & 206 deletions

tests/Sharpify.Tests/AesProviderTests.cs

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public void AesProvider_PlainText() {
1212
string encrypted = aesProvider.Encrypt(PlainText);
1313
string decrypted = aesProvider.Decrypt(encrypted);
1414

15-
decrypted.Should().Be(PlainText);
15+
Assert.Equal(PlainText, decrypted);
1616
}
1717

1818
[Fact]
@@ -23,7 +23,7 @@ public void AesProvider_Bytes() {
2323
byte[] encryptedBytes = aesProvider.EncryptBytes(plainBytes);
2424
byte[] decryptedBytes = aesProvider.DecryptBytes(encryptedBytes);
2525

26-
decryptedBytes.Should().Equal(plainBytes);
26+
Assert.Equal(plainBytes, decryptedBytes);
2727
}
2828

2929
[Fact]
@@ -35,7 +35,7 @@ public void AesProvider_Bytes_Span() {
3535
Span<byte> decryptedSpan = stackalloc byte[plainBytes.Length];
3636
int written = aesProvider.DecryptBytes(encryptedBytes, decryptedSpan, true);
3737

38-
decryptedSpan.Slice(0, written).SequenceEqual(plainBytes).Should().BeTrue();
38+
Assert.Equal(plainBytes, decryptedSpan.Slice(0, written));
3939
}
4040

4141
[Fact]
@@ -45,7 +45,7 @@ public void AesProvider_DecryptBytes_WhenInputIsNotEncrypted_ReturnsEmptyString(
4545
using var aesProvider = new AesProvider(Key);
4646
byte[] decryptedBytes = aesProvider.DecryptBytes(plainBytes);
4747

48-
decryptedBytes.Should().Equal(Array.Empty<byte>());
48+
Assert.Equal(Array.Empty<byte>(), decryptedBytes);
4949
}
5050

5151
[Fact]
@@ -54,7 +54,7 @@ public void AesProvider_GeneratePassword_AndValidate() {
5454
string hashedPassword = AesProvider.GeneratePassword(password);
5555
bool isValid = AesProvider.IsPasswordValid(password, hashedPassword);
5656

57-
isValid.Should().BeTrue();
57+
Assert.True(isValid);
5858
}
5959

6060
[Fact]
@@ -64,7 +64,7 @@ public void AesProvider_Validate_Invalid() {
6464
string hashedPassword = AesProvider.GeneratePassword(password);
6565
bool isValid = AesProvider.IsPasswordValid(wrongPassword, hashedPassword);
6666

67-
isValid.Should().BeFalse();
67+
Assert.False(isValid);
6868
}
6969

7070
[Fact]
@@ -77,8 +77,8 @@ public void AesProvider_URL() {
7777
string copy = new(url);
7878
string encryptedUrl = aesProvider.EncryptUrl(url);
7979
string decryptedUrl = aesProvider.DecryptUrl(encryptedUrl);
80-
url.Should().Be(copy);
81-
decryptedUrl.Should().Be(url);
80+
Assert.Equal(copy, url);
81+
Assert.Equal(url, decryptedUrl);
8282
}
8383
}
8484

@@ -92,8 +92,9 @@ public void AesProvider_EncryptUrl_OnPlainText() {
9292
var encryptedUrl = aesProvider.EncryptUrl(plainUrl);
9393

9494
// Assert
95-
encryptedUrl.Should().NotBeNullOrEmpty();
96-
encryptedUrl.Should().NotBe(plainUrl);
95+
Assert.NotNull(encryptedUrl);
96+
Assert.NotEmpty(encryptedUrl);
97+
Assert.NotEqual(plainUrl, encryptedUrl);
9798
}
9899

99100
[Fact]
@@ -107,8 +108,9 @@ public void AesProvider_DecryptUrl_OnEncryptedText() {
107108
var decryptedUrl = aesProvider.DecryptUrl(encryptedUrl);
108109

109110
// Assert
110-
decryptedUrl.Should().NotBeNullOrEmpty();
111-
decryptedUrl.Should().Be(plainUrl);
111+
Assert.NotNull(decryptedUrl);
112+
Assert.NotEmpty(decryptedUrl);
113+
Assert.Equal(plainUrl, decryptedUrl);
112114
}
113115

114116
[Fact]
@@ -122,8 +124,8 @@ public void AesProvider_DecryptUrl_IncorrectEncryptedUrl() {
122124
var decryptedUrl = aesProvider.DecryptUrl(incorrectEncryptedUrl);
123125

124126
// Assert
125-
decryptedUrl.Should().NotBeNull();
126-
decryptedUrl.Should().NotBe(plainUrl);
127+
Assert.NotNull(decryptedUrl);
128+
Assert.NotEqual(plainUrl, decryptedUrl);
127129
}
128130

129131
[Fact]
@@ -137,21 +139,22 @@ public void AesProvider_EncryptAndDecryptUrl_WhenInputIsUnicode() {
137139
var decryptedUrl = aesProvider.DecryptUrl(encryptedUrl);
138140

139141
// Assert
140-
decryptedUrl.Should().NotBeNullOrEmpty();
141-
decryptedUrl.Should().Be(unicodeUrl);
142+
Assert.NotNull(decryptedUrl);
143+
Assert.NotEmpty(decryptedUrl);
144+
Assert.Equal(unicodeUrl, decryptedUrl);
142145
}
143146

144147
[Fact]
145148
public void AesProvider_CreateEncryptor() {
146149
using var aesProvider = new AesProvider(Key);
147150
var encryptor = aesProvider.CreateEncryptor();
148151

149-
encryptor.Should().NotBeNull();
152+
Assert.NotNull(encryptor);
150153

151154
var actual = encryptor.TransformFinalBlock(Encoding.UTF8.GetBytes(PlainText), 0, PlainText.Length);
152155
var expected = aesProvider.EncryptBytes(Encoding.UTF8.GetBytes(PlainText));
153156

154-
actual.Should().BeEquivalentTo(expected);
157+
Assert.Equal(expected, actual);
155158
}
156159

157160
[Fact]
@@ -164,6 +167,6 @@ public void AesProvider_CreateDecryptor() {
164167
var actual = decryptor.TransformFinalBlock(source, 0, source.Length);
165168
var expected = aesProvider.DecryptBytes(source);
166169

167-
actual.Should().BeEquivalentTo(expected);
170+
Assert.Equal(expected, actual);
168171
}
169172
}

tests/Sharpify.Tests/CollectionExtensionsTests.cs

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public void IsNullOrEmpty_GivenNullList() {
1212
var result = list.IsNullOrEmpty();
1313

1414
// Assert
15-
result.Should().BeTrue();
15+
Assert.True(result);
1616
}
1717

1818
[Fact]
@@ -24,7 +24,7 @@ public void IsNullOrEmpty_GivenEmptyList() {
2424
var result = list.IsNullOrEmpty();
2525

2626
// Assert
27-
result.Should().BeTrue();
27+
Assert.True(result);
2828
}
2929

3030
[Fact]
@@ -36,9 +36,9 @@ public void AsSpan_GivenNonEmptyList_ReturnsCorrectSpan() {
3636
var span = list.AsSpan();
3737

3838
// Assert
39-
span.Length.Should().Be(list.Count);
39+
Assert.Equal(list.Count, span.Length);
4040
for (int i = 0; i < list.Count; i++) {
41-
span[i].Should().Be(list[i]);
41+
Assert.Equal(list[i], span[i]);
4242
}
4343
}
4444

@@ -51,7 +51,7 @@ public void AsSpan_GivenEmptyList_ReturnsEmptySpan() {
5151
var span = list.AsSpan();
5252

5353
// Assert
54-
span.Length.Should().Be(0);
54+
Assert.Equal(0, span.Length);
5555
}
5656

5757
[Fact]
@@ -70,7 +70,7 @@ public void GetValueRefOrNullRef_GivenExistingKey_ReturnsRefToValue() {
7070
ref var valueReal = ref CollectionsMarshal.GetValueRefOrNullRef(dictionary, key);
7171

7272
// Assert
73-
Unsafe.AreSame(ref valueRef, ref valueReal).Should().BeTrue();
73+
Assert.True(Unsafe.AreSame(ref valueRef, ref valueReal));
7474
}
7575

7676
[Fact]
@@ -83,7 +83,7 @@ public void GetValueRefOrNullRef_GivenNonExistingKey_ReturnsRefNull() {
8383
ref var valueRef = ref dictionary.GetValueRefOrNullRef(key);
8484

8585
// Assert
86-
Unsafe.IsNullRef(ref valueRef).Should().BeTrue();
86+
Assert.True(Unsafe.IsNullRef(ref valueRef));
8787
}
8888

8989
[Fact]
@@ -101,8 +101,8 @@ public void GetValueRefOrAddDefault_GivenExistingKey_ReturnsRefToValueAndDoesNot
101101
ref var valueRef = ref dictionary.GetValueRefOrAddDefault(key, out bool exists);
102102

103103
// Assert
104-
valueRef.Should().BeEquivalentTo("two");
105-
exists.Should().BeTrue();
104+
Assert.Equal("two", valueRef);
105+
Assert.True(exists);
106106
}
107107

108108
[Fact]
@@ -116,9 +116,9 @@ public void GetValueRefOrAddDefault_GivenNonExistingKey_AddsNewEntryWithDefaultV
116116

117117
// Assert
118118
#pragma warning disable
119-
valueRef.Should().Be(default(string));
120-
exists.Should().BeFalse();
121-
dictionary.Should().ContainKey(key).And.ContainValue(default(string));
119+
Assert.Equal(default(string), valueRef);
120+
Assert.False(exists);
121+
Assert.Contains(new KeyValuePair<int, string>(key, default(string)), dictionary);
122122
#pragma warning restore
123123
}
124124

@@ -128,7 +128,7 @@ public void CopyTo_CopiesDictionaryEntries() {
128128
var buffer = ArrayPool<KeyValuePair<int, int>>.Shared.Rent(dict.Count);
129129
dict.CopyTo(buffer, 0);
130130
var span = new Span<KeyValuePair<int, int>>(buffer, 0, dict.Count);
131-
span.ToArray().Should().Equal(dict);
131+
Assert.Equal(dict, span.ToArray());
132132
buffer.ReturnBufferToSharedArrayPool();
133133
}
134134

@@ -137,7 +137,7 @@ public void RentBufferAndCopyEntries_ReturnRentedBuffer_Dictionary() {
137137
var dict = Enumerable.Range(1, 10).ToDictionary(i => i, i => i);
138138
var (buffer, entries) = dict.RentBufferAndCopyEntries();
139139
try {
140-
entries.ToArray().Should().Equal(dict);
140+
Assert.Equal(dict, entries.ToArray());
141141
} finally {
142142
buffer.ReturnBufferToSharedArrayPool();
143143
}
@@ -150,7 +150,7 @@ public void Dictionary_CopyToArray() {
150150
dict.CopyTo(buffer, 0);
151151
var span = buffer.AsSpan(0, dict.Count);
152152
try {
153-
span.SequenceEqual(dict.ToArray()).Should().BeTrue();
153+
Assert.Equal(dict, span.ToArray());
154154
} finally {
155155
buffer.ReturnBufferToSharedArrayPool();
156156
}
@@ -166,7 +166,7 @@ public void PureSort_GivenUnsortedIntArray_ReturnsSortedIntArray() {
166166
var result = source.PureSort(Comparer<int>.Default);
167167

168168
// Assert
169-
result.Should().Equal(expected);
169+
Assert.Equal(expected, result);
170170
}
171171

172172
[Fact]
@@ -179,7 +179,7 @@ public void PureSort_GivenUnsortedStringArray_ReturnsSortedStringArray() {
179179
var result = source.PureSort(StringComparer.InvariantCulture);
180180

181181
// Assert
182-
result.Should().Equal(expected);
182+
Assert.Equal(expected, result);
183183
}
184184

185185
[Fact]
@@ -192,7 +192,7 @@ public void PureSort_GivenUnsortedIntList_ReturnsSortedIntList() {
192192
var result = source.PureSort(Comparer<int>.Default);
193193

194194
// Assert
195-
result.Should().Equal(expected);
195+
Assert.Equal(expected, result);
196196
}
197197

198198
[Fact]
@@ -205,7 +205,7 @@ public void PureSort_GivenUnsortedStringList_ReturnsSortedStringList() {
205205
var result = source.PureSort(Comparer<string>.Default);
206206

207207
// Assert
208-
result.Should().Equal(expected);
208+
Assert.Equal(expected, result);
209209
}
210210

211211
[Fact]
@@ -218,7 +218,7 @@ public void RemoveDuplicates_GivenListWithDuplicates_RemovesDuplicates() {
218218
list.RemoveDuplicates();
219219

220220
// Assert
221-
list.Should().Equal(expected);
221+
Assert.Equal(expected, list);
222222
}
223223

224224
[Fact]
@@ -231,8 +231,8 @@ public void RemoveDuplicatesWithHashSet_GivenListWithDuplicates_RemovesDuplicate
231231
list.RemoveDuplicates(out var hSet);
232232

233233
// Assert
234-
list.Should().Equal(expected);
235-
hSet.Should().HaveCount(expected.Count);
234+
Assert.Equal(expected, list);
235+
Assert.Equal(expected.Count, hSet.Count);
236236
}
237237

238238
[Fact]
@@ -245,7 +245,7 @@ public void RemoveDuplicates_GivenListWithNoDuplicates_DoesNotModifyList() {
245245
list.RemoveDuplicates(comparer: StringComparer.InvariantCulture);
246246

247247
// Assert
248-
list.Should().Equal(expected);
248+
Assert.Equal(expected, list);
249249
}
250250

251251
[Fact]
@@ -258,7 +258,7 @@ public void RemoveDuplicates_Sorted_GivenSortedListWithDuplicates_RemovesDuplica
258258
list.RemoveDuplicates(isSorted: true);
259259

260260
// Assert
261-
list.Should().Equal(expected);
261+
Assert.Equal(expected, list);
262262
}
263263

264264
[Fact]
@@ -271,7 +271,7 @@ public void RemoveDuplicates_Sorted_GivenSortedListWithNoDuplicates_DoesNotModif
271271
list.RemoveDuplicates(isSorted: true, comparer: StringComparer.InvariantCulture);
272272

273273
// Assert
274-
list.Should().Equal(expected);
274+
Assert.Equal(expected, list);
275275
}
276276

277277
[Fact]
@@ -283,7 +283,7 @@ public void ChunkToSegments_GivenEmptyArray_ReturnsEmptyList() {
283283
var result = array.ChunkToSegments(3);
284284

285285
// Assert
286-
result.Should().BeEmpty();
286+
Assert.Empty(result);
287287
}
288288

289289
[Fact]
@@ -295,8 +295,8 @@ public void ChunkToSegments_GivenArrayWithLengthLessThanSegmentSize_ReturnsSingl
295295
var result = array.ChunkToSegments(5);
296296

297297
// Assert
298-
result.Should().HaveCount(1);
299-
result[0].Should().Equal(array);
298+
Assert.Single(result);
299+
Assert.Equal(array, result[0]);
300300
}
301301

302302
[Fact]
@@ -308,7 +308,7 @@ public void ChunkToSegments_GivenValidArray_ReturnsCorrectNumberOfSegments() {
308308
var result = array.ChunkToSegments(3);
309309

310310
// Assert
311-
result.Should().HaveCount(3);
312-
result.Sum(s => s.Count).Should().Be(array.Length);
311+
Assert.Equal(3, result.Count);
312+
Assert.Equal(array.Length, result.Sum(s => s.Count));
313313
}
314314
}

tests/Sharpify.Tests/Collections/BufferWrapperTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public void BufferWrapper_NoCapacity_Throws() {
1313
};
1414

1515
// Act & Assert
16-
act.Should().Throw<ArgumentOutOfRangeException>();
16+
Assert.Throws<ArgumentOutOfRangeException>(act);
1717
}
1818

1919
[Fact]
@@ -28,7 +28,7 @@ public void BufferWrapper_Append_ToFullCapacity() {
2828
};
2929

3030
// Assert
31-
act.Should().NotThrow<ArgumentOutOfRangeException>();
31+
act();
3232
}
3333

3434
[Fact]
@@ -43,7 +43,7 @@ public void BufferWrapper_Append_BeyondCapacity() {
4343
};
4444

4545
// Assert
46-
act.Should().Throw<ArgumentOutOfRangeException>();
46+
Assert.Throws<ArgumentOutOfRangeException>(act);
4747
}
4848

4949
[Fact]
@@ -57,7 +57,7 @@ public void BufferWrapper_Reset() {
5757
buffer.Append("David");
5858

5959
// Assert
60-
(buffer.WrittenSpan is "David").Should().BeTrue();
60+
Assert.Equal("David", buffer.WrittenSpan);
6161
}
6262
}
6363
#endif

0 commit comments

Comments
 (0)