Exemple #1
0
        public void TestStepsIndexAndTitle()
        {
            var taskContext = ExecutionHelper.ExeContext();
            var procedure   = this.CreateTestFile("Christian");

            taskContext.CallProcedure(procedure);
            var log = new LogInspector(taskContext.Logger);

            log.ExpectNext("0 - Pre - TestRun - Starting");
            log.ExpectNext("1 - Pre - MyFile.Christian - <arguments>");
            log.ExpectNext("2 - Normal - 16 - STEP #1 : First");
            log.ExpectNext("2 - Normal - 17 - STEP #2 : Second");
            log.ExpectNext("2 - Normal - 18 - STEP #3 : Third");
            log.ExpectNext("2 - Post");
            log.ExpectEnd();
        }
Exemple #2
0
        public void TestStepsIndexNoTitle()
        {
            var taskContext = ExecutionHelper.ExeContext();
            var procedure   = this.CreateTestFile("Anders");

            taskContext.CallProcedure(procedure);
            var log = new LogInspector(taskContext.Logger);

            log.ExpectNext("0 - Pre - TestRun - Starting");
            log.ExpectNext("1 - Pre - MyFile.Anders - <arguments>");
            log.ExpectNext("2 - Normal - 4 - STEP #1");
            log.ExpectNext("2 - Normal - 5 - STEP #2");
            log.ExpectNext("2 - Normal - 6 - STEP #3");
            log.ExpectNext("2 - Post");
            log.ExpectEnd();
        }
        public void ProcedureCallSimpleNoParamsNoReturn2Levels()
        {
            var taskContext = ExecutionHelper.ExeContext();

            var procedure = this.CreateTestFileNoParams("Bent", "AB");

            taskContext.CallProcedure(procedure);
            var log = new LogInspector(taskContext.Logger);

            log.ExpectNext("0 - Pre - TestRun - Starting");
            log.ExpectNext("1 - Pre - MyFile.Bent - <arguments>");
            log.ExpectNext("2 - Normal - 6 - log: This is Bent");
            log.ExpectNext("2 - Pre - MyFile.Anders - <arguments>");
            log.ExpectNext("3 - Normal - 3 - log: This is Anders");
            log.ExpectNext("3 - Post");
            log.ExpectNext("2 - Post");
            log.ExpectEnd();
        }
Exemple #4
0
        public void TestLineReaderAwait()
        {
            var f = new StringBuilder();

            f.AppendLine("string MyProcedure() {");
            f.AppendLine("   string[] myArr = [\"Anders\", \"Bent\", \"Christian\", \"Dennis\"];");
            f.AppendLine("   var reader = myArr.ToLineReader();");
            f.AppendLine("   var found = reader.Await(\"Dennis\", 2s);");
            f.AppendLine("   return found;");
            f.AppendLine("}");
            var file      = FileBuilder.ParseFile(null, f.ToString());
            var procedure = file.GetFileElement <IFileProcedure>("MyProcedure");;

            var taskContext = ExecutionHelper.ExeContext();
            var result      = taskContext.CallProcedure(procedure);

            Assert.AreEqual("Dennis", (string)result);
        }
Exemple #5
0
        public void TestExpectWithEqualsStatement()
        {
            // With title and expect is passing
            var f = new StringBuilder();

            f.AppendLine("bool MyProcedure() {");
            f.AppendLine("   int x = 10;");
            f.AppendLine("   expect (x == 10);");
            f.AppendLine("   return this.HasFails;");
            f.AppendLine("}");
            var file      = FileBuilder.ParseFile(null, f.ToString());
            var procedure = file.GetFileElement <IFileProcedure>("MyProcedure");;

            var taskContext = ExecutionHelper.ExeContext();
            var result      = taskContext.CallProcedure(procedure);

            Assert.AreEqual(false, (bool)result);
        }
        public void TestFunctionCallInReturnStatement()
        {
            var f = new StringBuilder();

            f.AppendLine("namespace MyFile;");
            f.AppendLine("function int MySub() {");
            f.AppendLine("   return 323;");
            f.AppendLine("}");
            f.AppendLine("int MyProcedure() {");
            f.AppendLine("   return MySub();");
            f.AppendLine("}");
            var file      = FileBuilder.ParseFile(null, f.ToString());
            var procedure = file["MyProcedure"] as IFileProcedure;

            var taskContext = ExecutionHelper.ExeContext();
            var result      = taskContext.CallProcedure(procedure);

            Assert.AreEqual(323, (long)result);
        }
        public void TestCallSimpleProcedureReference()
        {
            var f = new StringBuilder();

            f.AppendLine("namespace MyFile;");
            f.AppendLine("function int MySub() {");
            f.AppendLine("   return 104;");
            f.AppendLine("}");
            f.AppendLine("int MyProcedure() {");
            f.AppendLine("   var proc = MySub;");
            f.AppendLine("   var result = proc();");
            f.AppendLine("   return result;");
            f.AppendLine("}");
            var file      = FileBuilder.ParseFile(null, f.ToString());
            var procedure = file["MyProcedure"] as IFileProcedure;

            var taskContext = ExecutionHelper.ExeContext();
            var result      = taskContext.CallProcedure(procedure);

            Assert.AreEqual(104, (long)result);
        }
        public void TestCallWithReturnValue()
        {
            var f = new StringBuilder();

            f.AppendLine("namespace MyFile;");
            f.AppendLine("int MySub() {");
            f.AppendLine("   return 772;");
            f.AppendLine("}");
            f.AppendLine("int MyProcedure() {");
            f.AppendLine("   int i = 278;");
            f.AppendLine("   i = 631;");
            f.AppendLine("   i = MySub();");
            f.AppendLine("   return i;");
            f.AppendLine("}");
            var file      = FileBuilder.ParseFile(null, f.ToString());
            var procedure = file["MyProcedure"] as IFileProcedure;

            var taskContext = ExecutionHelper.ExeContext();
            var result      = taskContext.CallProcedure(procedure);

            Assert.AreEqual(772, (long)result);
        }