public void IsGivenADescription()
        {
            string description    = "DESCRIPTION";
            bool   irrelevantFlag = false;

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

            AssertDescription.IsEqual(new ReturnCloneAction(prototype),
                                      "a clone of <" + prototype + ">(NMockTests.NamedObject)");
        }
Exemple #3
0
        public void HasReadableDescription()
        {
            Exception   exception = new Exception();
            ThrowAction action    = new ThrowAction(exception);

            AssertDescription.IsEqual(action, "throw <" + exception + ">(System.Exception)");
        }
		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 + "\"");
        }
 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)");
 }
Exemple #7
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)");
        }
Exemple #8
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");
        }
Exemple #9
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");
        }
Exemple #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)");
        }
Exemple #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");
        }
        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)");
        }
Exemple #13
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");
        }
Exemple #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 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 []");
        }
Exemple #16
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");
        }
Exemple #17
0
        public void HasAReadableDescription()
        {
            NamedObject value = new NamedObject("value");

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

            AssertDescription.IsEqual(new PropertyMatcher("A", matcher), "property 'A' " + matcher);
        }
Exemple #19
0
 public void HasAReadableDescription()
 {
     AssertDescription.IsEqual(new ResultSynthesizer(),
                               "a synthesized result");
 }
Exemple #20
0
        public void HasAReadableDescription()
        {
            IAction action = new FireAction("MyEvent", 123);

            AssertDescription.IsEqual(action, "fire MyEvent");
        }
Exemple #21
0
        public void ShowsOutputParametersInDescription()
        {
            Matcher matcher = new ArgumentsMatcher(new AlwaysMatcher(true, "arg1"), Is.Out);

            AssertDescription.IsEqual(matcher, "(arg1, out)");
        }
        public void HasAReadableDescription()
        {
            IAction action = new CollectAction(37);

            AssertDescription.IsEqual(action, "collect argument at index 37");
        }
 public void UsesMethodNameAsDescription()
 {
     AssertDescription.IsEqual(new MethodNameMatcher("m", typeof(I)), "m");
 }
        public void HasAReadableDescription()
        {
            Matcher matcher = new EqualMatcher("foo");

            AssertDescription.IsEqual(new FieldMatcher("A", matcher), "field 'A' " + matcher);
        }
Exemple #25
0
 public void ProvidesAReadableDescription()
 {
     AssertDescription.IsEqual(new NullMatcher(), "null");
 }