Skip to content

Commit

Permalink
Convert constructor into member initializers
Browse files Browse the repository at this point in the history
  • Loading branch information
IT-VBFK committed Aug 17, 2023
1 parent 4d4d754 commit 8a9d9a9
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions Src/FluentAssertions/Specialized/ExceptionAssertions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ namespace FluentAssertions.Specialized;
public class ExceptionAssertions<TException> : ReferenceTypeAssertions<IEnumerable<TException>, ExceptionAssertions<TException>>
where TException : Exception
{
#region Private Definitions

private static readonly ExceptionMessageAssertion OuterMessageAssertion = new();

#endregion

public ExceptionAssertions(IEnumerable<TException> exceptions)
: base(exceptions)
{
Expand Down Expand Up @@ -86,7 +80,7 @@ public ExceptionAssertions(IEnumerable<TException> exceptions)
.ForCondition(Subject.Any())
.FailWith("Expected exception with message {0}{reason}, but no exception was thrown.", expectedWildcardPattern);

OuterMessageAssertion.Execute(Subject.Select(exc => exc.Message), expectedWildcardPattern, because,
ExceptionMessageAssertion.Execute(Subject.Select(exc => exc.Message), expectedWildcardPattern, because,
becauseArgs);

return this;
Expand Down Expand Up @@ -264,16 +258,11 @@ private static string BuildExceptionsString(IEnumerable<TException> exceptions)
"\t" + Formatter.ToString(exception)));
}

private sealed class ExceptionMessageAssertion
private static class ExceptionMessageAssertion
{
public ExceptionMessageAssertion()
{
Context = "exception message";
}

public string Context { get; }
private const string Context = "exception message";

public void Execute(IEnumerable<string> messages, string expectation, string because, params object[] becauseArgs)
public static void Execute(IEnumerable<string> messages, string expectation, string because, params object[] becauseArgs)
{
using var _ = new AssertionScope();
var results = new AssertionResultSet();
Expand Down

0 comments on commit 8a9d9a9

Please sign in to comment.