public void Static_AsString_returns_self_described_value() { const string description = "test"; var text = StringDescription.AsString(new SelfDescribingValue <string>(description)); Assert.AreEqual(description, text); }
public void Description_can_be_formatted() { var matcher = originalMatcher.DescribedAs("{0}, {1}", "Hello", "World!"); var description = new StringDescription(); matcher.DescribeTo(description); Assert.AreEqual("Hello, World!", description.ToString()); }
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 static void ShouldHaveDescription(this ISelfDescribing matcher, string expected) { var description = new StringDescription(); matcher.DescribeTo(description); var actual = description.ToString(); Xunit.Assert.Equal(expected, actual); }
public void Describe_mismatch() { var matcher = Ends.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_mismatch_if_thrown_exception_does_not_match_predicate() { var matcher = new Throws<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 Append_string() { var description = new StringDescription(new StringBuilder()); const string value = "test"; description.AppendText(value); Assert.AreEqual(value, description.ToString()); }
public void Use_mismatch_description_when_not_null() { var matcher = new TestNonNullDiagnosingMatcher(s => false); var description = new StringDescription(); matcher.DescribeMismatch("", description); Assert.Equal("TestNonNullDiagnosingMatcher.MatchesSafely", description.ToString()); }
public static void ShouldHaveMismatchDescriptionForValue <TMatched>(this IMatcher <TMatched> matcher, TMatched value, string expected) { var description = new StringDescription(); matcher.DescribeMismatch(value, description); var actual = description.ToString(); Xunit.Assert.Equal(expected, actual); }
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_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_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 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_mismatch_safely() { var matcher = new TestNonNullMatcher(s => false); var description = new StringDescription(); matcher.DescribeMismatchSafely2("something", description); Assert.Equal("was \"something\"", description.ToString()); }
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 DescribeTo() { var matcher = new CombinableMatcher<string>(failingMatcher); var description = new StringDescription(); matcher.DescribeTo(description); Assert.AreEqual("Failing matcher", description.ToString(), "Expected no match if either matcher fails."); }
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_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 = 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_to() { var matcher = Is.Null <string>(); var description = new StringDescription(); matcher.DescribeTo(description); Assert.That(description.ToString(), Is.EqualTo("null")); }
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 DescribeTo() { var matcher = new CombinableMatcher <string>(_failingMatcher); var description = new StringDescription(); matcher.DescribeTo(description); Assert.Equal("Failing matcher", description.ToString()); }
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 Append_char() { var description = new StringDescription(new StringBuilder()); const char value = 't'; description.AppendValue(value); Assert.AreEqual("\"t\"", description.ToString()); }
public void Describe_matcher() { var matcher = new Throws<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 Use_base_mismatch_description_when_null() { var matcher = new TestNonNullDiagnosingMatcher(s => true); var description = new StringDescription(); matcher.DescribeMismatch(null, description); Assert.Equal("was null", description.ToString()); }
public void Describe_to() { var matcher = Ends.With("bob"); var description = new StringDescription(); matcher.DescribeTo(description); Assert.That(description.ToString(), Is.EqualTo("a string ending with \"bob\"")); }
public static void ShouldHaveMismatchDescriptionForValue <TMatched>(this IMatcher <TMatched> matcher, TMatched value, IMatcher <string> expectedMatcher) { var description = new StringDescription(); matcher.DescribeMismatch(value, description); var actual = description.ToString(); Assert.That(actual, expectedMatcher); }
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_if_action_does_not_throw() { var matcher = new Throws<ArgumentException>(); var description = new StringDescription(); matcher.DescribeMismatch(() => { }, description); NHAssert.That(description.ToString(), Is.EqualTo("no exception was thrown")); }
public void Description_is_concatenated_from_matchers() { var matcher = Matches.AllOf(new[] { failingMatcher, successfulMatcher }); var description = new StringDescription(); matcher.DescribeTo(description); Assert.AreEqual("(Failing matcher and Successful matcher)", description.ToString()); }
public void Describe_to() { var matcher = new TestMatcher(""); var description = new StringDescription(); matcher.DescribeTo(description); Assert.Equal("", description.ToString()); }
public void Describe_mismatch() { var matcher = Has.Item("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_appends_matcher_description() { var matcher = Has.Item("aaa"); var description = new StringDescription(); matcher.DescribeTo(description); Assert.That(description.ToString(), Is.EqualTo("a collection containing aaa")); }
private static void WriteActual <T>(T actual, IMatcher <T> matcher, TextWriter writer) { writer.Write(" But "); var mismatchDescription = new StringDescription(); matcher.DescribeMismatch(actual, mismatchDescription); writer.Write(mismatchDescription.ToString()); writer.WriteLine(); }
public void Describe_mismatch_if_action_throws_different_exception() { var matcher = new Throws<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_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 Description_is_concatenated_from_matchers() { var matcher = Matches.AllOf(_failingMatcher, _successfulMatcher); var description = new StringDescription(); matcher.DescribeTo(description); Assert.Equal("(Failing matcher and Successful matcher)", description.ToString()); }
public void Mismatch_description_appended_if_matcher_fails() { var matcher = Matches.AllOf(_failingMatcher); var description = new StringDescription(); matcher.DescribeMismatch("bob", description); Assert.Equal("Failing matcher was \"bob\"", description.ToString()); }
public void DescribeTo() { var matcher = new CombinableMatcher <string>(failingMatcher); var description = new StringDescription(); matcher.DescribeTo(description); Assert.AreEqual("Failing matcher", description.ToString(), "Expected no match if either matcher fails."); }
private static void WriteExpected(ISelfDescribing matcher, TextWriter writer) { writer.Write(TextMessageWriter.Pfx_Expected); var description = new StringDescription(); matcher.DescribeTo(description); writer.Write(description.ToString()); writer.WriteLine(); }
public void Mismatch_description_appended_if_matcher_fails() { var matcher = Matches.AllOf(new[] { failingMatcher }); var description = new StringDescription(); matcher.DescribeMismatch("bob", description); Assert.AreEqual("Failing matcher was bob", description.ToString()); }
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 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 Description_is_overridden() { const string newDescription = "newDescription"; var matcher = originalMatcher.DescribedAs(newDescription); var description = new StringDescription(); matcher.DescribeTo(description); Assert.AreEqual(newDescription, description.ToString()); }
public void Append_description() { const string test = "test"; var isEqual = IsEqual<string>.EqualTo(test); var description = new StringDescription(); isEqual.DescribeTo(description); Assert.AreEqual(description.ToString(), test); }
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 Append_description() { const int six = 6; var greaterThan = Is.GreaterThanOrEqualTo(six); var description = new StringDescription(); greaterThan.DescribeTo(description); Assert.AreEqual(description.ToString(), "greater than or equal to " + six); }
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 StringBuilder_passed_in_to_ctor_is_used() { var stringBuilder = new StringBuilder(); var description = new StringDescription(stringBuilder); const string value = "test"; stringBuilder.Append(value); Assert.AreEqual(value, description.ToString()); }
public void Append_description() { const int six = 6; var lessThan = Is.LessThan(six); var description = new StringDescription(); lessThan.DescribeTo(description); Assert.AreEqual(description.ToString(), "less than " + six); }
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 Default_ctor_provides_new_string_builder() { var desc = new StringDescription().ToString(); Assert.AreEqual("", desc); }