コード例 #1
0
        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);
    }
コード例 #3
0
ファイル: Test.cs プロジェクト: iv22/Dictionary
 private void Reset()
 {
     _curPart = -1;
     state = TestStates.Ready;
     wrongWords = new List<Word>();
     selectedWords = getTestWords(_dictionary);
 }
コード例 #4
0
        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);
        }
コード例 #5
0
        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");
        }
コード例 #6
0
 public JsUnitTest(IWebBrowser browser, string inputJs, string evaluateJs, string expectedJavaScriptResult)
 {
     _browser   = browser;
     InputJs    = inputJs;
     EvaluateJs = evaluateJs;
     ExpectedJavaScriptResult = expectedJavaScriptResult;
     InputState = TestStates.NotRunning;
     CheckState = TestStates.NotRunning;
 }
コード例 #7
0
        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");
        }
コード例 #8
0
        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");
        }
コード例 #9
0
        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);
    }
コード例 #11
0
        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);
        }
コード例 #12
0
            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;
            }
コード例 #13
0
        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);
        }
コード例 #15
0
		private void FSM_SwitchingFromStateTwoToStateThree (TestStates oldState, TestStates newState)
		{
			Debug.Log ("Switching from Two to Three");
		}
コード例 #16
0
		private void FSM_ExitStateTwo (TestStates nextState)
		{
			Debug.Log ("Exit State Two");
			switchCondition = false;
		}
コード例 #17
0
		private void FSM_EnterStateTwo (TestStates previousState)
		{
			Debug.Log ("Enter State Two");
		}
コード例 #18
0
		private void FSM_SwitchingFromStateOneToStateTwo (TestStates oldState, TestStates newState)
		{
			Debug.Log ("Switching from One to Two");
		}
コード例 #19
0
		private void FSM_EnterStateOne (TestStates previousState)
		{
			Debug.Log ("Enter State One");
		}
コード例 #20
0
        public void TestStripSpaces(string input, string expected)
        {
            string result = TestStates.StripSpaces(input);

            Assert.AreEqual(expected, result);
        }
コード例 #21
0
ファイル: Test.cs プロジェクト: iv22/Dictionary
 private void changeState(TestStates state)
 {
     this.State = state;
 }
コード例 #22
0
ファイル: Test.cs プロジェクト: iv22/Dictionary
 public void Cancel()
 {
     if (this.CurrentPart != null)
         this.CurrentPart.Cancel();
     this.State = TestStates.Cancelled;
 }