コード例 #1
0
        private void AssertDescriptionIsEqual(InvocationExpectation expectation, string expected)
        {
            var writer = new StringDescriptionWriter();
            expectation.DescribeActiveExpectationsTo(writer);

            Assert.AreEqual(expected, writer.ToString());
        }
コード例 #2
0
        private static string DescriptionOf(ISelfDescribing selfDescribing)
        {
            var writer = new StringDescriptionWriter();

            selfDescribing.DescribeOn(writer);
            return writer.ToString();
        }
コード例 #3
0
ファイル: Verify.cs プロジェクト: isaiah-perumalla/NMocha
        /// <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());
            }
        }
コード例 #4
0
ファイル: Verify.cs プロジェクト: isaiah-perumalla/NMocha
        /// <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());
            }
        }
コード例 #5
0
 public void InitialiseWriter()
 {
     writer = new StringDescriptionWriter();
 }
コード例 #6
0
        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());
        }
コード例 #7
0
ファイル: Matcher.cs プロジェクト: isaiah-perumalla/NMocha
 /// <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();
 }