public void CollectionWithACountOtherThanTheSpecifiedCountOfMatchingPredicatesFails() { var collection = new[] { "a", "b", "c", "c" }; Verify.ShouldFail(() => collection.ShouldContain(x => x == "c", 5), #if net35 errorWithSource: @"collection should contain 5 element(s) satisfying the condition (x = ""c"") but does not", errorWithoutSource: @"[""a"", ""b"", ""c"", ""c""] should contain 5 element(s) satisfying the condition (x = ""c"") but does not"); #else errorWithSource: @"collection should contain 5 element(s) satisfying the condition (x == ""c"") but does not", errorWithoutSource: @"[""a"", ""b"", ""c"", ""c""] should contain 5 element(s) satisfying the condition (x == ""c"") but does not"); #endif }
public void PredicateClosureScenarioShouldFail() { var capturedOuterVar = 4; var arr = new[] { 1, 2, 3 }; Verify.ShouldFail(() => arr.ShouldContain(i => i > capturedOuterVar, "Some additional context"), errorWithSource: @"arr should contain an element satisfying the condition (i > capturedOuterVar) but does not Additional Info: Some additional context", errorWithoutSource: @"[1, 2, 3] should contain an element satisfying the condition (i > capturedOuterVar) but does not Additional Info: Some additional context"); }
public void CollectionWithACountOtherThanTheSpecifiedCountOfMatchingPredicatesFailsWithCustomMessageFunc() { var collection = new[] { "a", "b", "c", "c" }; Verify.ShouldFail(() => collection.ShouldContain(x => x == "c", 5, () => "custom message"), errorWithSource: @"collection should contain 5 element(s) satisfying the condition (x == ""c"") but does not Additional Info: custom message", errorWithoutSource: @"[""a"", ""b"", ""c"", ""c""] should contain 5 element(s) satisfying the condition (x == ""c"") but does not Additional Info: custom message"); }