Пример #1
0
        public void RemoveAdvisedSupportListener()
        {
            IAdvisedSupportListener listener = A.Fake <IAdvisedSupportListener>();

            ProxyFactory factory = new ProxyFactory(new TestObject());

            factory.AddListener(listener);
            factory.RemoveListener(listener);

            factory.GetProxy();

            // check that no lifecycle callback methods were invoked on the listener...
            A.CallTo(() => listener.Activated(null)).WithAnyArguments().MustNotHaveHappened();
            A.CallTo(() => listener.AdviceChanged(null)).WithAnyArguments().MustNotHaveHappened();
            A.CallTo(() => listener.InterfacesChanged(null)).WithAnyArguments().MustNotHaveHappened();
        }
Пример #2
0
        public void AddAdvisedSupportListener()
        {
            //MLP SPRNET-1367
            //IDynamicMock mock = new DynamicMock(typeof(IAdvisedSupportListener));
            //IAdvisedSupportListener listener = (IAdvisedSupportListener)mock.Object;
            IAdvisedSupportListener listener = A.Fake <IAdvisedSupportListener>();
            //listener.Activated();
            //mock.Expect("Activated");

            ProxyFactory factory = new ProxyFactory(new TestObject());

            factory.AddListener(listener);
            factory.GetProxy();

            A.CallTo(() => listener.Activated(A <AdvisedSupport> ._)).MustHaveHappened();
        }
Пример #3
0
        public void AdvisedSupportListenerMethodsAreCalledAppropriately()
        {
            IAdvisedSupportListener listener = A.Fake <IAdvisedSupportListener>();

            ProxyFactory factory = new ProxyFactory(new TestObject());

            factory.AddListener(listener);

            // must fire the Activated callback...
            factory.GetProxy();
            // must fire the AdviceChanged callback...
            factory.AddAdvice(new NopInterceptor());
            // must fire the InterfacesChanged callback...
            factory.AddInterface(typeof(ISerializable));

            A.CallTo(() => listener.Activated(A <AdvisedSupport> .That.Not.IsNull())).MustHaveHappened();
            A.CallTo(() => listener.AdviceChanged(A <AdvisedSupport> .That.Not.IsNull())).MustHaveHappened();
            A.CallTo(() => listener.InterfacesChanged(A <AdvisedSupport> .That.Not.IsNull())).MustHaveHappened();
        }
Пример #4
0
        public void AddAdvisedSupportListener()
        {
            //MLP SPRNET-1367
            //IDynamicMock mock = new DynamicMock(typeof(IAdvisedSupportListener));
            //IAdvisedSupportListener listener = (IAdvisedSupportListener)mock.Object;
            IAdvisedSupportListener listener =
                (IAdvisedSupportListener)mocks.CreateMock(typeof(IAdvisedSupportListener));

            listener.Activated(null);
            LastCall.On(listener).IgnoreArguments();
            //listener.Activated();
            //mock.Expect("Activated");

            mocks.ReplayAll();
            ProxyFactory factory = new ProxyFactory(new TestObject());

            factory.AddListener(listener);
            factory.GetProxy();
            mocks.VerifyAll();
        }