public void Has_items_with_matchers() { var aaaMatcher = new CustomMatcher <string>("aaa", s => s == "aaa"); var bbbMatcher = new CustomMatcher <string>("bbb", s => s == "bbb"); Assert.That(new[] { "aaa", "bbb", "ccc" }, Has.Items <string>(aaaMatcher, bbbMatcher)); }
public void No_match_if_string_does_not_contain_substring() { var matcher = Contains.String("bob"); var matches = matcher.Matches("the cat sat on the mat"); Assert.That(matches, Is.False()); }
public void No_match_if_string_does_not_end_with_substring() { var matcher = Starts.With("bob"); var matches = matcher.Matches("the cat sat on the mat"); Assert.That(matches, Is.False()); }
public void No_match_if_inner_matcher_matches() { var isNot = new IsNot <string>(always); var matches = isNot.Matches("test"); Assert.That(matches, Is.EqualTo(false)); }
public void No_match_if_action_does_not_throw() { var matcher = new ThrowsMatcher <ArgumentException>(); var match = matcher.Matches(() => { }); NHAssert.That(match, Is.False()); }
public void No_match_if_action_throws_different_exception() { var matcher = new ThrowsMatcher <NullReferenceException>(); var match = matcher.Matches(DoIt); NHAssert.That(match, Is.False()); }
public void No_match_if_null() { var matcher = Is.InstanceOf(typeof(ShaneLong)); var matches = matcher.Matches(null); Assert.That(matches, Is.False()); }
public void No_match_if_null() { var matcher = Is.NotNull <string>(); var matches = matcher.Matches(null); Assert.That(matches, Is.False()); }
public void No_match_if_thrown_exception_does_not_match_predicate() { var matcher = new ThrowsMatcher <ArgumentNullException>().With(e => e.Message == "something else"); var matches = matcher.Matches(DoIt); NHAssert.That(matches, Is.False()); }
public void Describe_matcher() { var matcher = new ThrowsMatcher <ArgumentNullException>(); var description = new StringDescription(); matcher.DescribeTo(description); NHAssert.That(description.ToString(), Is.EqualTo("the block to throw an exception of type System.ArgumentNullException")); }
public void Describe_to() { var matcher = Is.InstanceOf(typeof(ShaneLong)); var description = new StringDescription(); matcher.DescribeTo(description); Assert.That(description.ToString(), Is.EqualTo("an instance of NHamcrest.Tests.Core.IsInstanceOfTests+ShaneLong")); }
public void Describe_mismatch() { var matcher = Starts.With("bob"); var description = new StringDescription(); matcher.DescribeMismatch("the cat sat on the mat", description); Assert.That(description.ToString(), Is.EqualTo("was \"the cat sat on the mat\"")); }
public void Describe_to() { var matcher = Starts.With("bob"); var description = new StringDescription(); matcher.DescribeTo(description); Assert.That(description.ToString(), Is.EqualTo("a string starting with \"bob\"")); }
public void No_match_if_something_else() { var simonChurch = new SimonChurch(); var matcher = Is.InstanceOf(typeof(ShaneLong)); var matches = matcher.Matches(simonChurch); Assert.That(matches, Is.False()); }
public void Describe_to() { var matcher = Is.Null <string>(); var description = new StringDescription(); matcher.DescribeTo(description); Assert.That(description.ToString(), Is.EqualTo("null")); }
public void Description_adds_not() { var matcher = Is.Not(always); var description = new StringDescription(); matcher.DescribeTo(description); Assert.That(description.ToString(), Is.EqualTo("not Always")); }
public void Describe_mismatch_if_action_does_not_throw() { var matcher = new ThrowsMatcher <ArgumentException>(); var description = new StringDescription(); matcher.DescribeMismatch(() => { }, description); NHAssert.That(description.ToString(), Is.EqualTo("no exception was thrown")); }
public void Default_description() { var matcher = Is.Anything(); var description = new StringDescription(); matcher.DescribeTo(description); Assert.That(description.ToString(), Is.EqualTo("ANYTHING")); }
public void Describe_mismatch_when_null() { var matcher = Is.InstanceOf(typeof(ShaneLong)); var description = new StringDescription(); matcher.DescribeMismatch(null, description); Assert.That(description.ToString(), Is.EqualTo("null")); }
public void Describe_to() { var matcher = Contains.String("bob"); var description = new StringDescription(); matcher.DescribeTo(description); Assert.That(description.ToString(), Is.EqualTo("a string containing \"bob\"")); }
public void Describe_mismatch() { var matcher = Has.Item(Is.EqualTo("aaa")); var description = new StringDescription(); matcher.DescribeMismatch(new [] { "bbb", "ddd" }, description); Assert.That(description.ToString(), Is.EqualTo("was \"bbb\", was \"ddd\"")); }
public void Describe_to() { var matcher = Every.Item(_startsWithA); var description = new StringDescription(); matcher.DescribeTo(description); Assert.That(description.ToString(), Is.EqualTo("every item starts with an A")); }
public void Describe_to_appends_matcher_description() { var matcher = Has.Item(Is.EqualTo("aaa")); var description = new StringDescription(); matcher.DescribeTo(description); Assert.That(description.ToString(), Is.EqualTo("a collection containing \"aaa\"")); }
public void Describe_mismatch_if_thrown_exception_does_not_match_predicate() { var matcher = new ThrowsMatcher <ArgumentNullException>().With(e => e.Message == "something else"); var description = new StringDescription(); matcher.DescribeMismatch(DoIt, description); NHAssert.That(description.ToString(), Starts.With("the exception was of the correct type, but did not match the predicate")); }
public void Describe_mismatch_if_action_throws_different_exception() { var matcher = new ThrowsMatcher <NullReferenceException>(); var description = new StringDescription(); matcher.DescribeMismatch(DoIt, description); NHAssert.That(description.ToString(), Starts.With("an exception of type System.ArgumentNullException was thrown")); }
public void Describe_to() { var a = new A(); var matcher = Is.SameAs(a); var description = new StringDescription(); matcher.DescribeTo(description); Assert.That(description.ToString(), Is.EqualTo("SameAs(NHamcrest.Tests.Core.IsSameTests+A)")); }
public void No_match_if_different_object() { var a = new A(); var a1 = new A(); var matcher = Is.SameAs(a1); var matches = matcher.Matches(a); Assert.That(matches, Is.False()); }
public void Appends_description() { const string test = "test"; var matcher = Is.Anything(test); var description = new StringDescription(); matcher.DescribeTo(description); Assert.That(description.ToString(), Is.EqualTo(test)); }
public void Describe_mismatch() { var simonChurch = new SimonChurch(); var matcher = Is.InstanceOf(typeof(ShaneLong)); var description = new StringDescription(); matcher.DescribeMismatch(simonChurch, description); const string errorMessage = "Simon Church is an instance of NHamcrest.Tests.Core.IsInstanceOfTests+SimonChurch not" + " NHamcrest.Tests.Core.IsInstanceOfTests+ShaneLong"; Assert.That(description.ToString(), Is.EqualTo(errorMessage)); }
public void Match_if_string_ends_with_substring() { Assert.That("the cat sat on the mat", Starts.With("the")); }