public void AddAndRemoveEventHandlerThroughIntroduction() { TestObject target = new TestObject(); DoubleClickableIntroduction dci = new DoubleClickableIntroduction(); DefaultIntroductionAdvisor advisor = new DefaultIntroductionAdvisor(dci); CountingBeforeAdvice countingBeforeAdvice = new CountingBeforeAdvice(); target.Name = "SOME-NAME"; ProxyFactory pf = new ProxyFactory(target); pf.AddIntroduction(advisor); pf.AddAdvisor(new DefaultPointcutAdvisor(countingBeforeAdvice)); object proxy = pf.GetProxy(); ITestObject to = proxy as ITestObject; Assert.IsNotNull(to); Assert.AreEqual("SOME-NAME", to.Name); IDoubleClickable doubleClickable = proxy as IDoubleClickable; // add event handler through introduction doubleClickable.DoubleClick += new EventHandler(OnClick); OnClickWasCalled = false; doubleClickable.FireDoubleClickEvent(); Assert.IsTrue(OnClickWasCalled); Assert.AreEqual(3, countingBeforeAdvice.GetCalls()); // remove event handler through introduction doubleClickable.DoubleClick -= new EventHandler(OnClick); OnClickWasCalled = false; doubleClickable.FireDoubleClickEvent(); Assert.IsFalse(OnClickWasCalled); Assert.AreEqual(5, countingBeforeAdvice.GetCalls()); }
//[SerializeField] private ThingRuntimeSet allWorldObjects; //[SerializeField] private List<RecipeType> allCraftRecipes = new List<RecipeType>(); #endregion #region MonoBehavior Functions private void Awake() { //DelegateManager.connectedTowers = _connectedTowers; _rayProvider = GetComponent <IRayProvider>(); _selector = GetComponent <ISelector>(); _clickResponse = GetComponent <IClickable>(); _doubleClickResponse = GetComponent <IDoubleClickable>(); DelegateManager.infoPanel = _infoPanel; }