public void BuildTest() { var builder = new CodeStateMachineBuilder <TestStates, TestActions>(); builder .StartWith(TestStates.Default) .Move(TestStates.Default, TestActions.Save, TestStates.Draft) .Move(TestStates.Draft, TestActions.Check, TestStates.Checked) .Move(TestStates.Draft, TestActions.Delete, TestStates.Deleted) .Move(TestStates.Checked, TestActions.Check, TestStates.DoubleChecked) .Move(TestStates.Checked, TestActions.Recall, TestStates.Recalled) .Move(TestStates.DoubleChecked, TestActions.Recall, TestStates.Recalled) ; var machine = builder.Build(); TestStates ts = TestStates.Default; machine.Pushed += (sender, e) => { ts = e.NewState; }; machine.Push(TestActions.Save); Assert.AreEqual(TestStates.Draft, ts); machine.Push(TestActions.Check); Assert.AreEqual(TestStates.Checked, ts); machine.Push(TestActions.Check); Assert.AreEqual(TestStates.DoubleChecked, ts); }
public void TestLastStatePropBeforeChange() { var fsm = new StateMachine <TestStates, StateDriverUnity>(behaviour); Assert.Throws <NullReferenceException>(() => { TestStates state = fsm.LastState; }); Assert.IsFalse(fsm.LastStateExists); fsm.ChangeState(TestStates.StateInit); //Conflicted about this. Prefer to return default values, or the current state //but that would undermine correctness Assert.Throws <NullReferenceException>(() => { TestStates state = fsm.LastState; }); Assert.IsFalse(fsm.LastStateExists); fsm.ChangeState(TestStates.StatePlay); Assert.AreEqual(TestStates.StateInit, fsm.LastState); Assert.IsTrue(fsm.LastStateExists); }
private void Reset() { _curPart = -1; state = TestStates.Ready; wrongWords = new List<Word>(); selectedWords = getTestWords(_dictionary); }
public void TestGetStates(int i, string expected) { TestStates myTestRepo = new TestStates(); List <State> result = myTestRepo.GetStates(); string stateAbbrev = result[i].StateAbbreviation; Assert.AreEqual(expected, stateAbbrev); }
public void TestStateComponentInitialisation() { StateComponent <TestStates> actual = new StateComponent <TestStates>(TestStates.s1); TestStates expected = TestStates.s1; Assert.AreEqual(expected, actual.Peek(), "Test that the initialising state is the one passed in the constructor"); }
public JsUnitTest(IWebBrowser browser, string inputJs, string evaluateJs, string expectedJavaScriptResult) { _browser = browser; InputJs = inputJs; EvaluateJs = evaluateJs; ExpectedJavaScriptResult = expectedJavaScriptResult; InputState = TestStates.NotRunning; CheckState = TestStates.NotRunning; }
public void TestStateSwitch() { StateComponent <TestStates> actual = new StateComponent <TestStates>(TestStates.s1); actual.Switch(TestStates.s3); TestStates expected = TestStates.s3; Assert.AreEqual(expected, actual.Peek(), "Test that the state has changed once the stateis asked to switch"); }
public void TestStateComponentPush() { StateComponent <TestStates> actual = new StateComponent <TestStates>(TestStates.s1); actual.Push(TestStates.s2); TestStates expected = TestStates.s2; Assert.AreEqual(expected, actual.Peek(), "Test that the peeked state after a push is the topmost state"); }
public void TestStateComponentPop() { StateComponent <TestStates> actual = new StateComponent <TestStates>(TestStates.s1); actual.Push(TestStates.s2); actual.Pop(); TestStates expected = TestStates.s1; Assert.AreEqual(expected, actual.Peek(), "Test that the peeked state is the same after a push and pop"); }
public void TestStatePropBeforeChange() { var fsm = new StateMachine <TestStates, StateDriverUnity>(behaviour); Assert.Throws <NullReferenceException>(() => { TestStates state = fsm.State; }); fsm.ChangeState(TestStates.StateInit); Assert.AreEqual(TestStates.StateInit, fsm.State); }
private TestStates getNextState(TestStates state) { switch (state) { case TestStates.State1: return(TestStates.State2); case TestStates.State2: return(TestStates.State3); case TestStates.State3: return(TestStates.State1); } return(TestStates.State1); }
public async Task RunTest() { InputState = TestStates.Running; var response = await _browser.EvaluateScriptAsync(InputJs); InputState = response.Success ? TestStates.Passed : TestStates.Failed; InputJsResult = response.Result?.ToString() ?? ""; if (InputState == TestStates.Failed) { return; } var evalResponse = await _browser.EvaluateScriptAsync(EvaluateJs); ActualJavaScriptResult = evalResponse.Result?.ToString() ?? ""; CheckState = ActualJavaScriptResult == ExpectedJavaScriptResult ? TestStates.Passed : TestStates.Failed; }
public void PushAndCheckStateIsRightByEventOfPushed() { var builder = CsvStateMachineBuilder <TestStates, TestActions> .FromFile("./Resources/Doc.csv"); var machine = builder.Build(); TestStates ts = TestStates.Default; machine.Pushed += (sender, e) => { ts = e.NewState; }; machine.Push(TestActions.Save); Assert.AreEqual(TestStates.Draft, ts); machine.Push(TestActions.Check); Assert.AreEqual(TestStates.Checked, ts); machine.Push(TestActions.Check); Assert.AreEqual(TestStates.DoubleChecked, ts); }
public void Convert_MatchingKeyExcludeFallback_ReturnsDictionaryValue(TestStates state, string expected) { var converted = Convert(state, null, new Tuple <IDictionary <TestStates, string>, string, bool>(_testStatedictionary, default(string), false), CultureInfo.CurrentUICulture); Assert.Equal(expected, converted); }
private void FSM_SwitchingFromStateTwoToStateThree (TestStates oldState, TestStates newState) { Debug.Log ("Switching from Two to Three"); }
private void FSM_ExitStateTwo (TestStates nextState) { Debug.Log ("Exit State Two"); switchCondition = false; }
private void FSM_EnterStateTwo (TestStates previousState) { Debug.Log ("Enter State Two"); }
private void FSM_SwitchingFromStateOneToStateTwo (TestStates oldState, TestStates newState) { Debug.Log ("Switching from One to Two"); }
private void FSM_EnterStateOne (TestStates previousState) { Debug.Log ("Enter State One"); }
public void TestStripSpaces(string input, string expected) { string result = TestStates.StripSpaces(input); Assert.AreEqual(expected, result); }
private void changeState(TestStates state) { this.State = state; }
public void Cancel() { if (this.CurrentPart != null) this.CurrentPart.Cancel(); this.State = TestStates.Cancelled; }