-
Notifications
You must be signed in to change notification settings - Fork 53
Strings
Checks if the string is empty, fails if null or not empty.
// this check succeeds
Check.That("").IsEmpty();
// this check fails
Check.That("test").IsEmpty;
Checks if the string is empty or is null, fails if not empty.
// this check succeeds
Check.That("").IsNullOrEmpty();
// this check fails
Check.That("test").IsNullOrEmpty;
Checks if the string does contain texts, fails if empty or null.
// those checks succeed
Check.That("test").IsNotEmpty();
Check.That("test").HasContent();
// those checks fail
Check.That("").IsNotEmpty;
Check.That("").HasContent;
Checks that the sut contains expected, fails if expected is not found.
// this check succeeds
Check.That("this is a test").Contains("test");
// this check fails
Check.That("this is a test").Contains("check");
Checks that the sut does not contain reference, fails if reference is found.
// this check succeeds
Check.That("this is a test").Contains("check");
// this check fails
Check.That("this is a test").Contains("test");
Checks that the sut does start with reference, fails otherwise.
// this check succeeds
Check.That("this is a test").StartsWith("this");
// this check fails
Check.That("this is a test").StartsWith("test");
Checks that the sut does end with reference, fails otherwise.
// this check succeeds
Check.That("this is a test").EndsWith("test");
// this check fails
Check.That("this is a test").EndsWith("this");
Checks that the sut is equal to expected, without taking case into account. Fails otherwise.
// this check succeeds
Check.That("This is a TEST").IsEqualIgnoringCase("this is a test");
// this check fails
Check.That("this is a test").IsEqualIgnoringCase("this");
Checks that the sut is one of the expected strings; fails otherwise.
// this check succeeds
Check.That("correct").IsOneOf("ok", "valid", "correct");
// this check fails
Check.That("ko").IsOneOf("ok", "valid", "correct");
Checks that the sut matches the expected regular expression, fails if not.
// this check succeeds
Check.That("peach").Matches("p([a-z]+)ch");
// this check fails
Check.That("peas").Matches("p([a-z]+)ch");
Checks that the sut does not match the expected regular expression, fails if not.
// this check succeeds
Check.That("peas").DoesNotMatch("p([a-z]+)ch");
// this check fails
Check.That("peas").DoesNotMatch("p([a-z]+)ch");
Checks that the sut matches the expected wildcards expression, fails if not. As a reminder wildcards are '?' for any signle character and '*' for 0 or more characters.
// this check succeeds
Check.That("peaches for the win").MatchesWildcards("peach*");
// this check fails
Check.That("peas for the win").MatchesWildcards("peach*");
Allows to perform checks on the sut as if it was an array of strings, where each string is a line of the original text.
// this check succeeds
Check.That("hello\r\nthere").AsLines().HasSize(2);
// this check fails
Check.That("hello\r\nthere").AsLines().HasElementAt(1).Which().IsEqualTo("you");
- Welcome
- How to start
- Customising error messages
-
Check.That
- All (Equality, Type)
- Reference types
- Members based
- IEnumerable (Properties, Content, Elements)
- String (Properties, Content, RegExp )
- Numeric Type(Properties, Comparisons, Floating)
- Dictionary
- Char (Properties, Value)
- IComparable
- DateTime
- DateTimeOffset
- Misc: Boolean, TimeSpan, Stream, Enum, EventWaitHandle
- Check.ThatCode
- Check.ThatDynamic
- Extensibility
- Auxiliary types (TimeUnit)
- Mocks