Example #1
0
        public void HasReadableDescription()
        {
            Exception   exception = new Exception();
            ThrowAction action    = new ThrowAction(exception);

            AssertDescription.IsEqual(action, "throw <" + exception + ">(System.Exception)");
        }
Example #2
0
        public void HasAReadableDescription()
        {
            Matcher left  = new MatcherWithDescription("<left>");
            Matcher right = new MatcherWithDescription("<right>");

            AssertDescription.IsComposed(new OrMatcher(left, right), "'{0}' or '{1}'", left, right);
        }
Example #3
0
        public void HasAReadableDescription()
        {
            Matcher    negated    = new MatcherWithDescription("<negated>");
            NotMatcher notMatcher = new NotMatcher(negated);

            AssertDescription.IsComposed(notMatcher, "not {0}", negated);
        }
Example #4
0
        public void IsGivenADescription()
        {
            string description    = "DESCRIPTION";
            bool   irrelevantFlag = false;

            AssertDescription.IsEqual(new AlwaysMatcher(irrelevantFlag, description), description);
        }
Example #5
0
        public void HasAReadableDescription()
        {
            ICloneable prototype = ACloneableObject();

            AssertDescription.IsEqual(new ReturnCloneAction(prototype),
                                      "a clone of <" + prototype + ">(NMockTests.NamedObject)");
        }
Example #6
0
		public void HasAReadableDescription()
		{
			object result = new NamedObject("result");
			ReturnAction action = new ReturnAction(result);

			AssertDescription.IsEqual(action, "return <result>(NMockTests.NamedObject)");
		}
        public void HasAReadableDescription()
        {
            string substring = "substring";

            AssertDescription.IsEqual(new StringContainsMatcher(substring),
                                      "string containing \"" + substring + "\"");
        }
Example #8
0
        public void FormatsDescriptionToLookSimilarToAnArgumentList()
        {
            Matcher matcher = new ArgumentsMatcher(
                new AlwaysMatcher(true, "arg1-description"),
                new AlwaysMatcher(true, "arg2-description"));

            AssertDescription.IsEqual(matcher, "(arg1-description, arg2-description)");
        }
 public void HasReadableDescription()
 {
     AssertDescription.IsEqual(new ComparisonMatcher(10, -1, -1), "? < <10>(System.Int32)");
     AssertDescription.IsEqual(new ComparisonMatcher(10, -1, 0), "? <= <10>(System.Int32)");
     AssertDescription.IsEqual(new ComparisonMatcher(10, 0, 0), "? = <10>(System.Int32)");
     AssertDescription.IsEqual(new ComparisonMatcher(10, 0, 1), "? >= <10>(System.Int32)");
     AssertDescription.IsEqual(new ComparisonMatcher(10, 1, 1), "? > <10>(System.Int32)");
 }
Example #10
0
        public void DescribesAsIndexSetterArguments()
        {
            Matcher matcher = new IndexSetterArgumentsMatcher(
                new AlwaysMatcher(true, "arg1-description"),
                new AlwaysMatcher(true, "arg2-description"));

            AssertDescription.IsEqual(matcher, "[arg1-description] = (arg2-description)");
        }
Example #11
0
        public void DescriptionOfInvocationOfPropertyGetterDoesNotShowSugaredMethod()
        {
            MethodInfo getter = typeof(SugarMethods).GetMethod("get_Property", new Type[0]);

            invocation = new Invocation(receiver, getter, new object[0]);

            AssertDescription.IsEqual(invocation, "receiver.Property\r\n");
        }
Example #12
0
        public void OverridesDescriptionOfOtherMatcherWithThatPassedToConstructor()
        {
            Matcher m1 = new DescriptionOverride("m1", new AlwaysMatcher(true, "always true"));
            Matcher m2 = new DescriptionOverride("m2", new AlwaysMatcher(false, "always false"));

            AssertDescription.IsEqual(m1, "m1");
            AssertDescription.IsEqual(m2, "m2");
        }
Example #13
0
        public void DescriptionOfInvocationOfPropertySetterDoesNotShowSugaredMethod()
        {
            MethodInfo setter = typeof(SugarMethods).GetMethod("set_Property", new[] { typeof(int) });

            invocation = new Invocation(receiver, setter, new object[] { 10 });

            AssertDescription.IsEqual(invocation, "receiver.Property = <10>(System.Int32)\r\n");
        }
Example #14
0
        public void HasReadableDescription()
        {
            string name  = "param";
            object value = new NamedObject("value");

            SetNamedParameterAction action = new SetNamedParameterAction(name, value);

            AssertDescription.IsEqual(action, "set param=<value>(NMockTests.NamedObject)");
        }
        public void HasReadableDescription()
        {
            int    index = 1;
            object value = new NamedObject("value");

            SetIndexedParameterAction action = new SetIndexedParameterAction(index, value);

            AssertDescription.IsEqual(action, "set arg 1=<value>(NMockTests.NamedObject)");
        }
Example #16
0
        public void DescriptionOfInvocationOfIndexerSetterDoesNotShowSugaredMethod()
        {
            MethodInfo getter = typeof(SugarMethods).GetMethod(
                "set_Item", new[] { typeof(string), typeof(int), typeof(int) });

            invocation = new Invocation(receiver, getter, new object[] { "hello", 10, 11 });

            AssertDescription.IsEqual(invocation, "receiver[\"hello\", <10>(System.Int32)] = <11>(System.Int32)\r\n");
        }
Example #17
0
        public void HasAReadableDescription()
        {
            AssertDescription.IsEqual(
                new ElementMatcher(CollectionOf("a", "b", 1, 2)),
                "element of [\"a\", \"b\", <1>(System.Int32), <2>(System.Int32)]");

            AssertDescription.IsEqual(
                new ElementMatcher(CollectionOf()),
                "element of []");
        }
Example #18
0
        public void DescriptionOfEventRemoverDoesNotShowSugaredMethod()
        {
            MethodInfo adder = typeof(SugarMethods).GetMethod(
                "remove_Event", new[] { typeof(EventHandler) });
            Delegate handler = new EventHandler(HandleEvent);

            invocation = new Invocation(receiver, adder, new object[] { handler });

            AssertDescription.IsEqual(invocation, "receiver.Event -= <HandleEvent[System.EventHandler]>\r\n");
        }
Example #19
0
        public void HasAReadableDescription()
        {
            NamedObject value = new NamedObject("value");

            AssertDescription.IsEqual(new EqualMatcher(value), "equal to <" + value + ">(NMockTests.NamedObject)");
        }
Example #20
0
        public void HasAReadableDescription()
        {
            Matcher matcher = new EqualMatcher("foo");

            AssertDescription.IsEqual(new PropertyMatcher("A", matcher), "property 'A' " + matcher);
        }
Example #21
0
        public void HasAReadableDescription()
        {
            Matcher matcher = new EqualMatcher("foo");

            AssertDescription.IsEqual(new FieldMatcher("A", matcher), "field 'A' " + matcher);
        }
 public void UsesMethodNameAsDescription()
 {
     AssertDescription.IsEqual(new MethodNameMatcher("m", typeof(I)), "m");
 }
Example #23
0
 public void ReturnsAReadableDescription()
 {
     stringMatcher.DescribeToOutput = "<stringMatcher description>";
     AssertDescription.IsComposed(matcher, "an object with a string representation that is {0}", stringMatcher);
 }
Example #24
0
        public void HasAReadableDescription()
        {
            IAction action = new FireAction("MyEvent", 123);

            AssertDescription.IsEqual(action, "fire MyEvent");
        }
Example #25
0
        public void HasAReadableDescription()
        {
            IAction action = new CollectAction(37);

            AssertDescription.IsEqual(action, "collect argument at index 37");
        }
Example #26
0
 public void HasAReadableDescription()
 {
     AssertDescription.IsEqual(new ResultSynthesizer(),
                               "a synthesized result");
 }
Example #27
0
 public void ProvidesAReadableDescription()
 {
     AssertDescription.IsEqual(new NullMatcher(), "null");
 }
Example #28
0
        public void ShowsOutputParametersInDescription()
        {
            Matcher matcher = new ArgumentsMatcher(new AlwaysMatcher(true, "arg1"), Is.Out);

            AssertDescription.IsEqual(matcher, "(arg1, out)");
        }