示例#1
0
 public void SucceedsWithGoodValues(object value)
 {
     if (!theConstraint.Matches(value))
     {
         MessageWriter writer = new TextMessageWriter();
         theConstraint.WriteMessageTo(writer);
         Assert.Fail(writer.ToString());
     }
 }
示例#2
0
 public void SucceedsWithGoodValues(object value)
 {
     var constraintResult = theConstraint.ApplyTo(value);
     if (!constraintResult.IsSuccess)
     {
         MessageWriter writer = new TextMessageWriter();
         constraintResult.WriteMessageTo(writer);
         Assert.Fail(writer.ToString());
     }
 }
 public void SucceedsWithNonVoidReturningFunction()
 {
     var constraintResult = theConstraint.ApplyTo(TestDelegates.ThrowsInsteadOfReturns);
     if (!constraintResult.IsSuccess)
     {
         MessageWriter writer = new TextMessageWriter();
         constraintResult.WriteMessageTo(writer);
         Assert.Fail(writer.ToString());
     }
 }
 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
        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 ));
        }
 /// <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();
 }
        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
 public void SetUp()
 {
     writer = new TextMessageWriter();
 }