public void RunsInCScript() { var script = new TestScript(); script.AppendBlock(new JsHamcrestLibrary()); Assert.DoesNotThrow(() => script.RunTest(ScriptResources.JsHamcrestSampleTest)); }
public void RunsInCScript() { var script = new TestScript(); script.AppendBlock(new JsonLibrary()); Assert.Equal("\"1\"", script.RunTest("return JSON.stringify(JSON.parse('1'));")); }
public void RunTestThrowsScriptExceptionBackToCaller() { var script = new TestScript(); var ex = Assert.Throws<ScriptException>(() => script.RunTest("throw { message: 'My Script Exception' };")); Assert.Equal(ex.Message, "{\"message\":\"My Script Exception\"}"); }
public void IgnoresMultipleRegistrations() { var script = new TestScript(); script.AppendBlock(new JsHamcrestLibrary()); script.AppendBlock(new JsHamcrestLibrary()); Assert.DoesNotThrow(() => script.RunTest(ScriptResources.JsHamcrestSampleTest)); }
public void IgnoresMultipleRegistrations() { var script = new TestScript(); script.AppendBlock(new JsonLibrary()); script.AppendBlock(new JsonLibrary()); Assert.Equal("\"1\"", script.RunTest("return JSON.stringify(1);")); }
// Use this for initialization void Start () { InputM = GetComponent<InputManager>(); Movement = GetComponent<MovementManager>(); Tester = GetComponent<TestScript>(); isRunning = false; }
public void TestActionsInScript() { // make some actions var a = new TestAction("a"); var b = new TestAction("b"); var c = new TestAction("c"); var d = new TestAction("d"); var e = new TestAction("e"); var f = new TestAction("f"); var seq = new TestScript("test"); seq.Enqueue(new List<Action>() { a, b, c }); // make sure they're all enqueued but only A is activated Assert.IsTrue(!seq.IsEmpty && seq.Head == a); Assert.IsTrue(a.IsEnqueued && a.IsActive); Assert.IsTrue(b.IsEnqueued && !b.IsActive); Assert.IsTrue(c.IsEnqueued && !c.IsActive); // stop A, this should dequeue it and activate B a.Stop(true); Assert.IsTrue(!seq.IsEmpty && seq.Head == b); Assert.IsTrue(!a.IsEnqueued && !a.IsActive); Assert.IsTrue( b.IsEnqueued && b.IsActive); Assert.IsTrue( c.IsEnqueued && !c.IsActive); // stop the script, this should pop B and C without activating the latter seq.Clear(); Assert.IsTrue(seq.IsEmpty && seq.Head == null); Assert.IsTrue(!a.IsEnqueued && !a.IsActive && a.countActivate == 1 && a.countDeactivate == 1); Assert.IsTrue(!b.IsEnqueued && !b.IsActive && b.countActivate == 1 && b.countDeactivate == 1); Assert.IsTrue(!c.IsEnqueued && !c.IsActive && c.countActivate == 0 && c.countDeactivate == 0); // push two more seq.Enqueue(new List<Action>() { d, e }); Assert.IsTrue(d.IsEnqueued && d.IsActive && d.countActivate == 1 && d.countDeactivate == 0); Assert.IsTrue(e.IsEnqueued && !e.IsActive && e.countActivate == 0 && e.countDeactivate == 0); // pop E from the end, this should not affect D, or activate/deactivate E seq.PopTail(); Assert.IsTrue( d.IsEnqueued && d.IsActive && d.countActivate == 1 && d.countDeactivate == 0); Assert.IsTrue(!e.IsEnqueued && !e.IsActive && e.countActivate == 0 && e.countDeactivate == 0); // push F to the front, this should deactivate D but keep it in the queue seq.PushHead(f); Assert.IsTrue(f.IsEnqueued && f.IsActive && f.countActivate == 1 && f.countDeactivate == 0); Assert.IsTrue(d.IsEnqueued && !d.IsActive && d.countActivate == 1 && d.countDeactivate == 1); // now dequeue F from the front, this should pop it, and re-activate D seq.StopCurrentAction(true, null); Assert.IsTrue(!f.IsEnqueued && !f.IsActive && f.countActivate == 1 && f.countDeactivate == 1); Assert.IsTrue( d.IsEnqueued && d.IsActive && d.countActivate == 2 && d.countDeactivate == 1); }
public void AlwaysAppendBlockToExistingScript() { var block1 = new ScriptBlock("var x = 0;"); var block2 = new ScriptBlock("var y = 1;"); var block3 = new ScriptBlock("var z = 2;"); var script = new TestScript(); script.AppendBlock(block1); script.AppendBlock(block2); script.AppendBlock(block3); Assert.Equal(block1 + Environment.NewLine + block2 + Environment.NewLine + block3 + Environment.NewLine, script.ToString()); }
public void R_AutoFormatIfNoScope() { using (var script = new TestScript(RContentTypeDefinition.ContentType)) { script.Type("if(x>1)"); script.DoIdle(300); script.Type("{ENTER}a"); string expected = "if (x > 1)\r\n a"; string actual = script.EditorText; actual.Should().Be(expected); } }
public void R_AutoFormatFunctionBraces() { using (var script = new TestScript(RContentTypeDefinition.ContentType)) { script.Type("function(a,b){"); script.DoIdle(300); script.Type("{ENTER}a"); string expected = "function(a, b) {\r\n a\r\n}"; string actual = script.EditorText; actual.Should().Be(expected); } }
public void R_RequireIntellisense() { using (var script = new TestScript(RContentTypeDefinition.ContentType)) { script.Type("require(uti"); script.DoIdle(100); script.Type("{TAB}"); string expected = "require(utils)"; string actual = script.EditorText; actual.Should().Be(expected); } }
public void R_KeywordIntellisense() { using (var script = new TestScript(RContentTypeDefinition.ContentType)) { script.Type("funct"); script.DoIdle(100); script.Type("{TAB}"); string expected = "function"; string actual = script.EditorText; actual.Should().Be(expected); } }
public void AlwaysAppendBlockToExistingScript() { var block1 = new ScriptBlock("var x = 0;"); var block2 = new ScriptBlock("var y = 1;"); var block3 = new ScriptBlock("var z = 2;"); var script = new TestScript(new MsieJavaScriptEngine()); script.AppendBlock(block1); script.AppendBlock(block2); script.AppendBlock(block3); Assert.Equal(block1.ToInlineScriptFragment() + Environment.NewLine + block2.ToInlineScriptFragment() + Environment.NewLine + block3.ToInlineScriptFragment() + Environment.NewLine, script.ToString()); }
public IEnumerator RefuseDisabledBehaviour() { TestScript testScript = containingObject.AddComponent <TestScript>(); SerializableTypeBehaviourObservableList behaviourTypes = containingObject.AddComponent <SerializableTypeBehaviourObservableList>(); yield return(null); subject.BehaviourTypes = behaviourTypes; behaviourTypes.Add(typeof(TestScript)); testScript.enabled = false; Assert.IsFalse(container.Accepts(containingObject)); }
public void R_CompletionFilter02() { using (var script = new TestScript(RContentTypeDefinition.ContentType)) { script.Type("x <- lm"); script.DoIdle(100); script.Type("+"); string expected = "x <- lm+"; string actual = script.EditorText; actual.Should().Be(expected); } }
public void TestScriptsInQueue() { // make some scripts var a = new TestAction("a"); var b = new TestAction("b"); var c = new TestAction("c"); var abc = new TestScript("abc", a, b, c); var empty = new TestScript("empty"); var d = new TestAction("d"); var e = new TestAction("e"); var f = new TestAction("f"); var def = new TestScript("def", d, e, f); var q = new ScriptQueue(); q.Enqueue(new Script[] { abc, empty, def }); // verify the first script and action are active Assert.IsTrue(!q.IsEmpty && q.Head == abc && q.Head.Head == a); Assert.IsTrue(abc.IsEnqueued && abc.IsActive); Assert.IsTrue(empty.IsEnqueued && !empty.IsActive); Assert.IsTrue(def.IsEnqueued && !def.IsActive); // stop the first action, keeps the same script active a.Stop(true); Assert.IsTrue(!q.IsEmpty && q.Head == abc && q.Head.Head == b); // finish off actions. this will remove ABC from the queue b.Stop(true); c.Stop(true); Assert.IsTrue(!q.IsEmpty && q.Head != abc); Assert.IsTrue(abc.countActivate == 1 && abc.countDeactivate == 1); // the Empty script was activated but then immediately removed, because it's empty Assert.IsTrue(!empty.IsEnqueued && !empty.IsActive); Assert.IsTrue(empty.countActivate == 1 && empty.countDeactivate == 1); // and let's make sure that DEF is the active one now Assert.IsTrue(!q.IsEmpty && q.Head == def && q.Head.Head == d); Assert.IsTrue(!abc.IsEnqueued && !abc.IsActive); Assert.IsTrue(!empty.IsEnqueued && !empty.IsActive); Assert.IsTrue(def.IsEnqueued && def.IsActive); Assert.IsTrue(def.countActivate == 1 && def.countDeactivate == 0); // then if we force-stop DEF, it should clean out of the queue completely def.StopScript(true, null); Assert.IsTrue(q.IsEmpty && q.Head == null); Assert.IsTrue(!def.IsEnqueued && !def.IsActive); Assert.IsTrue(def.countActivate == 1 && def.countDeactivate == 1); }
public void R_AutoFormatScopeBraces07() { using (var script = new TestScript(RContentTypeDefinition.ContentType)) { REditorSettings.FormatOptions.BracesOnNewLine = true; script.Type("x <-function(a,{ENTER}b){ENTER}{"); script.DoIdle(300); script.Type("{ENTER}a"); string expected = "x <- function(a,\r\n b)\r\n{\r\n a\r\n}"; string actual = script.EditorText; actual.Should().Be(expected); } }
public IEnumerator RefusesInactiveGameObject() { TestScript testScript = containingObject.AddComponent <TestScript>(); SerializableTypeBehaviourObservableList behaviourTypes = containingObject.AddComponent <SerializableTypeBehaviourObservableList>(); yield return(null); subject.BehaviourTypes = behaviourTypes; behaviourTypes.Add(typeof(TestScript)); testScript.enabled = true; subject.gameObject.SetActive(false); Assert.IsFalse(container.Accepts(containingObject)); }
public void R_AutoFormatScopeBraces08() { using (var script = new TestScript("while (true) {\r\n}", RContentTypeDefinition.ContentType)) { REditorSettings.FormatOptions.BracesOnNewLine = true; script.MoveDown(); script.Enter(); string expected = "while (true)\r\n{\r\n\r\n}"; string actual = script.EditorText; actual.Should().Be(expected); } }
public static void DoIdle(int ms) { UIThreadHelper.Instance.Invoke(() => { int time = 0; while (time < ms) { TestScript.DoEvents(); VsAppShell.Current.DoIdle(); Thread.Sleep(20); time += 20; } }); }
public void R_SmartIndentTest01() { using (var script = new TestScript(string.Empty, RContentTypeDefinition.ContentType)) { REditorSettings.FormatOptions.BracesOnNewLine = false; script.MoveRight(); script.Type("{{ENTER}a"); script.DoIdle(300); string expected = "{\r\n a\r\n}"; string actual = script.EditorText; actual.Should().Be(expected); } }
public void R_AutoFormatFunctionArgument() { using (var script = new TestScript(RContentTypeDefinition.ContentType)) { REditorSettings.FormatOptions.BracesOnNewLine = false; script.Type("zzzz(a=1,{ENTER}"); script.DoIdle(300); script.Type("b=2"); string expected = "zzzz(a = 1,\r\n b=2)"; string actual = script.EditorText; actual.Should().Be(expected); } }
public void R_OutlineToggleAll() { string text = _files.LoadDestinationFile("lsfit.r"); using (var script = new TestScript(text, RContentTypeDefinition.ContentType)) { script.DoIdle(500); IOutliningManagerService svc = EditorShell.Current.ExportProvider.GetExportedValue <IOutliningManagerService>(); IOutliningManager mgr = svc.GetOutliningManager(EditorWindow.CoreEditor.View); var snapshot = EditorWindow.TextBuffer.CurrentSnapshot; var viewLines = EditorWindow.CoreEditor.View.TextViewLines; viewLines.Count.Should().Be(40); script.DoIdle(500); EditorWindow.ExecCommand(VSConstants.VSStd2K, (int)VSConstants.VSStd2KCmdID.OUTLN_TOGGLE_ALL); script.DoIdle(1000); IEnumerable <ICollapsed> collapsed = mgr.GetCollapsedRegions(new SnapshotSpan(snapshot, new Span(0, snapshot.Length))); collapsed.Count().Should().Be(20); EditorWindow.ExecCommand(VSConstants.VSStd2K, (int)VSConstants.VSStd2KCmdID.OUTLN_TOGGLE_ALL); script.DoIdle(500); viewLines = EditorWindow.CoreEditor.View.TextViewLines; viewLines.Count.Should().Be(40); EditorWindow.ExecCommand(VSConstants.VSStd2K, (int)VSConstants.VSStd2KCmdID.OUTLN_STOP_HIDING_ALL); script.DoIdle(200); mgr.Enabled.Should().Be(false); EditorWindow.ExecCommand(VSConstants.VSStd2K, (int)VSConstants.VSStd2KCmdID.OUTLN_START_AUTOHIDING); script.DoIdle(200); mgr.Enabled.Should().Be(true); script.MoveDown(9); EditorWindow.ExecCommand(VSConstants.VSStd2K, (int)VSConstants.VSStd2KCmdID.OUTLN_TOGGLE_CURRENT); script.DoIdle(500); collapsed = mgr.GetCollapsedRegions(new SnapshotSpan(snapshot, new Span(0, snapshot.Length))); collapsed.Count().Should().Be(1); EditorWindow.ExecCommand(VSConstants.VSStd2K, (int)VSConstants.VSStd2KCmdID.OUTLN_TOGGLE_CURRENT); script.DoIdle(200); collapsed = mgr.GetCollapsedRegions(new SnapshotSpan(snapshot, new Span(0, snapshot.Length))); collapsed.Count().Should().Be(0); } }
public void R_SelectWord03() { using (var script = new TestScript("abc\'def", RContentTypeDefinition.ContentType)) { script.Execute(Languages.Editor.Controller.Constants.VSConstants.VSStd2KCmdID.SELECTCURRENTWORD); var span = EditorWindow.CoreEditor.View.Selection.StreamSelectionSpan; var selectedWord = span.GetText(); selectedWord.Should().Be("abc"); script.MoveRight(2); script.Execute(Languages.Editor.Controller.Constants.VSConstants.VSStd2KCmdID.SELECTCURRENTWORD); span = EditorWindow.CoreEditor.View.Selection.StreamSelectionSpan; selectedWord = span.GetText(); selectedWord.Should().Be("def"); } }
private void UpdateLblTestScripts(TestScript testcaseScript) { if (lblPassedScripts.InvokeRequired) { var d = new SetTextCallback(UpdateLblTestScripts); Invoke(d, new object[] { testcaseScript }); } else { lblPassedScripts.Text = @"Passed scripts: " + _rcRunner.RunningTestsCount.TotPassed; lblFailedScripts.Text = @"Failed scripts: " + _rcRunner.RunningTestsCount.TotFailed; lblRunningScripts.Text = @"Running scripts: " + _rcRunner.RunningTestsCount.TotRunning; lblWatingScripts.Text = @"Waiting scripts: " + _rcRunner.RunningTestsCount.TotWaiting; } }
public void Test(TestCase testCase) { var script = new TestScript { IncludeDefaultBreakpoint = false }; // Append required JavaScript libraries. script.AppendBlock(new JsAssertLibrary()); // Append required JavaScript Files. script.AppendFile(@"..\..\dateExtensions.js"); script.AppendFile(@"..\..\cookieContainer.js"); script.AppendFile(testCase.TestFile); // Run 'Test'. script.RunTest(testCase); }
public static void DoIdle(int ms) { UIThreadHelper.Instance.Invoke(() => { var idle = VsAppShell.Current.GetService <IIdleTimeSource>(); int time = 0; while (time < ms) { TestScript.DoEvents(); idle.DoIdle(); Thread.Sleep(20); time += 20; } }); }
public void R_NoCompletionOnTabInComment() { // Tab only completes when selected item starts // with the text typed so far in the buffer using (var script = new TestScript(RContentTypeDefinition.ContentType)) { script.DoIdle(100); script.Type("#com"); script.DoIdle(300); script.Type("{TAB}a"); script.DoIdle(100); string actual = script.EditorText; actual.Should().Be("#com a"); // Tab was not consumed } }
public async Task TestForeachWithLargeItems() { var testFlow = new TestScript() { Dialog = new ForeachItemsDialog() } .SendConversationUpdate(); for (var i = 0; i < 1000; i++) { testFlow = testFlow.AssertReply(i.ToString()); } await testFlow.ExecuteAsync(ResourceExplorer); }
public void R_AutoFormatFunctonArguments02() { using (var script = new TestScript(RContentTypeDefinition.ContentType)) { string text = "x <-function (x,y,{ENTER}wt= NULL){ENTER}"; script.Type(text); script.DoIdle(300); string actual = script.EditorText; string expected = "x <- function(x, y,\r\n" + " wt = NULL)\r\n"; actual.Should().Be(expected); } }
public void R_AutoFormatScopeBraces04() { using (var script = new TestScript(RContentTypeDefinition.ContentType)) { REditorSettings.FormatOptions.BracesOnNewLine = false; script.Type("while(true) {"); script.DoIdle(300); script.Type("}"); string expected = "while (true) { }"; string actual = script.EditorText; actual.Should().Be(expected); } }
public void R_AutoFormatFuncionDefinition04() { using (var script = new TestScript(RContentTypeDefinition.ContentType)) { string text = "function(){return(1)}"; script.Type(text); script.DoIdle(300); script.Enter(); string actual = script.EditorText; string expected = @"function() { return(1) } "; actual.Should().Be(expected); } }
/// <summary> /// 加载测试数据 /// </summary> /// <param name="testScriptFileName"></param> private void LoadTestScript(string testScriptFileName) { string scriptString = ""; using (System.IO.StreamReader sr = System.IO.File.OpenText(testScriptFileName)) { scriptString = sr.ReadToEnd(); } ITestScriptParser parser = new AutoTestFramework.SeleniumTestEngine.SeleniumIdeHtmlScriptParser(); scriptModel = parser.Parse(scriptString); textBox3.Text = scriptModel.StartUrl; textBox4.Text = scriptModel.Title; dataGridView1.DataSource = new List <TestCommand>(scriptModel.GetCommandList()); }
public void R_ProvisionalCurlyBrace01() { using (var script = new TestScript(RContentTypeDefinition.ContentType)) { REditorSettings.FormatOptions.BracesOnNewLine = false; script.Type("while(1)"); script.DoIdle(300); script.Type("{"); script.DoIdle(300); script.Type("{ENTER}}"); string expected = "while (1) {\r\n}"; string actual = script.EditorText; actual.Should().Be(expected); } }
public void R_AutoFormatScopeBraces10() { using (var script = new TestScript(RContentTypeDefinition.ContentType)) { REditorSettings.FormatOptions.BracesOnNewLine = false; script.Type("if(TRUE){"); script.DoIdle(300); script.Type("{ENTER}a"); script.MoveDown(); script.MoveRight(); script.Type("{ENTER}"); string expected = "if (TRUE) {\r\n a\r\n}\r\n"; string actual = script.EditorText; actual.Should().Be(expected); } }
public void R_NoCompletionOnTabWhenNoMatch() { // Tab only completes when selected item starts // with the text typed so far in the buffer using (var script = new TestScript(RContentTypeDefinition.ContentType)) { script.DoIdle(100); script.Type("while aaa"); script.DoIdle(300); script.Type("{TAB}"); script.DoIdle(100); string actual = script.EditorText; actual.Should().Be("while aaa"); // nothing was inserted from the completion list EditorWindow.CoreEditor.View.Caret.Position.BufferPosition.Position.Should().Be(actual.Length); } }
private void UpdateListView(TestScript testcaseScript) { if (listViewTestScripts.InvokeRequired) { var d = new SetTextCallback(UpdateListView); Invoke(d, new object[] { testcaseScript }); } else { var item = listViewTestScripts.FindItemWithText(testcaseScript.Name, true, 0); if (item == null) { return; } UpdateListviewItemBasedOnTestStatus(testcaseScript, item); } }
public void Setup() { Script = new TestScript { IncludeDefaultBreakpoint = false }; // Append required JavaScript libraries. Script.AppendBlock(new JsAssertLibrary()); // Append required JavaScript Files. Script.AppendFile(@"..\..\dateExtensions.js"); Script.AppendFile(@"..\..\cookieContainer.js"); Script.AppendFile(@"..\..\whenSettingCookies.js"); // Setup JavaScript Context Script.AppendBlock(@" var document = {}; var cookieContainer = new CookieContainer(document); "); }
public void AlwaysAppendIncludeToExistingScript() { using (var tempFile1 = new TempFile()) using (var tempFile2 = new TempFile()) using (var tempFile3 = new TempFile()) { var script = new TestScript(); script.AppendFile(tempFile1.FileName); script.AppendFile(tempFile2.FileName); script.AppendFile(tempFile3.FileName); Assert.Equal(String.Format( @"<script language='JavaScript' src='{0}'></script>{3}<script language='JavaScript' src='{1}'></script>{3}<script language='JavaScript' src='{2}'></script>{3}", tempFile1.FileName, tempFile2.FileName, tempFile3.FileName, Environment.NewLine ), script.ToString()); } }
public void TestActionStartupAndUpdate() { // make some actions var a = new TestAction("a"); var b = new TestAction("b"); var c = new TestAction("c", true); // this one stops before first update var seq = new TestScript("test", a, b, c); Assert.IsTrue(a.IsEnqueued && a.IsActive && !a.IsStarted); Assert.IsTrue(a.countUpdate == 0); // fake an update cycle seq.OnUpdate(); Assert.IsTrue(a.IsEnqueued && a.IsActive && a.IsStarted); Assert.IsTrue(a.countUpdate == 1); // stop. this will remove and deactivate A, and activate B, // but not start it yet until an update a.Stop(true); Assert.IsTrue(!a.IsEnqueued && !a.IsActive && !a.IsStarted); Assert.IsTrue( b.IsEnqueued && b.IsActive && !b.IsStarted); Assert.IsTrue(a.countUpdate == 1); Assert.IsTrue(b.countUpdate == 0); seq.OnUpdate(); Assert.IsTrue(b.IsEnqueued && b.IsActive && b.IsStarted); Assert.IsTrue(b.countUpdate == 1); // stop b. this will activate c, which will stop itself before first update b.Stop(true); Assert.IsTrue(c.IsEnqueued && c.IsActive && !c.IsStarted); Assert.IsTrue(c.countUpdate == 0); seq.OnUpdate(); Assert.IsTrue(!c.IsEnqueued && !c.IsActive && !c.IsStarted); Assert.IsTrue(c.countUpdate == 0); // this update never got a chance to run }
public void TestScriptsInQueue() { // make some scripts var a = new TestAction("a"); var b = new TestAction("b"); var c = new TestAction("c"); var abc = new TestScript("abc", a, b, c); var empty = new TestScript("empty"); var d = new TestAction("d"); var e = new TestAction("e"); var f = new TestAction("f"); var def = new TestScript("def", d, e, f ); var q = new ScriptQueue(); q.Enqueue(new List<Script>() { abc, empty, def }); // verify the first script and action are active Assert.IsTrue(!q.IsEmpty && q.Head == abc && q.Head.Head == a); Assert.IsTrue( abc.IsEnqueued && abc.IsActive); Assert.IsTrue(empty.IsEnqueued && !empty.IsActive); Assert.IsTrue( def.IsEnqueued && !def.IsActive); // stop the first action, keeps the same script active a.Stop(true); Assert.IsTrue(!q.IsEmpty && q.Head == abc && q.Head.Head == b); // finish off actions. this will remove ABC from the queue b.Stop(true); c.Stop(true); Assert.IsTrue(!q.IsEmpty && q.Head != abc); Assert.IsTrue(abc.countActivate == 1 && abc.countDeactivate == 1); // the Empty script was activated but then immediately removed, because it's empty Assert.IsTrue(!empty.IsEnqueued && !empty.IsActive); Assert.IsTrue(empty.countActivate == 1 && empty.countDeactivate == 1); // and let's make sure that DEF is the active one now Assert.IsTrue(!q.IsEmpty && q.Head == def && q.Head.Head == d); Assert.IsTrue( !abc.IsEnqueued && !abc.IsActive); Assert.IsTrue(!empty.IsEnqueued && !empty.IsActive); Assert.IsTrue( def.IsEnqueued && def.IsActive); Assert.IsTrue(def.countActivate == 1 && def.countDeactivate == 0); // then if we force-stop DEF, it should clean out of the queue completely def.StopScript(true, null); Assert.IsTrue(q.IsEmpty && q.Head == null); Assert.IsTrue(!def.IsEnqueued && !def.IsActive); Assert.IsTrue(def.countActivate == 1 && def.countDeactivate == 1); }
public void RunTestIncludesDefaultDebuggerStatementByDefault() { var cscriptCommand = new FakeCScriptCommand(); var script = new TestScript(cscriptCommand); script.RunTest("return true;"); Assert.True(cscriptCommand.ScriptContainedDebuggerStatement); }
public static TestScript CreateTestScript(int id) { TestScript testScript = new TestScript(); testScript.ID = id; return testScript; }
public void AddToTestScripts(TestScript testScript) { base.AddObject("TestScripts", testScript); }
public void RunTestIncludesDefaultDebuggerStatementIfRequested() { var cscriptCommand = new FakeCScriptCommand(); var script = new TestScript(cscriptCommand) { IncludeDefaultBreakpoint = true }; script.RunTest("return true;"); Assert.True(cscriptCommand.ScriptContainedDebuggerStatement); }
void Awake() { instance = this; }
public void TestQueueUpdate() { // make some scripts var a = new TestAction("a"); var b = new TestAction("b"); var c = new TestAction("c"); var abc = new TestScript("abc", a, b, c); var d = new TestAction("d"); var e = new TestAction("e"); var f = new TestAction("f"); var def = new TestScript("def", d, e, f); var q = new ScriptQueue(); q.Enqueue(new List<Script>() { abc, def }); Assert.IsTrue(a.IsEnqueued && a.IsActive && !a.IsStarted); // fake a queue update q.OnUpdate(); Assert.IsTrue(a.IsEnqueued && a.IsActive && a.IsStarted); // stop the script. the first action in the next script // will be activated, but won't be started until another update q.StopCurrentScript(true, null); Assert.IsTrue(!abc.IsEnqueued && !abc.IsActive && !a.IsActive && !a.IsStarted); Assert.IsTrue(def.IsEnqueued && def.IsActive && d.IsActive && !d.IsStarted); q.OnUpdate(); Assert.IsTrue(def.IsEnqueued && def.IsActive && d.IsActive && d.IsStarted); // clear everything. no more updates q.StopAllScripts(true, null); Assert.IsTrue(!def.IsEnqueued && !def.IsActive && !d.IsActive && !d.IsStarted); Assert.IsTrue(q.IsEmpty); }
public void RunTestReturnsValueWhenExplicitReturnSpecified() { var script = new TestScript(); Assert.Equal("\"Success!\"", script.RunTest("return 'Success!';")); }
private void Awake() { Instance = this; controller = GetComponent<CharacterController>(); }
public void TestStopOnFailure() { // make some scripts var a = new TestAction("a"); var b = new TestAction("b"); var c = new TestAction("c"); var abc = new TestScript("abc", a, b, c); var d = new TestAction("d"); var e = new TestAction("e"); var f = new TestAction("f"); var def = new TestScript("def", d, e, f); var q = new ScriptQueue(); q.Enqueue(new List<Script>() { abc, def }); q.OnUpdate(); Assert.IsTrue(a.IsEnqueued && a.IsActive && a.IsStarted); // if we stop just action a with the failure flag set, it should stop the entire script // and advance to the next one abc.StopCurrentAction(false, null); Assert.IsTrue(!a.IsEnqueued && !a.IsActive); Assert.IsTrue(!abc.IsEnqueued && !abc.IsActive); Assert.IsTrue(def.IsActive && d.IsActive); // similary stopping the script will just remove it def.StopScript(false, null); Assert.IsTrue(!def.IsActive && !d.IsActive); }
public void RunTestDoesNotIncludeDefaultDebuggerStatementIfSuppressed() { var cscriptCommand = new FakeCScriptCommand(); var script = new TestScript(cscriptCommand) { IncludeDefaultBreakpoint = false }; script.RunTest("return true;"); Assert.False(cscriptCommand.ScriptContainedDebuggerStatement); }
protected JavaScriptTestBase(Boolean includeDefaultBreakpoint) { Script = new TestScript { IncludeDefaultBreakpoint = includeDefaultBreakpoint }; }
// Use this for initialization void Awake() { Instance = this; pMove = player.GetComponent<TestScript>(); }
public void RunTestReturnsNullWhenNoReturnSpecified() { var script = new TestScript(); Assert.Equal("null", script.RunTest("var result = 'Success!';")); }