public void Awake() { m_Dispatcher = DispatcherFactory.GetDispatcher(); m_ApplicationContextTarget = ApplicationContext.BindTarget(m_UIApplicationState); m_DebugContextTarget = DebugOptionContext.BindTarget(m_UIDebugState); DispatchToken = m_Dispatcher.Register <Payload <IViewerAction> >(InvokeOnDispatch); }
public void UIContextsTests_ApplicationContext_IsAbleSupportTwoContextTwoPropertiesWithEachOneValueChanged() { //Given a defined data struct is registered var updateDelegateWasCalled1 = 0; var updateDelegateWasCalled2 = 0; var data1 = new InternalData(); var contextTarget1 = ApplicationContext.BindTarget(data1); var data2 = new DifferentData(); var contextTarget2 = DebugOptionContext.BindTarget(data2); //When a UISelector is created var getter = UISelector.createSelector <bool>(ApplicationContext.current, "trueOrFalse", (trueOrFalse) => { updateDelegateWasCalled1++; }); var getterString = UISelector.createSelector <string>(DebugOptionContext.current, "aDifferentString", (aString) => { updateDelegateWasCalled2++; }); //Then I should be able to invoke the update lambda data1.trueOrFalse = true; contextTarget1.UpdateWith(ref data1); data2.aDifferentString = "changed"; contextTarget2.UpdateWith(ref data2); //Verify Getter returned True Assert.IsTrue(getter(), "Getter should return True"); //Verify Getter returned "changed" Assert.IsTrue(getterString().Equals("changed"), "Getter should return 'changed'"); //Verify the update lambda was invoked Assert.IsTrue(updateDelegateWasCalled1 == 1, "Verify the update lambdas were invoked ApplicationContext"); Assert.IsTrue(updateDelegateWasCalled1 == 1, "Verify the update lambdas were invoked DebugContext"); }