public void TestFourArgSignal() { Signal<int, int, int, int> signal = new Signal<int, int, int, int>(); int intendedResult = ((testInt + testIntTwo) * testIntThree) - testIntFour; signal.AddListener(FourArgSignalCallback); signal.Dispatch(testInt, testIntTwo, testIntThree, testIntFour); Assert.AreEqual(intendedResult, testValue); signal.RemoveListener(FourArgSignalCallback); signal.Dispatch(testInt, testIntTwo, testIntThree, testIntFour); Assert.AreEqual(intendedResult, testValue); //no-op due to remove intendedResult += testInt; intendedResult += testIntTwo; intendedResult *= testIntThree; intendedResult -= testIntFour; signal.AddOnce(FourArgSignalCallback); signal.Dispatch(testInt, testIntTwo, testIntThree, testIntFour); Assert.AreEqual(intendedResult, testValue); signal.Dispatch(testInt, testIntTwo, testIntThree, testIntFour); Assert.AreEqual(intendedResult, testValue); //Add once should result in no-op }
public void TestTwoArgSignal() { Signal<int, int> signal = new Signal<int, int>(); signal.AddListener(TwoArgSignalCallback); signal.Dispatch(testInt, testIntTwo); Assert.AreEqual(testInt + testIntTwo, testValue); signal.RemoveListener(TwoArgSignalCallback); signal.Dispatch(testInt, testIntTwo); Assert.AreEqual(testInt + testIntTwo, testValue); //Removed listener should have no-op signal.AddOnce(TwoArgSignalCallback); signal.Dispatch(testInt, testIntTwo); Assert.AreEqual((testInt + testIntTwo) * 2, testValue); signal.Dispatch(testInt, testIntTwo); Assert.AreEqual((testInt + testIntTwo) * 2, testValue); //addonce should result in no-op }
public void RemoveBinding() { Signal.RemoveListener(Callback); }
public void RemoveListener_NoType_ExpectsListenerRemoved() { Signal signal = new Signal(); signal.AddListener(NoArgSignalCallback); signal.Dispatch(); Assert.AreEqual(1, testValue); signal.RemoveListener(NoArgSignalCallback); signal.Dispatch(); Assert.AreEqual(1, testValue); }
public void TestRemoveListener() { Signal<int> signal = new Signal<int>(); signal.AddListener(OneArgSignalCallback); signal.Dispatch(testInt); Assert.AreEqual(testInt, testValue); signal.RemoveListener(OneArgSignalCallback); signal.Dispatch(testInt); Assert.AreEqual(testInt, testValue); }
public void TestRemoveListenerDoesntBlowUpFour() { Signal<int,int,int,int> signal = new Signal<int,int,int,int>(); signal.RemoveListener(FourArgSignalCallback); }
public void TestRemoveListenerDoesntBlowUpOne() { Signal<int> signal = new Signal<int>(); signal.RemoveListener(OneArgSignalCallback); }
public void TestRemoveListenerDoesntBlowUp() { Signal signal = new Signal(); signal.RemoveListener(NoArgSignalCallback); }
virtual public void RemoveListener(Action callback) { specificSignal.RemoveListener(callback); }