From a525a6d24e44d2499896a2b8e72a1fe91d16bb47 Mon Sep 17 00:00:00 2001 From: Christo du Toit Date: Fri, 19 Jul 2024 17:25:37 +0100 Subject: [PATCH] CODE RUB: Code cleanup --- ...eptionTests.Logic.DataEqualsWithMessage.cs | 30 +++++++++---------- Xeption/Assertions/XeptionAssertions.cs | 6 ++-- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Xeption.Tests/XeptionTests.Logic.DataEqualsWithMessage.cs b/Xeption.Tests/XeptionTests.Logic.DataEqualsWithMessage.cs index f29b549..c098116 100644 --- a/Xeption.Tests/XeptionTests.Logic.DataEqualsWithMessage.cs +++ b/Xeption.Tests/XeptionTests.Logic.DataEqualsWithMessage.cs @@ -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] @@ -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] @@ -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] @@ -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()); } } } \ No newline at end of file diff --git a/Xeption/Assertions/XeptionAssertions.cs b/Xeption/Assertions/XeptionAssertions.cs index a76ce5d..936a62c 100644 --- a/Xeption/Assertions/XeptionAssertions.cs +++ b/Xeption/Assertions/XeptionAssertions.cs @@ -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) { @@ -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) {