コード例 #1
0
 public void SucceedsWithGoodValues(object value)
 {
     if (!theConstraint.Matches(value))
     {
         MessageWriter writer = new TextMessageWriter();
         theConstraint.WriteMessageTo(writer);
         Assert.Fail(writer.ToString());
     }
 }
コード例 #2
0
ファイル: ConstraintTestBase.cs プロジェクト: nunit/nunit
 public void SucceedsWithGoodValues(object value)
 {
     var constraintResult = theConstraint.ApplyTo(value);
     if (!constraintResult.IsSuccess)
     {
         MessageWriter writer = new TextMessageWriter();
         constraintResult.WriteMessageTo(writer);
         Assert.Fail(writer.ToString());
     }
 }
コード例 #3
0
 public void SucceedsWithNonVoidReturningFunction()
 {
     var constraintResult = theConstraint.ApplyTo(TestDelegates.ThrowsInsteadOfReturns);
     if (!constraintResult.IsSuccess)
     {
         MessageWriter writer = new TextMessageWriter();
         constraintResult.WriteMessageTo(writer);
         Assert.Fail(writer.ToString());
     }
 }
コード例 #4
0
 public void HonorsIgnoreCase( IEnumerable expected, IEnumerable actual )
 {
     var constraint = new CollectionSubsetConstraint( expected ).IgnoreCase;
     var constraintResult = constraint.ApplyTo( actual );
     if ( !constraintResult.IsSuccess )
     {
         MessageWriter writer = new TextMessageWriter();
         constraintResult.WriteMessageTo( writer );
         Assert.Fail( writer.ToString() );
     }
 }
コード例 #5
0
        public void FailsWithBadValues(object badValue, string message)
        {
            string NL = Env.NewLine;

            Assert.IsFalse(theConstraint.Matches(badValue));

            TextMessageWriter writer = new TextMessageWriter();
            theConstraint.WriteMessageTo(writer);
            Assert.That( writer.ToString(), Is.EqualTo(
                TextMessageWriter.Pfx_Expected + expectedDescription + NL +
                TextMessageWriter.Pfx_Actual + message + NL ));
        }
コード例 #6
0
ファイル: ConstraintTestBase.cs プロジェクト: nunit/nunit
        public void FailsWithBadValues(object badValue, string message)
        {
            string NL = Environment.NewLine;

            var constraintResult = theConstraint.ApplyTo(badValue);
            Assert.IsFalse(constraintResult.IsSuccess);

            TextMessageWriter writer = new TextMessageWriter();
            constraintResult.WriteMessageTo(writer);
            Assert.That( writer.ToString(), Is.EqualTo(
                TextMessageWriter.Pfx_Expected + expectedDescription + NL +
                TextMessageWriter.Pfx_Actual + message + NL ));
        }
コード例 #7
0
 /// <summary>
 /// Writes the value of the expected object.
 /// </summary>
 public string WriteExpected()
 {
     MessageWriter writer = new TextMessageWriter();
     if (Actual is IUnexpectedElement)
     {
         writer.Write("nothing");
     }
     else
     {
         writer.WriteValue(Expected);
     }
     return writer.ToString();
 }
コード例 #8
0
        public void PropertyEqualToValueWithTolerance()
        {
            Constraint c = new EqualConstraint(105m).Within(0.1m);
            TextMessageWriter w = new TextMessageWriter();
            c.WriteDescriptionTo(w);
            Assert.That(w.ToString(), Is.EqualTo("105m +/- 0.1m"));

            c = new PropertyConstraint("D", new EqualConstraint(105m).Within(0.1m));
            w = new TextMessageWriter();
            c.WriteDescriptionTo(w);
            Assert.That(w.ToString(), Is.EqualTo("property D equal to 105m +/- 0.1m"));
        }
コード例 #9
0
 public void SetUp()
 {
     writer = new TextMessageWriter();
 }
コード例 #10
0
        public void FailureMessageWithHashSetAndArray()
        {
            var hash = new HashSet<string>(new string[] { "presto", "abracadabra", "hocuspocus" });
            var array = new string[] { "abracadabra", "presto", "hocusfocus" };

            var constraint = new CollectionEquivalentConstraint(hash);
            var constraintResult = constraint.ApplyTo(array);
            Assert.False(constraintResult.IsSuccess);

            TextMessageWriter writer = new TextMessageWriter();
            constraintResult.WriteMessageTo(writer);
            Assert.That(writer.ToString(), Is.EqualTo(
                "  Expected: equivalent to < \"presto\", \"abracadabra\", \"hocuspocus\" >" + Environment.NewLine +
                "  But was:  < \"abracadabra\", \"presto\", \"hocusfocus\" >" + Environment.NewLine));
            //Console.WriteLine(writer.ToString());
        }
コード例 #11
0
 public void ProvidesProperDescription()
 {
     TextMessageWriter writer = new TextMessageWriter();
     theConstraint.WriteDescriptionTo(writer);
     Assert.That(writer.ToString(), Is.EqualTo(expectedDescription));
 }
コード例 #12
0
ファイル: TextMessageWriterTests.cs プロジェクト: nunit/nunit
 public void SetUp()
 {
     writer = new TextMessageWriter();
 }