Avoid quoting newlines by jnyrup · Pull Request #2202 · fluentassertions/fluentassertions · GitHub
Skip to content
Merged
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
12 changes: 6 additions & 6 deletions Src/FluentAssertions/ObjectAssertionsExtensions.cs
3 changes: 1 addition & 2 deletions Src/FluentAssertions/Specialized/AsyncFunctionAssertions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,8 @@ private ExceptionAssertions<TException> AssertThrows<TException>(
.FailWith("but no exception was thrown.")
.Then
.ForCondition(expectedExceptions.Any())
.FailWith("but found <{0}>: {1}{2}.",
.FailWith("but found <{0}>:" + Environment.NewLine + "{1}.",
exception?.GetType(),
Environment.NewLine,
exception)
.Then
.ClearExpectation();
Expand Down
3 changes: 1 addition & 2 deletions Src/FluentAssertions/Specialized/DelegateAssertionsBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ protected ExceptionAssertions<TException> ThrowInternal<TException>(
.FailWith("but no exception was thrown.")
.Then
.ForCondition(expectedExceptions.Any())
.FailWith("but found <{0}>: {1}{2}.",
.FailWith("but found <{0}>:" + Environment.NewLine + "{1}.",
exception?.GetType(),
Environment.NewLine,
exception)
.Then
.ClearExpectation();
Expand Down
5 changes: 3 additions & 2 deletions Src/FluentAssertions/Specialized/ExceptionAssertions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,9 @@ public ExceptionAssertions<TException> Where(Expression<Func<TException, bool>>
Execute.Assertion
.ForCondition(condition(SingleSubject))
.BecauseOf(because, becauseArgs)
.FailWith("Expected exception where {0}{reason}, but the condition was not met by:{1}{1}{2}.",
exceptionExpression, Environment.NewLine, Subject);
.FailWith("Expected exception where {0}{reason}, but the condition was not met by:"
+ Environment.NewLine + Environment.NewLine + "{1}.",
exceptionExpression, Subject);

return this;
}
Expand Down
20 changes: 12 additions & 8 deletions Src/FluentAssertions/Streams/StreamAssertions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,9 @@ public AndConstraint<TAssertions> HavePosition(long expected, string because = "
{
Execute.Assertion
.BecauseOf(because, becauseArgs)
.FailWith("Expected the position of {context:stream} to be {0}{reason}, but it failed with:{1}{2}",
expected, Environment.NewLine, exception.Message);
.FailWith("Expected the position of {context:stream} to be {0}{reason}, but it failed with:"
+ Environment.NewLine + "{1}",
expected, exception.Message);

return new AndConstraint<TAssertions>((TAssertions)this);
}
Expand Down Expand Up @@ -280,8 +281,9 @@ public AndConstraint<TAssertions> NotHavePosition(long unexpected, string becaus
{
Execute.Assertion
.BecauseOf(because, becauseArgs)
.FailWith("Expected the position of {context:stream} not to be {0}{reason}, but it failed with:{1}{2}",
unexpected, Environment.NewLine, exception.Message);
.FailWith("Expected the position of {context:stream} not to be {0}{reason}, but it failed with:"
+ Environment.NewLine + "{1}",
unexpected, exception.Message);

return new AndConstraint<TAssertions>((TAssertions)this);
}
Expand Down Expand Up @@ -328,8 +330,9 @@ public AndConstraint<TAssertions> HaveLength(long expected, string because = "",
{
Execute.Assertion
.BecauseOf(because, becauseArgs)
.FailWith("Expected the length of {context:stream} to be {0}{reason}, but it failed with:{1}{2}",
expected, Environment.NewLine, exception.Message);
.FailWith("Expected the length of {context:stream} to be {0}{reason}, but it failed with:"
+ Environment.NewLine + "{1}",
expected, exception.Message);

return new AndConstraint<TAssertions>((TAssertions)this);
}
Expand Down Expand Up @@ -376,8 +379,9 @@ public AndConstraint<TAssertions> NotHaveLength(long unexpected, string because
{
Execute.Assertion
.BecauseOf(because, becauseArgs)
.FailWith("Expected the length of {context:stream} not to be {0}{reason}, but it failed with:{1}{2}",
unexpected, Environment.NewLine, exception.Message);
.FailWith("Expected the length of {context:stream} not to be {0}{reason}, but it failed with:"
+ Environment.NewLine + "{1}",
unexpected, exception.Message);

return new AndConstraint<TAssertions>((TAssertions)this);
}
Expand Down
40 changes: 14 additions & 26 deletions Src/FluentAssertions/Types/TypeSelectorAssertions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,8 @@ public AndConstraint<TypeSelectorAssertions> BeDecoratedWith<TAttribute>(string
.ForCondition(!typesWithoutAttribute.Any())
.BecauseOf(because, becauseArgs)
.FailWith("Expected all types to be decorated with {0}{reason}," +
" but the attribute was not found on the following types:{1}{2}.",
" but the attribute was not found on the following types:" + Environment.NewLine + "{1}.",
typeof(TAttribute),
Environment.NewLine,
GetDescriptionsFor(typesWithoutAttribute));

return new AndConstraint<TypeSelectorAssertions>(this);
Expand Down Expand Up @@ -92,10 +91,9 @@ public AndConstraint<TypeSelectorAssertions> BeDecoratedWith<TAttribute>(
.ForCondition(!typesWithoutMatchingAttribute.Any())
.BecauseOf(because, becauseArgs)
.FailWith("Expected all types to be decorated with {0} that matches {1}{reason}," +
" but no matching attribute was found on the following types:{2}{3}.",
" but no matching attribute was found on the following types:" + Environment.NewLine + "{2}.",
typeof(TAttribute),
isMatchingAttributePredicate,
Environment.NewLine,
GetDescriptionsFor(typesWithoutMatchingAttribute));

return new AndConstraint<TypeSelectorAssertions>(this);
Expand Down Expand Up @@ -123,9 +121,8 @@ public AndConstraint<TypeSelectorAssertions> BeDecoratedWithOrInherit<TAttribute
.ForCondition(!typesWithoutAttribute.Any())
.BecauseOf(because, becauseArgs)
.FailWith("Expected all types to be decorated with or inherit {0}{reason}," +
" but the attribute was not found on the following types:{1}{2}.",
" but the attribute was not found on the following types:" + Environment.NewLine + "{1}.",
typeof(TAttribute),
Environment.NewLine,
GetDescriptionsFor(typesWithoutAttribute));

return new AndConstraint<TypeSelectorAssertions>(this);
Expand Down Expand Up @@ -160,10 +157,9 @@ public AndConstraint<TypeSelectorAssertions> BeDecoratedWithOrInherit<TAttribute
.ForCondition(!typesWithoutMatchingAttribute.Any())
.BecauseOf(because, becauseArgs)
.FailWith("Expected all types to be decorated with or inherit {0} that matches {1}{reason}," +
" but no matching attribute was found on the following types:{2}{3}.",
" but no matching attribute was found on the following types:" + Environment.NewLine + "{2}.",
typeof(TAttribute),
isMatchingAttributePredicate,
Environment.NewLine,
GetDescriptionsFor(typesWithoutMatchingAttribute));

return new AndConstraint<TypeSelectorAssertions>(this);
Expand All @@ -190,9 +186,8 @@ public AndConstraint<TypeSelectorAssertions> NotBeDecoratedWith<TAttribute>(stri
.ForCondition(!typesWithAttribute.Any())
.BecauseOf(because, becauseArgs)
.FailWith("Expected all types to not be decorated with {0}{reason}," +
" but the attribute was found on the following types:{1}{2}.",
" but the attribute was found on the following types:" + Environment.NewLine + "{1}.",
typeof(TAttribute),
Environment.NewLine,
GetDescriptionsFor(typesWithAttribute));

return new AndConstraint<TypeSelectorAssertions>(this);
Expand Down Expand Up @@ -227,10 +222,9 @@ public AndConstraint<TypeSelectorAssertions> NotBeDecoratedWith<TAttribute>(
.ForCondition(!typesWithMatchingAttribute.Any())
.BecauseOf(because, becauseArgs)
.FailWith("Expected all types to not be decorated with {0} that matches {1}{reason}," +
" but a matching attribute was found on the following types:{2}{3}.",
" but a matching attribute was found on the following types:" + Environment.NewLine + "{2}.",
typeof(TAttribute),
isMatchingAttributePredicate,
Environment.NewLine,
GetDescriptionsFor(typesWithMatchingAttribute));

return new AndConstraint<TypeSelectorAssertions>(this);
Expand Down Expand Up @@ -258,9 +252,8 @@ public AndConstraint<TypeSelectorAssertions> NotBeDecoratedWithOrInherit<TAttrib
.ForCondition(!typesWithAttribute.Any())
.BecauseOf(because, becauseArgs)
.FailWith("Expected all types to not be decorated with or inherit {0}{reason}," +
" but the attribute was found on the following types:{1}{2}.",
" but the attribute was found on the following types:" + Environment.NewLine + "{1}.",
typeof(TAttribute),
Environment.NewLine,
GetDescriptionsFor(typesWithAttribute));

return new AndConstraint<TypeSelectorAssertions>(this);
Expand Down Expand Up @@ -295,10 +288,9 @@ public AndConstraint<TypeSelectorAssertions> NotBeDecoratedWithOrInherit<TAttrib
.ForCondition(!typesWithMatchingAttribute.Any())
.BecauseOf(because, becauseArgs)
.FailWith("Expected all types to not be decorated with or inherit {0} that matches {1}{reason}," +
" but a matching attribute was found on the following types:{2}{3}.",
" but a matching attribute was found on the following types:" + Environment.NewLine + "{2}.",
typeof(TAttribute),
isMatchingAttributePredicate,
Environment.NewLine,
GetDescriptionsFor(typesWithMatchingAttribute));

return new AndConstraint<TypeSelectorAssertions>(this);
Expand All @@ -320,7 +312,7 @@ public AndConstraint<TypeSelectorAssertions> BeSealed(string because = "", param

Execute.Assertion.ForCondition(!notSealedTypes.Any())
.BecauseOf(because, becauseArgs)
.FailWith("Expected all types to be sealed{reason}, but the following types are not:{0}{1}.", Environment.NewLine,
.FailWith("Expected all types to be sealed{reason}, but the following types are not:" + Environment.NewLine + "{0}.",
GetDescriptionsFor(notSealedTypes));

return new AndConstraint<TypeSelectorAssertions>(this);
Expand All @@ -342,7 +334,7 @@ public AndConstraint<TypeSelectorAssertions> NotBeSealed(string because = "", pa

Execute.Assertion.ForCondition(!sealedTypes.Any())
.BecauseOf(because, becauseArgs)
.FailWith("Expected all types not to be sealed{reason}, but the following types are:{0}{1}.", Environment.NewLine,
.FailWith("Expected all types not to be sealed{reason}, but the following types are:" + Environment.NewLine + "{0}.",
GetDescriptionsFor(sealedTypes));

return new AndConstraint<TypeSelectorAssertions>(this);
Expand Down Expand Up @@ -372,9 +364,8 @@ public AndConstraint<TypeSelectorAssertions> BeInNamespace(string @namespace, st
.ForCondition(!typesNotInNamespace.Any())
.BecauseOf(because, becauseArgs)
.FailWith("Expected all types to be in namespace {0}{reason}," +
" but the following types are in a different namespace:{1}{2}.",
" but the following types are in a different namespace:" + Environment.NewLine + "{1}.",
@namespace,
Environment.NewLine,
GetDescriptionsFor(typesNotInNamespace));

return new AndConstraint<TypeSelectorAssertions>(this);
Expand Down Expand Up @@ -404,9 +395,8 @@ public AndConstraint<TypeSelectorAssertions> NotBeInNamespace(string @namespace,
.ForCondition(!typesInNamespace.Any())
.BecauseOf(because, becauseArgs)
.FailWith("Expected no types to be in namespace {0}{reason}," +
" but the following types are in the namespace:{1}{2}.",
" but the following types are in the namespace:" + Environment.NewLine + "{1}.",
@namespace,
Environment.NewLine,
GetDescriptionsFor(typesInNamespace));

return new AndConstraint<TypeSelectorAssertions>(this);
Expand Down Expand Up @@ -436,9 +426,8 @@ public AndConstraint<TypeSelectorAssertions> BeUnderNamespace(string @namespace,
.ForCondition(!typesNotUnderNamespace.Any())
.BecauseOf(because, becauseArgs)
.FailWith("Expected the namespaces of all types to start with {0}{reason}," +
" but the namespaces of the following types do not start with it:{1}{2}.",
" but the namespaces of the following types do not start with it:" + Environment.NewLine + "{1}.",
@namespace,
Environment.NewLine,
GetDescriptionsFor(typesNotUnderNamespace));

return new AndConstraint<TypeSelectorAssertions>(this);
Expand Down Expand Up @@ -469,9 +458,8 @@ public AndConstraint<TypeSelectorAssertions> NotBeUnderNamespace(string @namespa
.ForCondition(!typesUnderNamespace.Any())
.BecauseOf(because, becauseArgs)
.FailWith("Expected the namespaces of all types to not start with {0}{reason}," +
" but the namespaces of the following types start with it:{1}{2}.",
" but the namespaces of the following types start with it:" + Environment.NewLine + "{1}.",
@namespace,
Environment.NewLine,
GetDescriptionsFor(typesUnderNamespace));

return new AndConstraint<TypeSelectorAssertions>(this);
Expand Down