示例#1
0
        public void RecordsInvocation()
        {
            var behavior = new MockProxyBehavior();

            behavior.Invoke(new MethodInvocation(new object(), typeof(object).GetMethod(nameof(object.ToString))),
                            () => (m, n) => m.CreateValueReturn(null));

            var ms = typeof(IMocked).GetMethods();

            Assert.Equal(1, behavior.Invocations.Count);
        }
示例#2
0
        public void ReturnsFromIMocked()
        {
            var behavior = new MockProxyBehavior();

            var result = behavior.Invoke(new MethodInvocation(
                                             new object(),
                                             typeof(IMocked).GetProperty(nameof(IMocked.Mock)).GetGetMethod()),
                                         null);

            Assert.True(result.ReturnValue is IMocked);
            Assert.Equal(0, behavior.Invocations.Count);
        }
示例#3
0
        public void ForwardsIMockInvocations(MethodInfo method)
        {
            var behavior = new MockProxyBehavior();

            var result = behavior.Invoke(new MethodInvocation(new object(), method), null);

            if (method.ReturnType != typeof(void))
            {
                Assert.Same(method.Invoke(behavior, new object[0]), result.ReturnValue);
            }

            Assert.Equal(0, behavior.Invocations.Count);
        }