public void CallBaseMethod_should_call_Proceed_on_invocation()
        {
            var invokation = A.Fake <IInvocation>();

            Fake.Configure(invokation).CallsTo(x => x.Arguments).Returns(new object[] { });
            Fake.Configure(invokation).CallsTo(x => x.Method).Returns(typeof(IFoo).GetMethod("Bar", new Type[] { }));

            var adapter = new InvocationCallAdapter(invokation);

            adapter.CallBaseMethod();

            Fake.Assert(invokation).WasCalled(x => x.Proceed());
        }
Пример #2
0
        public void CallBaseMethod_should_call_Proceed_on_invokation()
        {
            var invokation = A.Fake <IInvocation>();

            A.CallTo(() => invokation.Arguments).Returns(new object[] { });
            A.CallTo(() => invokation.Method).Returns(typeof(IFoo).GetMethod("Bar", new Type[] { }));

            var adapter = new InvocationCallAdapter(invokation);

            adapter.CallBaseMethod();

            A.CallTo(() => invokation.Proceed()).MustHaveHappened(Repeated.Once);
        }
Пример #3
0
        public void SetArgumentValue_sets_the_argument_value_of_the_invokation()
        {
            var invocation = A.Fake <IInvocation>();

            Configure.Fake(invocation).CallsTo(x => x.Arguments).Returns(new object[] { });
            Configure.Fake(invocation).CallsTo(x => x.Method).Returns(typeof(IFoo).GetMethod("Bar", new Type[] { }));

            var adapter = new InvocationCallAdapter(invocation);

            adapter.SetArgumentValue(0, "test");

            A.CallTo(() => invocation.SetArgumentValue(0, "test")).MustHaveHappened(Repeated.Once);
        }
Пример #4
0
        public void Method_should_rewrite_method_from_ICanInterceptObjectMembers_to_mapped_object_method_when_called(
            [ValueSource("interfaceMethods")] MethodInfo interfaceMethod,
            [ValueSource("objectMethods")] MethodInfo objectMethod)
        {
            var invocation = A.Fake <IInvocation>();

            A.CallTo(() => invocation.Arguments).Returns(interfaceMethod.GetParameters());
            A.CallTo(() => invocation.Method).Returns(interfaceMethod);

            var adapter = new InvocationCallAdapter(invocation);

            Assert.That(adapter.Method, Is.EqualTo(objectMethod));
        }
        public void SetArgumentValue_sets_the_argument_value_of_the_invokation()
        {
            var invocation = A.Fake <IInvocation>();

            Fake.Configure(invocation).CallsTo(x => x.Arguments).Returns(new object[] { });
            Fake.Configure(invocation).CallsTo(x => x.Method).Returns(typeof(IFoo).GetMethod("Bar", new Type[] { }));

            var adapter = new InvocationCallAdapter(invocation);

            adapter.SetArgumentValue(0, "test");

            Fake.Assert(invocation)
            .WasCalled(x => x.SetArgumentValue(0, "test"));
        }