예제 #1
0
        public void IsGivenADescription()
        {
            string description    = "DESCRIPTION";
            bool   irrelevantFlag = false;

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

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

            AssertDescription.IsEqual(action, "throw <" + exception + ">(System.Exception)");
        }
예제 #4
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 + "\"");
        }
예제 #6
0
 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)");
 }
예제 #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)");
        }
예제 #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");
        }
예제 #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");
        }
예제 #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)");
        }
예제 #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)");
        }
예제 #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");
        }
예제 #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)");
        }
예제 #15
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 []");
        }
예제 #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");
        }
예제 #17
0
        public void HasAReadableDescription()
        {
            NamedObject value = new NamedObject("value");

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

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

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

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

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

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