An Spring.Objects.Factory.Support.IMethodReplacer implementation that delegates to an Spring.Objects.Factory.Support.IMethodReplacer that is obtained as the result of a lookup in an associated IoC container.

This class is reserved for internal use within the framework; it is not intended to be used by application developers using Spring.NET.

Наследование: AbstractMethodReplacer
Пример #1
0
        public void SunnyDayPath()
        {
            IObjectFactory mockFactory = (IObjectFactory)mocks.CreateMock(typeof(IObjectFactory));
            IConfigurableObjectDefinition mockDefinition = (IConfigurableObjectDefinition)mocks.CreateMock(typeof(IConfigurableObjectDefinition));
            IMethodReplacer mockReplacer = (IMethodReplacer)mocks.CreateMock(typeof(IMethodReplacer));


            const string ReplacerObjectName = "replacer";

            Expect.Call(mockFactory.GetObject(ReplacerObjectName)).Return(mockReplacer);

            ReplacedMethodOverride ovr       = new ReplacedMethodOverride("SunnyDayPath", ReplacerObjectName);
            MethodOverrides        overrides = new MethodOverrides();

            overrides.Add(ovr);
            Expect.Call(mockDefinition.MethodOverrides).Return(overrides);

            Expect.Call(mockReplacer.Implement(null, null, null)).IgnoreArguments().Return(null);
            mocks.ReplayAll();

            DelegatingMethodReplacer replacer = new DelegatingMethodReplacer(mockDefinition, mockFactory);
            MethodInfo method = (MethodInfo)MethodBase.GetCurrentMethod();

            replacer.Implement(this, method, new object[] {});

            mocks.VerifyAll();
        }
        public void SunnyDayPath()
        {
            IObjectFactory mockFactory = (IObjectFactory) mocks.CreateMock(typeof(IObjectFactory));
            IConfigurableObjectDefinition mockDefinition = (IConfigurableObjectDefinition) mocks.CreateMock(typeof(IConfigurableObjectDefinition));
            IMethodReplacer mockReplacer = (IMethodReplacer) mocks.CreateMock(typeof(IMethodReplacer));

            const string ReplacerObjectName = "replacer";
            Expect.Call(mockFactory.GetObject(ReplacerObjectName)).Return(mockReplacer);

            ReplacedMethodOverride ovr = new ReplacedMethodOverride("SunnyDayPath", ReplacerObjectName);
            MethodOverrides overrides = new MethodOverrides();
            overrides.Add(ovr);
            Expect.Call(mockDefinition.MethodOverrides).Return(overrides);

            Expect.Call(mockReplacer.Implement(null, null, null)).IgnoreArguments().Return(null);
            mocks.ReplayAll();

            DelegatingMethodReplacer replacer = new DelegatingMethodReplacer(mockDefinition, mockFactory);
            MethodInfo method = (MethodInfo) MethodBase.GetCurrentMethod();
            replacer.Implement(this, method, new object[] {});

            mocks.VerifyAll();
        }
        public void SunnyDayPath()
        {
            IObjectFactory mockFactory = A.Fake <IObjectFactory>();
            IConfigurableObjectDefinition mockDefinition = A.Fake <IConfigurableObjectDefinition>();
            IMethodReplacer mockReplacer = A.Fake <IMethodReplacer>();


            const string ReplacerObjectName = "replacer";

            A.CallTo(() => mockFactory.GetObject(ReplacerObjectName)).Returns(mockReplacer);

            ReplacedMethodOverride ovr       = new ReplacedMethodOverride("SunnyDayPath", ReplacerObjectName);
            MethodOverrides        overrides = new MethodOverrides();

            overrides.Add(ovr);
            A.CallTo(() => mockDefinition.MethodOverrides).Returns(overrides);

            A.CallTo(() => mockReplacer.Implement(null, null, null)).WithAnyArguments().Returns(null);

            DelegatingMethodReplacer replacer = new DelegatingMethodReplacer(mockDefinition, mockFactory);
            MethodInfo method = (MethodInfo)MethodBase.GetCurrentMethod();

            replacer.Implement(this, method, new object[] {});
        }