-
-
Notifications
You must be signed in to change notification settings - Fork 0
feat: support strings in HasItem
#684
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,138 @@ | ||
| using System.Collections.Generic; | ||
| using System.Text.RegularExpressions; | ||
| using aweXpect.Core; | ||
| using aweXpect.Options; | ||
|
|
||
| namespace aweXpect.Results; | ||
|
|
||
| /// <summary> | ||
| /// The result for verifying that a collection has a specific item at a given index. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// <seealso cref="HasItemResult{TCollection}" /> | ||
| /// </remarks> | ||
| public class StringHasItemResult<TCollection>( | ||
| ExpectationBuilder expectationBuilder, | ||
| IThat<TCollection> collection, | ||
| CollectionIndexOptions collectionIndexOptions, | ||
| StringEqualityOptions options) | ||
| : StringHasItemResult<TCollection, | ||
| StringHasItemResult<TCollection>>( | ||
| expectationBuilder, | ||
| collection, | ||
| collectionIndexOptions, | ||
| options); | ||
|
|
||
| /// <summary> | ||
| /// The result for verifying that a collection has a specific item at a given index. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// <seealso cref="HasItemResult{TCollection}" /> | ||
| /// </remarks> | ||
| public class StringHasItemResult<TCollection, TSelf>( | ||
| ExpectationBuilder expectationBuilder, | ||
| IThat<TCollection> collection, | ||
| CollectionIndexOptions collectionIndexOptions, | ||
| StringEqualityOptions options) | ||
| : HasItemResult<TCollection>(expectationBuilder, collection, collectionIndexOptions), | ||
| IOptionsProvider<StringEqualityOptions> | ||
| where TSelf : StringHasItemResult<TCollection, TSelf> | ||
| { | ||
| /// <inheritdoc cref="IOptionsProvider{TOptions}.Options" /> | ||
| StringEqualityOptions IOptionsProvider<StringEqualityOptions>.Options => options; | ||
|
|
||
| /// <summary> | ||
| /// Ignores casing when comparing the <see langword="string" />s, | ||
| /// according to the <paramref name="ignoreCase" /> parameter. | ||
| /// </summary> | ||
| public TSelf IgnoringCase(bool ignoreCase = true) | ||
| { | ||
| options.IgnoringCase(ignoreCase); | ||
| return (TSelf)this; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Ignores the newline style when comparing <see langword="string" />s, | ||
| /// according to the <paramref name="ignoreNewlineStyle" /> parameter. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// Enabling this option will replace all occurrences of <c>\r\n</c> and <c>\r</c> with <c>\n</c> in the strings before | ||
| /// comparing them. | ||
| /// </remarks> | ||
| public TSelf IgnoringNewlineStyle(bool ignoreNewlineStyle = true) | ||
| { | ||
| options.IgnoringNewlineStyle(ignoreNewlineStyle); | ||
| return (TSelf)this; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Ignores leading white-space when comparing <see langword="string" />s, | ||
| /// according to the <paramref name="ignoreLeadingWhiteSpace" /> parameter. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// Note:<br /> | ||
| /// This affects the index of first mismatch, as the removed whitespace is also ignored for the index calculation! | ||
| /// </remarks> | ||
| public TSelf IgnoringLeadingWhiteSpace(bool ignoreLeadingWhiteSpace = true) | ||
| { | ||
| options.IgnoringLeadingWhiteSpace(ignoreLeadingWhiteSpace); | ||
| return (TSelf)this; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Ignores trailing white-space when comparing <see langword="string" />s, | ||
| /// according to the <paramref name="ignoreTrailingWhiteSpace" /> parameter. | ||
| /// </summary> | ||
| public TSelf IgnoringTrailingWhiteSpace(bool ignoreTrailingWhiteSpace = true) | ||
| { | ||
| options.IgnoringTrailingWhiteSpace(ignoreTrailingWhiteSpace); | ||
| return (TSelf)this; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Uses the provided <paramref name="comparer" /> for comparing <see langword="string" />s. | ||
| /// </summary> | ||
| public TSelf Using( | ||
| IEqualityComparer<string> comparer) | ||
| { | ||
| options.UsingComparer(comparer); | ||
| return (TSelf)this; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Interprets the expected <see langword="string" /> as a prefix, so that the actual value starts with it. | ||
| /// </summary> | ||
| public TSelf AsPrefix() | ||
| { | ||
| options.AsPrefix(); | ||
| return (TSelf)this; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Interprets the expected <see langword="string" /> as <see cref="Regex" /> pattern. | ||
| /// </summary> | ||
| public TSelf AsRegex() | ||
| { | ||
| options.AsRegex(); | ||
| return (TSelf)this; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Interprets the expected <see langword="string" /> as a suffix, so that the actual value ends with it. | ||
| /// </summary> | ||
| public TSelf AsSuffix() | ||
| { | ||
| options.AsSuffix(); | ||
| return (TSelf)this; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Interprets the expected <see langword="string" /> as wildcard pattern.<br /> | ||
| /// Supports * to match zero or more characters and ? to match exactly one character. | ||
| /// </summary> | ||
| public TSelf AsWildcard() | ||
| { | ||
| options.AsWildcard(); | ||
| return (TSelf)this; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.