Пример #1
0
        public void Delegates_perform_action_to_the_target_obtained_via_target_delegate()
        {
            IMethod real  = type.of <string>().GetMethod("Insert");
            IMethod proxy = new ProxyMethod(type.of <char>(), real, (o, _) => o.ToString());

            Assert.AreEqual("insertt", proxy.PerformOn('t', 0, "insert"));
        }
Пример #2
0
        public void Delegates_perform_action_to_target()
        {
            //[SecuritySafeCritical] string Insert(int startIndex, string value)
            IMethod real  = type.of <string>().GetMethod("Insert");
            IMethod proxy = new ProxyMethod(type.of <string>(), real);

            Assert.AreEqual("inserttest", proxy.PerformOn("test", 0, "insert"));
        }
Пример #3
0
        public void Target_can_be_obtained_from_an_additional_parameter()
        {
            var parameterMock = new Mock <IParameter>();

            IMethod real  = type.of <string>().GetMethod("Insert");
            IMethod proxy = new ProxyMethod(type.of <char>(), real, (_, p) => p[0], parameterMock.Object);

            Assert.AreEqual("inserttest", proxy.PerformOn('t', "test", 0, "insert"));
        }
Пример #4
0
        public void When_performing_on_real__additional_parameters_are_skipped()
        {
            var parameterMock = new Mock <IParameter>();

            IMethod real  = type.of <string>().GetMethod("Insert");
            IMethod proxy = new ProxyMethod(type.of <char>(), real, (o, _) => o.ToString(), parameterMock.Object);

            Assert.AreEqual("insertt", proxy.PerformOn('t', "dummy", 0, "insert"));
        }