public void AdvisedSupportListenerMethodsAre_NOT_CalledIfProxyHasNotBeenCreated() { IAdvisedSupportListener listener = A.Fake <IAdvisedSupportListener>(); ProxyFactory factory = new ProxyFactory(new TestObject()); factory.AddListener(listener); // must not fire the AdviceChanged callback... factory.AddAdvice(new NopInterceptor()); // must not fire the InterfacesChanged callback... factory.AddInterface(typeof(ISerializable)); A.CallTo(() => listener.AdviceChanged(A <AdvisedSupport> ._)).MustNotHaveHappened(); A.CallTo(() => listener.InterfacesChanged(A <AdvisedSupport> ._)).MustNotHaveHappened(); }
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(); }
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(); }