public static AndConstraint <StringCollectionAssertions> BeEquivalentSequenceTo( this StringCollectionAssertions assertions, params string[] expectedValues ) { return(assertions.BeEquivalentTo(expectedValues, c => c.WithStrictOrderingFor(s => s))); }
public static void BeEquivalentUsingWildcards(this StringCollectionAssertions assertion, IEnumerable <string> expectation, Func <EquivalencyAssertionOptions <string>, EquivalencyAssertionOptions <string> > config, string because = "", params object[] becauseArgs) { var subject = assertion.Subject; var newConfig = new Func <EquivalencyAssertionOptions <string>, EquivalencyAssertionOptions <string> >(cfg => { var userConfig = config(cfg); return(userConfig.Using(new CompareStringsUsingCaseInsensitiveWildcards())); }); subject.Should().BeEquivalentTo(expectation, newConfig, because, becauseArgs); }
public static AndConstraint<StringCollectionAssertions> Contains(this IEnumerable<string> actual, IEnumerable<string> expected, IEqualityComparer<string> comparer, string because = "", params object[] reasonArgs) { var node = new StringCollectionAssertions(actual); if (expected == null) { throw new NullReferenceException("Cannot verify containment against a <null> collection"); } if (!expected.Any()) { throw new ArgumentException("Cannot verify containment against an empty collection"); } if (ReferenceEquals(node.Subject, null)) { Execute.Assertion .BecauseOf(because, reasonArgs) .FailWith("Expected {context:collection} to contain {0}{reason}, but found <null>.", expected); } var missingItems = expected.Except(node.Subject, comparer); if (missingItems.Any()) { if (expected.Count() > 1) { Execute.Assertion .BecauseOf(because, reasonArgs) .FailWith("Expected {context:collection} {0} to contain {1}{reason}, but could not find {2}.", node.Subject, expected, missingItems); } else { Execute.Assertion .BecauseOf(because, reasonArgs) .FailWith("Expected {context:collection} {0} to contain {1}{reason}.", node.Subject, expected.Cast<object>().First()); } } return new AndConstraint<StringCollectionAssertions>(node); }
internal static AndConstraint <StringCollectionAssertions> ContainExactlyInOrder( this StringCollectionAssertions scAssertions, params string[] expectations) { return(scAssertions.BeEquivalentTo(expectations, options => options.WithStrictOrdering())); }
public static AndConstraint <StringCollectionAssertions> BeEquivalentSequenceTo( this StringCollectionAssertions assertions, params string[] expectedValues) { return(assertions.ContainInOrder(expectedValues).And.BeEquivalentTo(expectedValues)); }
public static AndConstraint<StringCollectionAssertions> BeEquivalentWithSameOrdering( this StringCollectionAssertions assertions, params string?[] expectation) { return assertions.BeEquivalentTo(expectation, options => options.WithStrictOrdering()); }
public static AndConstraint <StringCollectionAssertions> OnlyContain( this StringCollectionAssertions assertions, IReadOnlyCollection <string> expected, string because = "", params object[] reasonArgs) => assertions.HaveCount(expected.Count, because, reasonArgs).And.Contain(expected, because, reasonArgs);
public static AndConstraint <StringCollectionAssertions> OnlyContain( this StringCollectionAssertions assertions, params string[] expected) => assertions.HaveCount(expected.Length).And.Contain(expected);