private void AssertDescriptionIsEqual(InvocationExpectation expectation, string expected)
        {
            var writer = new StringDescriptionWriter();
            expectation.DescribeActiveExpectationsTo(writer);

            Assert.AreEqual(expected, writer.ToString());
        }
Exemplo n.º 2
0
        private static string DescriptionOf(ISelfDescribing selfDescribing)
        {
            var writer = new StringDescriptionWriter();

            selfDescribing.DescribeOn(writer);
            return writer.ToString();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Verifies that the <paramref name="actualValue"/> is matched by the <paramref name="matcher"/>.
        /// </summary>
        /// <param name="actualValue">The actual value.</param>
        /// <param name="matcher">The matcher.</param>
        /// <exception cref="ExpectationException">Thrown if value does not match.</exception>
        public static void That(object actualValue, Matcher matcher)
        {
            if (!matcher.Matches(actualValue))
            {
                var writer = new StringDescriptionWriter();
                WriteDescriptionOfFailedMatch(writer, actualValue, matcher);

                throw new ExpectationException(writer.ToString());
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Verifies that the <paramref name="actualValue"/> is matched by the <paramref name="matcher"/>.
        /// </summary>
        /// <param name="actualValue">The actual value to match.</param>
        /// <param name="matcher">The matcher.</param>
        /// <param name="message">The error message.</param>
        /// <param name="formatArgs">The format args for the error message.</param>
        /// <exception cref="ExpectationException">Thrown if value does not match.</exception>
        public static void That(object actualValue, Matcher matcher, string message, params object[] formatArgs)
        {
            if (!matcher.Matches(actualValue))
            {
                var writer = new StringDescriptionWriter();
                writer.AppendTextFormat(message, formatArgs);
                WriteDescriptionOfFailedMatch(writer, actualValue, matcher);

                throw new ExpectationException(writer.ToString());
            }
        }
 public void InitialiseWriter()
 {
     writer = new StringDescriptionWriter();
 }
        private void FailUnexpectedInvocation(Invocation invocation)
        {
            var description = new StringDescriptionWriter();
            description.AppendText("unexpected invocation of ");
            invocation.DescribeOn(description);

            description.AppendNewLine();
            DescribeActiveExpectationsTo(description);

            description.AppendList("\nstates:\n" , Environment.NewLine, string.Empty, stateMachines);

            // try catch to get exception with stack trace.
            throw new ExpectationException(description.ToString());
        }
Exemplo n.º 7
0
 /// <summary>
 /// Returns a <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
 /// </summary>
 /// <returns>
 /// A <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
 /// </returns>
 public override string ToString()
 {
     var writer = new StringDescriptionWriter();
     DescribeOn(writer);
     return writer.ToString();
 }