Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Xeption.Tests/Xeption.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@

<ItemGroup>
<PackageReference Include="DeepCloner" Version="0.10.4" />
<PackageReference Include="FluentAssertions" Version="7.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="FluentAssertions" Version="8.2.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
<PackageReference Include="System.Collections" Version="4.3.0" />
<PackageReference Include="Tynamix.ObjectFiller" Version="1.5.9" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.0">
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PackageReference Include="coverlet.collector" Version="6.0.4">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
5 changes: 4 additions & 1 deletion Xeption/Assertions/XeptionAssertionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

using System;
using FluentAssertions.Exceptions;
using FluentAssertions.Execution;

namespace FluentAssertions
{
Expand All @@ -12,7 +13,9 @@ public static class XeptionAssertionExtensions
public static XeptionAssertions<TException> Should<TException>(this TException actualValue)
where TException : Exception
{
return new XeptionAssertions<TException>(actualValue);
var assertionChain = AssertionChain.GetOrCreate();

return new XeptionAssertions<TException>(actualValue, assertionChain);
}
}
}
11 changes: 5 additions & 6 deletions Xeption/Assertions/XeptionAssertions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
namespace FluentAssertions.Exceptions
{
public class XeptionAssertions<TException> : ReferenceTypeAssertions<Exception, XeptionAssertions<TException>>
where TException : Exception
where TException : Exception
{
public XeptionAssertions(TException exception) : base(exception)
public XeptionAssertions(TException exception, AssertionChain assertionChain)
: base(exception, assertionChain)
{ }

public AndConstraint<XeptionAssertions<TException>> BeEquivalentTo(
Expand All @@ -26,12 +27,10 @@ public AndConstraint<XeptionAssertions<TException>> BeEquivalentTo(
bool isMatch = XeptionExtensions
.IsSameExceptionsAs(actualException, expectedException, out string message);

Execute.Assertion
CurrentAssertionChain
.ForCondition(isMatch)
.BecauseOf(because, becauseArgs)
.FailWith(message)
.Then
.ClearExpectation();
.FailWith(message);

return new AndConstraint<XeptionAssertions<TException>>(this);
}
Expand Down
3 changes: 3 additions & 0 deletions Xeption/Xeption.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ internal static (bool IsMatch, string Message) CompareDataKeys(
? "exception"
: $"inner exception (level {exceptionLevel})";

#pragma warning disable CS0219 // Variable is assigned but its value is never used
bool isMatch = true;
#pragma warning restore CS0219 // Variable is assigned but its value is never used

var errors = new StringBuilder();
errors.AppendLine($"Expected {exceptionLevelName} to:");
bool unmatched = dictionary.Count != otherDictionary.Count;
Expand Down
8 changes: 6 additions & 2 deletions Xeption/Xeption.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

<PropertyGroup>
<TargetFrameworks>net9.0;netstandard2.0;netstandard2.1</TargetFrameworks>
<Nullable>disable</Nullable>
<ImplicitUsings>disable</ImplicitUsings>
<Authors>Hassan Habib, Christo du Toit</Authors>
<Company>Hassan Habib</Company>
<Description>Exceptional Exceptions</Description>
Expand Down Expand Up @@ -39,8 +41,10 @@

<ItemGroup>
<PackageReference Include="DeepCloner" Version="0.10.4" />
<PackageReference Include="FluentAssertions" Version="7.0.0" />
<PackageReference Include="FluentAssertions" Version="8.2.0" />
<PackageReference Include="System.Linq" Version="4.3.0" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
</ItemGroup>

<ItemGroup>
Expand All @@ -49,4 +53,4 @@
</None>
</ItemGroup>

</Project>
</Project>