Skip to content

Commit

Permalink
CODE RUB: Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
cjdutoit committed Jul 19, 2024
1 parent a22221e commit a525a6d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
30 changes: 15 additions & 15 deletions Xeption.Tests/XeptionTests.Logic.DataEqualsWithMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ public void ShouldReturnTrueAndNullStringIfDataMatchInCount()
Xeption actualXeption = expectedXeption.DeepClone();

// when
var actualComparisonResult = actualXeption.DataEqualsWithDetail(expectedXeption.Data);
(bool isEqual, string message) = actualXeption.DataEqualsWithDetail(expectedXeption.Data);

// then
actualComparisonResult.IsEqual.Should().BeTrue();
actualComparisonResult.Message.Should().BeNullOrEmpty();
isEqual.Should().BeTrue();
message.Should().BeNullOrEmpty();
}

[Fact]
Expand Down Expand Up @@ -58,12 +58,12 @@ public void ShouldReturnFalsAndMessageStringIfActualDataContainsKeysNotInExpecte
expectedMessage.AppendLine($"- NOT contain key '{randomKey}'.");

// when
var actualComparisonResult = actualXeption.DataEqualsWithDetail(expectedXeption.Data);
(bool isEqual, string message) = actualXeption.DataEqualsWithDetail(expectedXeption.Data);

// then
actualComparisonResult.IsEqual.Should().BeFalse();
actualComparisonResult.Message.Should().NotBeNullOrEmpty();
actualComparisonResult.Message.Should().BeEquivalentTo(expectedMessage.ToString());
isEqual.Should().BeFalse();
message.Should().NotBeNullOrEmpty();
message.Should().BeEquivalentTo(expectedMessage.ToString());
}

[Fact]
Expand Down Expand Up @@ -93,13 +93,13 @@ public void ShouldReturnFalseAndMessageStringIfExpectedDataContainsKeysNotInActu
$"- contain key '{randomKey}' with value(s) [{randomValue}].");

// when
var actualComparisonResult = actualXeption
(bool isEqual, string message) = actualXeption
.DataEqualsWithDetail(expectedXeption.Data);

// then
actualComparisonResult.IsEqual.Should().BeFalse();
actualComparisonResult.Message.Should().NotBeNullOrEmpty();
actualComparisonResult.Message.Should().BeEquivalentTo(expectedMessage.ToString());
isEqual.Should().BeFalse();
message.Should().NotBeNullOrEmpty();
message.Should().BeEquivalentTo(expectedMessage.ToString());
}

[Fact]
Expand Down Expand Up @@ -134,13 +134,13 @@ public void ShouldReturnFalseAndMessageStringIfExpectedDataContainsKeysMatchingK
$"but found value(s) ['{actualValues}'].");

// when
var actualComparisonResult = actualXeption
(bool isEqual, string message) = actualXeption
.DataEqualsWithDetail(expectedXeption.Data);

// then
actualComparisonResult.IsEqual.Should().BeFalse();
actualComparisonResult.Message.Should().NotBeNullOrEmpty();
actualComparisonResult.Message.Should().BeEquivalentTo(expectedMessage.ToString());
isEqual.Should().BeFalse();
message.Should().NotBeNullOrEmpty();
message.Should().BeEquivalentTo(expectedMessage.ToString());
}
}
}
6 changes: 3 additions & 3 deletions Xeption/Assertions/XeptionAssertions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ private bool InnerExceptionsMatch(
return false;
}

var typeMatch = actual.GetType().FullName == expected.GetType().FullName;
var messageMatch = actual.Message == expected.Message;
bool typeMatch = actual.GetType().FullName == expected.GetType().FullName;
bool messageMatch = actual.Message == expected.Message;

if (actual is AggregateException actualAggregate && expected is AggregateException expectedAggregate)
{
Expand Down Expand Up @@ -112,7 +112,7 @@ private bool InnerExceptionsMatch(
var actualInnerExceptions = actualAggregate.InnerExceptions;
var expectedInnerExceptions = expectedAggregate.InnerExceptions;

var countMatch = actualInnerExceptions.Count == expectedInnerExceptions.Count;
bool countMatch = actualInnerExceptions.Count == expectedInnerExceptions.Count;

if (!countMatch)
{
Expand Down

0 comments on commit a525a6d

Please sign in to comment.