Skip to content

Commit 5c0da04

Browse files
authored
refactor: replace FluentAssertions with aweXpect (#796)
This PR refactors the existing test suite to replace [FluentAssertions](https://github.com/fluentassertions/fluentassertions) with the new [aweXpect](https://github.com/aweXpect/aweXpect) assertion library for more expressive, async-friendly expectations. - Converted all test methods to `async Task` and swapped out `Record.Exception(...).Should()` with `await That(...).Throws*` patterns. - Removed FluentAssertions package references and usings; added `global using aweXpect` and `using static aweXpect.Expect`. - Updated custom test helpers to build aweXpect constraints instead of using FluentAssertions.
1 parent 4eaef90 commit 5c0da04

File tree

268 files changed

+8989
-9066
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

268 files changed

+8989
-9066
lines changed

Directory.Packages.props

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@
3535
<ItemGroup>
3636
<PackageVersion Include="AutoFixture.AutoNSubstitute" Version="5.0.0-preview0012"/>
3737
<PackageVersion Include="AutoFixture.Xunit3" Version="5.0.0-preview0012"/>
38-
<PackageVersion Include="aweXpect" Version="2.18.0"/>
38+
<PackageVersion Include="aweXpect" Version="2.19.1"/>
3939
<PackageVersion Include="aweXpect.Testably" Version="0.10.0"/>
40-
<PackageVersion Include="FluentAssertions" Version="7.2.0"/>
4140
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.13.0"/>
4241
<PackageVersion Include="xunit.v3" Version="2.0.3"/>
4342
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.1"/>

Examples/Directory.Build.props

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333

3434
<ItemGroup>
3535
<PackageReference Include="AutoFixture.Xunit3" />
36-
<PackageReference Include="FluentAssertions" />
3736
<PackageReference Include="Microsoft.NET.Test.Sdk" />
3837
<PackageReference Include="xunit.v3" />
3938
<PackageReference Include="xunit.runner.visualstudio">

Feature.Flags.props

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
<DefineConstants Condition="'$(IS_NET6_OR_HIGHER)' == '1'">$(DefineConstants);FEATURE_FILESYSTEMWATCHER_ADVANCED</DefineConstants>
2727
<DefineConstants Condition="'$(IS_NET6_OR_HIGHER)' == '1'">$(DefineConstants);FEATURE_EXCEPTION_HRESULT</DefineConstants>
2828
<DefineConstants Condition="'$(IS_NET8_OR_HIGHER)' == '1'">$(DefineConstants);FEATURE_FILESYSTEM_COMMENT_ENCRYPTED</DefineConstants>
29-
<DefineConstants Condition="'$(IS_NET8_OR_HIGHER)' == '1'">$(DefineConstants);FEATURE_FILESYSTEM_NET_7_OR_GREATER</DefineConstants> <DefineConstants Condition="'$(IS_NET8_OR_HIGHER)' == '1'">$(DefineConstants);FEATURE_FILESYSTEM_SAFEFILEHANDLE</DefineConstants>
29+
<DefineConstants Condition="'$(IS_NET8_OR_HIGHER)' == '1'">$(DefineConstants);FEATURE_FILESYSTEM_NET_7_OR_GREATER</DefineConstants>
30+
<DefineConstants Condition="'$(IS_NET8_OR_HIGHER)' == '1'">$(DefineConstants);FEATURE_FILESYSTEM_SAFEFILEHANDLE</DefineConstants>
3031
<DefineConstants Condition="'$(IS_NET8_OR_HIGHER)' == '1'">$(DefineConstants);FEATURE_FILESYSTEM_UNIXFILEMODE</DefineConstants>
3132
<DefineConstants Condition="'$(IS_NET8_OR_HIGHER)' == '1'">$(DefineConstants);FEATURE_GUID_FORMATPROVIDER</DefineConstants>
3233
<DefineConstants Condition="'$(IS_NET8_OR_HIGHER)' == '1'">$(DefineConstants);FEATURE_RANDOM_ITEMS</DefineConstants>

Source/Testably.Abstractions.Testing/Polyfills/StringExtensionMethods.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,22 @@ internal static bool Contains(
2828
return @this.Contains(value);
2929
}
3030

31+
/// <summary>
32+
/// Returns a value indicating whether a specified character occurs within this string, using the specified comparison
33+
/// rules.
34+
/// </summary>
35+
/// <returns>
36+
/// <see langword="true" /> if the <paramref name="value" /> parameter occurs withing this string,
37+
/// or if value is the empty string (""); otherwise, <see langword="false" />.
38+
/// </returns>
39+
internal static bool Contains(
40+
this string @this,
41+
string value,
42+
StringComparison comparisonType)
43+
{
44+
return @this.Contains(value);
45+
}
46+
3147
/// <summary>
3248
/// Determines whether the end of this string instance matches the specified character.
3349
/// </summary>

Source/Testably.Abstractions.Testing/Statistics/ParameterDescription.cs

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ protected ParameterDescription(bool isOutParameter)
2323
}
2424

2525
/// <summary>
26-
/// Creates a <see cref="ParameterDescription" /> from the <paramref name="value" /> used as an <see langword="out" /> parameter.
26+
/// Creates a <see cref="ParameterDescription" /> from the <paramref name="value" /> used as an <see langword="out" />
27+
/// parameter.
2728
/// </summary>
2829
public static ParameterDescription FromOutParameter<T>(T value)
2930
{
@@ -99,6 +100,16 @@ public bool Is<T>(ReadOnlySpan<T> value)
99100
d.Value.SequenceEqual(value.ToArray());
100101
#endif
101102

103+
#if FEATURE_SPAN
104+
/// <summary>
105+
/// Checks, if the value of the parameter equals <paramref name="value" />.
106+
/// </summary>
107+
public bool Is<T>(SpanParameterDescription<T> value)
108+
=> this is SpanParameterDescription<T> d &&
109+
d.IsReadOnly == value.IsReadOnly &&
110+
d.Value.SequenceEqual(value.Value);
111+
#endif
112+
102113
/// <summary>
103114
/// Checks, if the span value of the parameter matches the <paramref name="comparer" />.
104115
/// </summary>
@@ -138,17 +149,33 @@ public GenericParameterDescription(T value, bool isOutParameter) : base(isOutPar
138149
}
139150

140151
#if FEATURE_SPAN
141-
private sealed class SpanParameterDescription<T> : ParameterDescription
152+
/// <summary>
153+
/// A parameter description for span values.
154+
/// </summary>
155+
public sealed class SpanParameterDescription<T> : ParameterDescription
142156
{
157+
/// <summary>
158+
/// Flag indicating if the span is read-only.
159+
/// </summary>
143160
public bool IsReadOnly { get; }
161+
162+
/// <summary>
163+
/// The values of the span parameter.
164+
/// </summary>
144165
public T[] Value { get; }
145166

167+
/// <summary>
168+
/// A parameter description for <see cref="Span{T}" /> values.
169+
/// </summary>
146170
public SpanParameterDescription(Span<T> value) : base(false)
147171
{
148172
Value = value.ToArray();
149173
IsReadOnly = false;
150174
}
151175

176+
/// <summary>
177+
/// A parameter description for <see cref="ReadOnlySpan{T}" /> values.
178+
/// </summary>
152179
public SpanParameterDescription(ReadOnlySpan<T> value) : base(false)
153180
{
154181
Value = value.ToArray();

Tests/Api/Testably.Abstractions.Api.Tests/Expected/Testably.Abstractions.Testing_net6.0.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,10 +347,19 @@ namespace Testably.Abstractions.Testing.Statistics
347347
public bool Is<T>(System.Span<T> value) { }
348348
public bool Is<T>(T value) { }
349349
public bool Is<T>(T[] value) { }
350+
public bool Is<T>(Testably.Abstractions.Testing.Statistics.ParameterDescription.SpanParameterDescription<T> value) { }
350351
public static Testably.Abstractions.Testing.Statistics.ParameterDescription FromOutParameter<T>(T value) { }
351352
public static Testably.Abstractions.Testing.Statistics.ParameterDescription FromParameter<T>(System.ReadOnlySpan<T> value) { }
352353
public static Testably.Abstractions.Testing.Statistics.ParameterDescription FromParameter<T>(System.Span<T> value) { }
353354
public static Testably.Abstractions.Testing.Statistics.ParameterDescription FromParameter<T>(T value) { }
355+
public sealed class SpanParameterDescription<T> : Testably.Abstractions.Testing.Statistics.ParameterDescription
356+
{
357+
public SpanParameterDescription(System.ReadOnlySpan<T> value) { }
358+
public SpanParameterDescription(System.Span<T> value) { }
359+
public bool IsReadOnly { get; }
360+
public T[] Value { get; }
361+
public override string ToString() { }
362+
}
354363
}
355364
public enum PropertyAccess
356365
{

Tests/Api/Testably.Abstractions.Api.Tests/Expected/Testably.Abstractions.Testing_net8.0.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,10 +345,19 @@ namespace Testably.Abstractions.Testing.Statistics
345345
public bool Is<T>(System.Span<T> value) { }
346346
public bool Is<T>(T value) { }
347347
public bool Is<T>(T[] value) { }
348+
public bool Is<T>(Testably.Abstractions.Testing.Statistics.ParameterDescription.SpanParameterDescription<T> value) { }
348349
public static Testably.Abstractions.Testing.Statistics.ParameterDescription FromOutParameter<T>(T value) { }
349350
public static Testably.Abstractions.Testing.Statistics.ParameterDescription FromParameter<T>(System.ReadOnlySpan<T> value) { }
350351
public static Testably.Abstractions.Testing.Statistics.ParameterDescription FromParameter<T>(System.Span<T> value) { }
351352
public static Testably.Abstractions.Testing.Statistics.ParameterDescription FromParameter<T>(T value) { }
353+
public sealed class SpanParameterDescription<T> : Testably.Abstractions.Testing.Statistics.ParameterDescription
354+
{
355+
public SpanParameterDescription(System.ReadOnlySpan<T> value) { }
356+
public SpanParameterDescription(System.Span<T> value) { }
357+
public bool IsReadOnly { get; }
358+
public T[] Value { get; }
359+
public override string ToString() { }
360+
}
352361
}
353362
public enum PropertyAccess
354363
{

Tests/Api/Testably.Abstractions.Api.Tests/Expected/Testably.Abstractions.Testing_net9.0.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,10 +345,19 @@ namespace Testably.Abstractions.Testing.Statistics
345345
public bool Is<T>(System.Span<T> value) { }
346346
public bool Is<T>(T value) { }
347347
public bool Is<T>(T[] value) { }
348+
public bool Is<T>(Testably.Abstractions.Testing.Statistics.ParameterDescription.SpanParameterDescription<T> value) { }
348349
public static Testably.Abstractions.Testing.Statistics.ParameterDescription FromOutParameter<T>(T value) { }
349350
public static Testably.Abstractions.Testing.Statistics.ParameterDescription FromParameter<T>(System.ReadOnlySpan<T> value) { }
350351
public static Testably.Abstractions.Testing.Statistics.ParameterDescription FromParameter<T>(System.Span<T> value) { }
351352
public static Testably.Abstractions.Testing.Statistics.ParameterDescription FromParameter<T>(T value) { }
353+
public sealed class SpanParameterDescription<T> : Testably.Abstractions.Testing.Statistics.ParameterDescription
354+
{
355+
public SpanParameterDescription(System.ReadOnlySpan<T> value) { }
356+
public SpanParameterDescription(System.Span<T> value) { }
357+
public bool IsReadOnly { get; }
358+
public T[] Value { get; }
359+
public override string ToString() { }
360+
}
352361
}
353362
public enum PropertyAccess
354363
{

Tests/Api/Testably.Abstractions.Api.Tests/Expected/Testably.Abstractions.Testing_netstandard2.1.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,10 +344,19 @@ namespace Testably.Abstractions.Testing.Statistics
344344
public bool Is<T>(System.Span<T> value) { }
345345
public bool Is<T>(T value) { }
346346
public bool Is<T>(T[] value) { }
347+
public bool Is<T>(Testably.Abstractions.Testing.Statistics.ParameterDescription.SpanParameterDescription<T> value) { }
347348
public static Testably.Abstractions.Testing.Statistics.ParameterDescription FromOutParameter<T>(T value) { }
348349
public static Testably.Abstractions.Testing.Statistics.ParameterDescription FromParameter<T>(System.ReadOnlySpan<T> value) { }
349350
public static Testably.Abstractions.Testing.Statistics.ParameterDescription FromParameter<T>(System.Span<T> value) { }
350351
public static Testably.Abstractions.Testing.Statistics.ParameterDescription FromParameter<T>(T value) { }
352+
public sealed class SpanParameterDescription<T> : Testably.Abstractions.Testing.Statistics.ParameterDescription
353+
{
354+
public SpanParameterDescription(System.ReadOnlySpan<T> value) { }
355+
public SpanParameterDescription(System.Span<T> value) { }
356+
public bool IsReadOnly { get; }
357+
public T[] Value { get; }
358+
public override string ToString() { }
359+
}
351360
}
352361
public enum PropertyAccess
353362
{

0 commit comments

Comments
 (0)