示例#1
0
        public override string ToString()
        {
            var writer = new DescriptionWriter();

            DescribeTo(writer);
            return(writer.ToString());
        }
示例#2
0
 public void Assert()
 {
     if (!HasBeenMet)
     {
         var writer = new DescriptionWriter();
         DescribeTo(writer);
         throw new UnmetExpectationException(writer.ToString());
     }
 }
示例#3
0
文件: Verify.cs 项目: textmetal/main
		/// <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 == null) 
				throw new ArgumentNullException("matcher");

			if (!matcher.Matches(actualValue))
			{
				var writer = new DescriptionWriter();
				WriteDescriptionOfFailedMatch(writer, actualValue, matcher);

				throw new ExpectationException(writer.ToString());
			}
		}
示例#4
0
文件: Matcher.cs 项目: textmetal/main
		/// <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 DescriptionWriter();
			DescribeTo(writer);
			return writer.ToString();
		}
示例#5
0
		/// <summary>
		/// Constructs a <see cref="UnexpectedInvocationException"/> with the given parameters.
		/// </summary>
		/// <param name="factory">The MockFactory that threw this exception</param>
		/// <param name="invocation">The unexpected invocation</param>
		/// <param name="expectations">The expectations collection to describe</param>
		/// <param name="message">A message to help the user understand what was unexpected</param>
		internal UnexpectedInvocationException(MockFactory factory, Invocation invocation, IExpectationList expectations, string message)
		{
			if (factory == null)
				throw new ArgumentNullException("factory");
			if (invocation == null)
				throw new ArgumentNullException("invocation");
			if (expectations == null) 
				throw new ArgumentNullException("expectations");

			Factory = factory;

			var writer = new DescriptionWriter();
			writer.WriteLine();
			if (invocation.IsPropertySetAccessor)
				writer.WriteLine(UNEXPECTED_PROPERTY_SETTER_PREFIX);
			else if (invocation.IsPropertyGetAccessor)
				writer.WriteLine(UNEXPECTED_PROPERTY_GETTER_PREFIX);
			else
				writer.WriteLine(MESSAGE_PREFIX);
			writer.Write("  ");
			((ISelfDescribing)invocation).DescribeTo(writer);
			writer.Write(message);
			//expectations.DescribeActiveExpectationsTo(writer);
			//expectations.DescribeUnmetExpectationsTo(writer);
			expectations.DescribeTo(writer);

			_message = writer.ToString();
		}
示例#6
0
		public void Assert()
		{
			if(!HasBeenMet)
			{
				var writer = new DescriptionWriter();
				DescribeTo(writer);
				throw new UnmetExpectationException(writer.ToString());
			}
		}