diff --git a/Pipeline/Build.cs b/Pipeline/Build.cs
index a07a0cc08..25356ef59 100644
--- a/Pipeline/Build.cs
+++ b/Pipeline/Build.cs
@@ -19,7 +19,7 @@ partial class Build : NukeBuild
///
/// Afterward, you can update the package reference in `Directory.Packages.props` and reset this flag.
///
- readonly BuildScope BuildScope = BuildScope.Default;
+ readonly BuildScope BuildScope = BuildScope.CoreOnly;
[Parameter("Github Token")] readonly string GithubToken;
diff --git a/Source/aweXpect.Core/Formatting/ValueFormatters.Collection.cs b/Source/aweXpect.Core/Formatting/ValueFormatters.Collection.cs
index 005329f3a..c3e197cbc 100644
--- a/Source/aweXpect.Core/Formatting/ValueFormatters.Collection.cs
+++ b/Source/aweXpect.Core/Formatting/ValueFormatters.Collection.cs
@@ -85,6 +85,7 @@ public static void Format(
stringBuilder.Append(Format(formatter, v, options with
{
IncludeType = false,
+ UseLineBreaks = options.UseLineBreaks && v?.GetType() != typeof(string),
}).Indent(" ", false));
}
diff --git a/Source/aweXpect/Results/HasItemObjectResult.cs b/Source/aweXpect.Core/Results/ObjectHasItemResult.cs
similarity index 64%
rename from Source/aweXpect/Results/HasItemObjectResult.cs
rename to Source/aweXpect.Core/Results/ObjectHasItemResult.cs
index ebfc92dda..babd61ef6 100644
--- a/Source/aweXpect/Results/HasItemObjectResult.cs
+++ b/Source/aweXpect.Core/Results/ObjectHasItemResult.cs
@@ -1,7 +1,5 @@
-using System;
-using System.Collections.Generic;
+using System.Collections.Generic;
using aweXpect.Core;
-using aweXpect.Equivalency;
using aweXpect.Options;
namespace aweXpect.Results;
@@ -12,41 +10,35 @@ namespace aweXpect.Results;
///
///
///
-public class HasItemObjectResult(
+public class ObjectHasItemResult(
ExpectationBuilder expectationBuilder,
IThat collection,
CollectionIndexOptions collectionIndexOptions,
ObjectEqualityOptions options)
- : HasItemObjectResult>(
+ : ObjectHasItemResult>(
expectationBuilder,
collection,
collectionIndexOptions,
options);
-
///
/// The result for verifying that a collection has a specific item at a given index.
///
///
///
///
-public class HasItemObjectResult(
+public class ObjectHasItemResult(
ExpectationBuilder expectationBuilder,
IThat collection,
CollectionIndexOptions collectionIndexOptions,
ObjectEqualityOptions options)
- : HasItemResult(expectationBuilder, collection, collectionIndexOptions)
- where TSelf : HasItemObjectResult
+ : HasItemResult(expectationBuilder, collection, collectionIndexOptions),
+ IOptionsProvider>
+ where TSelf : ObjectHasItemResult
{
- ///
- /// Use equivalency to compare objects.
- ///
- public TSelf Equivalent(Func? optionsCallback = null)
- {
- options.Equivalent(EquivalencyOptionsExtensions.FromCallback(optionsCallback));
- return (TSelf)this;
- }
+ ///
+ ObjectEqualityOptions IOptionsProvider>.Options => options;
///
/// Uses the provided for comparing s.
diff --git a/Source/aweXpect.Core/Results/StringHasItemResult.cs b/Source/aweXpect.Core/Results/StringHasItemResult.cs
new file mode 100644
index 000000000..7905bf4a7
--- /dev/null
+++ b/Source/aweXpect.Core/Results/StringHasItemResult.cs
@@ -0,0 +1,138 @@
+using System.Collections.Generic;
+using System.Text.RegularExpressions;
+using aweXpect.Core;
+using aweXpect.Options;
+
+namespace aweXpect.Results;
+
+///
+/// The result for verifying that a collection has a specific item at a given index.
+///
+///
+///
+///
+public class StringHasItemResult(
+ ExpectationBuilder expectationBuilder,
+ IThat collection,
+ CollectionIndexOptions collectionIndexOptions,
+ StringEqualityOptions options)
+ : StringHasItemResult>(
+ expectationBuilder,
+ collection,
+ collectionIndexOptions,
+ options);
+
+///
+/// The result for verifying that a collection has a specific item at a given index.
+///
+///
+///
+///
+public class StringHasItemResult(
+ ExpectationBuilder expectationBuilder,
+ IThat collection,
+ CollectionIndexOptions collectionIndexOptions,
+ StringEqualityOptions options)
+ : HasItemResult(expectationBuilder, collection, collectionIndexOptions),
+ IOptionsProvider
+ where TSelf : StringHasItemResult
+{
+ ///
+ StringEqualityOptions IOptionsProvider.Options => options;
+
+ ///
+ /// Ignores casing when comparing the s,
+ /// according to the parameter.
+ ///
+ public TSelf IgnoringCase(bool ignoreCase = true)
+ {
+ options.IgnoringCase(ignoreCase);
+ return (TSelf)this;
+ }
+
+ ///
+ /// Ignores the newline style when comparing s,
+ /// according to the parameter.
+ ///
+ ///
+ /// Enabling this option will replace all occurrences of \r\n and \r with \n in the strings before
+ /// comparing them.
+ ///
+ public TSelf IgnoringNewlineStyle(bool ignoreNewlineStyle = true)
+ {
+ options.IgnoringNewlineStyle(ignoreNewlineStyle);
+ return (TSelf)this;
+ }
+
+ ///
+ /// Ignores leading white-space when comparing s,
+ /// according to the parameter.
+ ///
+ ///
+ /// Note:
+ /// This affects the index of first mismatch, as the removed whitespace is also ignored for the index calculation!
+ ///
+ public TSelf IgnoringLeadingWhiteSpace(bool ignoreLeadingWhiteSpace = true)
+ {
+ options.IgnoringLeadingWhiteSpace(ignoreLeadingWhiteSpace);
+ return (TSelf)this;
+ }
+
+ ///
+ /// Ignores trailing white-space when comparing s,
+ /// according to the parameter.
+ ///
+ public TSelf IgnoringTrailingWhiteSpace(bool ignoreTrailingWhiteSpace = true)
+ {
+ options.IgnoringTrailingWhiteSpace(ignoreTrailingWhiteSpace);
+ return (TSelf)this;
+ }
+
+ ///
+ /// Uses the provided for comparing s.
+ ///
+ public TSelf Using(
+ IEqualityComparer comparer)
+ {
+ options.UsingComparer(comparer);
+ return (TSelf)this;
+ }
+
+ ///
+ /// Interprets the expected as a prefix, so that the actual value starts with it.
+ ///
+ public TSelf AsPrefix()
+ {
+ options.AsPrefix();
+ return (TSelf)this;
+ }
+
+ ///
+ /// Interprets the expected as pattern.
+ ///
+ public TSelf AsRegex()
+ {
+ options.AsRegex();
+ return (TSelf)this;
+ }
+
+ ///
+ /// Interprets the expected as a suffix, so that the actual value ends with it.
+ ///
+ public TSelf AsSuffix()
+ {
+ options.AsSuffix();
+ return (TSelf)this;
+ }
+
+ ///
+ /// Interprets the expected as wildcard pattern.
+ /// Supports * to match zero or more characters and ? to match exactly one character.
+ ///
+ public TSelf AsWildcard()
+ {
+ options.AsWildcard();
+ return (TSelf)this;
+ }
+}
diff --git a/Source/aweXpect/Equivalency/EquivalencyExtensions.cs b/Source/aweXpect/Equivalency/EquivalencyExtensions.cs
index f4e66837f..a756d588b 100644
--- a/Source/aweXpect/Equivalency/EquivalencyExtensions.cs
+++ b/Source/aweXpect/Equivalency/EquivalencyExtensions.cs
@@ -24,6 +24,19 @@ public static TSelf Equivalent(
return (TSelf)result;
}
+ ///
+ /// Use equivalency to compare objects.
+ ///
+ public static TSelf Equivalent(
+ this ObjectHasItemResult result,
+ Func? options = null)
+ where TSelf : ObjectHasItemResult
+ {
+ ((IOptionsProvider>)result).Options.SetMatchType(
+ new EquivalencyComparer(EquivalencyOptionsExtensions.FromCallback(options)));
+ return (TSelf)result;
+ }
+
///
/// Use equivalency to compare objects.
///
diff --git a/Source/aweXpect/That/Collections/ThatAsyncEnumerable.HasItem.cs b/Source/aweXpect/That/Collections/ThatAsyncEnumerable.HasItem.cs
index bb9766454..8c2d13506 100644
--- a/Source/aweXpect/That/Collections/ThatAsyncEnumerable.HasItem.cs
+++ b/Source/aweXpect/That/Collections/ThatAsyncEnumerable.HasItem.cs
@@ -38,13 +38,13 @@ public static partial class ThatAsyncEnumerable
///
/// Verifies that the collection has the item…
///
- public static HasItemObjectResult?, TItem> HasItem(
+ public static ObjectHasItemResult?, TItem> HasItem(
this IThat?> source, TItem expected)
{
CollectionIndexOptions indexOptions = new();
ExpectationBuilder expectationBuilder = source.Get().ExpectationBuilder;
ObjectEqualityOptions options = new();
- return new HasItemObjectResult?, TItem>(
+ return new ObjectHasItemResult?, TItem>(
expectationBuilder.AddConstraint((it, grammars)
=> new HasItemConstraint(expectationBuilder, it, grammars,
a => options.AreConsideredEqual(a, expected),
@@ -55,6 +55,26 @@ public static partial class ThatAsyncEnumerable
options);
}
+ ///
+ /// Verifies that the collection has the item…
+ ///
+ public static StringHasItemResult?> HasItem(
+ this IThat?> source, string? expected)
+ {
+ CollectionIndexOptions indexOptions = new();
+ ExpectationBuilder expectationBuilder = source.Get().ExpectationBuilder;
+ StringEqualityOptions options = new();
+ return new StringHasItemResult?>(
+ expectationBuilder.AddConstraint((it, grammars)
+ => new HasItemConstraint(expectationBuilder, it, grammars,
+ a => options.AreConsideredEqual(a, expected),
+ () => options.GetExpectation(expected, grammars),
+ indexOptions)),
+ source,
+ indexOptions,
+ options);
+ }
+
private sealed class HasItemConstraint(
ExpectationBuilder expectationBuilder,
string it,
diff --git a/Source/aweXpect/That/Collections/ThatEnumerable.HasItem.cs b/Source/aweXpect/That/Collections/ThatEnumerable.HasItem.cs
index 8ed042eda..bbef4fa7d 100644
--- a/Source/aweXpect/That/Collections/ThatEnumerable.HasItem.cs
+++ b/Source/aweXpect/That/Collections/ThatEnumerable.HasItem.cs
@@ -40,13 +40,13 @@ public static partial class ThatEnumerable
///
/// Verifies that the collection has the item…
///
- public static HasItemObjectResult?, TItem> HasItem(
+ public static ObjectHasItemResult?, TItem> HasItem(
this IThat?> source, TItem expected)
{
CollectionIndexOptions indexOptions = new();
ExpectationBuilder expectationBuilder = source.Get().ExpectationBuilder;
ObjectEqualityOptions options = new();
- return new HasItemObjectResult?, TItem>(
+ return new ObjectHasItemResult?, TItem>(
expectationBuilder.AddConstraint((it, grammars)
=> new HasItemConstraint(expectationBuilder, it, grammars,
a => options.AreConsideredEqual(a, expected),
@@ -57,6 +57,26 @@ public static partial class ThatEnumerable
options);
}
+ ///
+ /// Verifies that the collection has the item…
+ ///
+ public static StringHasItemResult?> HasItem(
+ this IThat?> source, string? expected)
+ {
+ CollectionIndexOptions indexOptions = new();
+ ExpectationBuilder expectationBuilder = source.Get().ExpectationBuilder;
+ StringEqualityOptions options = new();
+ return new StringHasItemResult?>(
+ expectationBuilder.AddConstraint((it, grammars)
+ => new HasItemConstraint(expectationBuilder, it, grammars,
+ a => options.AreConsideredEqual(a, expected),
+ () => options.GetExpectation(expected, grammars),
+ indexOptions)),
+ source,
+ indexOptions,
+ options);
+ }
+
///
/// Verifies that the collection has an item matching the …
///
@@ -80,13 +100,13 @@ public static HasItemResult HasItem(
///
/// Verifies that the collection has the item…
///
- public static HasItemObjectResult HasItem(
+ public static ObjectHasItemResult HasItem(
this IThat source, object? expected)
{
CollectionIndexOptions indexOptions = new();
ExpectationBuilder expectationBuilder = source.Get().ExpectationBuilder;
ObjectEqualityOptions