public void Run()
        {
            this.errorsOccured = false;
            TestRunner testRunner = new TestRunner(this.fileName);

            testRunner.TestCompleted += new EventHandler(TestRunnerTestCompleted);
            testRunner.ExecutionCompleted += new EventHandler(TestRunnerExecutionCompleted);

            testRunner.Load();
            testRunner.Execute();
        }
        public void ReflectionLoadTest()
        {
            string dllpath = System.IO.Path.Combine(System.Environment.CurrentDirectory, "WaxRunnerTest.dll");
            TestRunner testRunner = new TestRunner(dllpath);
            testRunner.Load();

            // Assert the number of tests loaded
            Assert.AreEqual(2, testRunner.Tests.Count, "Incorrect number of tests parsed");

            // Assert the test attributes have been correclty loaded
            Assert.AreEqual("ReflectionTestid", testRunner.Tests[0].Id, "Invalid test id found.");

            // Assert the commands in the first test have been correctly loaded
            Assert.AreEqual(1, testRunner.Tests[0].Commands.Count, string.Format("Incorrect number of commands parsed for test with id {0}", testRunner.Tests[0].Id));

            Command command = testRunner.Tests[0].Commands[0];
            Assert.AreEqual(CommandType.GoTo, command.CommandType, "Incorrect command type found in first test");
            Assert.AreEqual("GotoTestPage", command.Id, "Incorrect command id found in first test");
            Assert.AreEqual("www.google.com.br", command.Arguments[0], "Incorrect command arguments found in first test");

            // Assert the test attributes have been correclty loaded
            Assert.AreEqual("ReflectionUnitTestClass", testRunner.Tests[1].Id, "Invalid test id found.");

            // Assert the commands in the first test have been correctly loaded
            Assert.AreEqual(1, testRunner.Tests[0].Commands.Count, string.Format("Incorrect number of commands parsed for test with id {0}", testRunner.Tests[0].Id));

            Command command2 = testRunner.Tests[1].Commands[0];
            Assert.AreEqual(CommandType.Code, command2.CommandType, "Incorrect command type found in first test");
            Assert.AreEqual("TestSept1", command2.Id, "Incorrect command id found in first test");

            Command command3 = testRunner.Tests[1].Commands[1];
            Assert.AreEqual(CommandType.Validate, command3.CommandType, "Incorrect command type found in first test");
            Assert.AreEqual("ValidateCommand1", command3.Id, "Incorrect command id found in first test");
            Assert.AreEqual("wax", command3.Arguments[0], "Incorrect command arguments found in first test");
            Assert.AreEqual("Text", command3.Arguments[1], "Incorrect command arguments found in first test");
            Assert.AreEqual("FirstName", command3.FindMethod.Arguments[0], "Incorrect command arguments found in first test");
            Assert.AreEqual(FindMethodTypes.ById, command3.FindMethod.MethodType, "Incorrect command arguments found in first test");
        }
        public void ReflectionExecutesComExecaoDeSucesso()
        {
            string dllpath = System.IO.Path.Combine(System.Environment.CurrentDirectory, "WaxRunnerTest.dll");
            TestRunner testRunner = new TestRunner(dllpath);
            testRunner.Load();
            testRunner.Progress += new EventHandler<TestProgressEventArgs>(TestRunnerProgress);

            this.progressHandlerCalledCount = 0;

            testRunner.Execute();

            Assert.AreEqual(3, this.progressHandlerCalledCount, "The progress event was not fired the expected number of times.");
        }
        public void ProgressTest()
        {
            TestRunner testRunner = new TestRunner(FileName);
            testRunner.Load();

            testRunner.Progress += new EventHandler<TestProgressEventArgs>(TestRunnerProgress);

            this.progressHandlerCalledCount = 0;

            testRunner.ExecutionStarted += new EventHandler(testRunner_ExecutionStarted);
            testRunner.ExecutionCompleted += new EventHandler(testRunner_ExecutionCompleted);
            testRunner.TestCompleted += new EventHandler(testRunner_TestCompleted);
            testRunner.CommandCompleted += new EventHandler<CommandCompletedEventArgs>(testRunner_CommandCompleted);

            testRunner.Execute();

            Assert.AreEqual(3, this.progressHandlerCalledCount, "The progress event was not fired the expected number of times.");
            Assert.AreEqual(1, executionStartedCount);
            Assert.AreEqual(1, executionCompletedCount);
            Assert.AreEqual(2, testCompletedCount);
            Assert.AreEqual(3, commandCompletedCount);
        }
        public void LoadTestExcelErrorFile()
        {
            TestRunner testRunner = new TestRunner(excelErrorFile);
            testRunner.Load();
            testRunner.TestErrorOccured += new EventHandler<TestErrorEventArgs>(testRunner_TestErrorOccured);
            testRunner.TestStarted += new EventHandler(testRunner_TestStarted);
            testRunner.Execute();

            // Assert the number of tests loaded
            Assert.AreEqual(2, testRunner.Tests.Count, "Incorrect number of tests parsed");
            Assert.AreEqual(1, testErrorOccuredCount);
            Assert.AreEqual(1, testRunner.Errors.Count);
            Assert.AreEqual(true, testRunner.ErrorsOccured);
            Assert.AreEqual(2, testStartedCount);
        }
        public void LoadTestEmptyExcelFile()
        {
            TestRunner testRunner = new TestRunner(excelEmptyFile);
            testRunner.Load();

            // Assert the number of tests loaded
            Assert.AreEqual(0, testRunner.Tests.Count, "Incorrect number of tests parsed");
        }
        public void LoadTest2()
        {
            TestRunner testRunner = new TestRunner(FileName);

            testRunner.LoadComplete += new EventHandler(testRunner_LoadComplete);

            testRunner.Load(CenarioExecucaoTestEnum.Completo);

            // Assert the number of tests loaded
            Assert.AreEqual(2, testRunner.Tests.Count, "Incorrect number of tests parsed");

            // Assert the test attributes have been correclty loaded
            Assert.AreEqual("test1", testRunner.Tests[0].Id, "Invalid test id found.");
            Assert.AreEqual("2", testRunner.Tests[1].Id, "Invalid test id found.");

            // Assert the commands in the first test have been correctly loaded
            Assert.AreEqual(2, testRunner.Tests[0].Commands.Count, string.Format("Incorrect number of commands parsed for test with id {0}", testRunner.Tests[0].Id));

            Command command = testRunner.Tests[0].Commands[0];
            Assert.AreEqual(CommandType.GoTo, command.CommandType, "Incorrect command type found in first test");
            Assert.AreEqual("GotoHome", command.Id, "Incorrect command id found in first test");
            Assert.AreEqual("http://www.google.co.uk", command.Arguments[0], "Incorrect command arguments found in first test");
            Assert.AreEqual(CommandType.GoTo, command.CommandType, "Incorrect command type found in second test");
        }
        public void LoadTest()
        {
            TestRunner testRunner = new TestRunner(FileName);
            testRunner.LoadComplete += new EventHandler(testRunner_LoadComplete);

            testRunner.Load();

            testRunner.TestErrorOccured += new EventHandler<TestErrorEventArgs>(
                delegate(object o, TestErrorEventArgs args) { });

            testRunner.TestStarted += new EventHandler((o, args) =>
                                                           {

                                                           });

            Assert.AreEqual(1, loadCount);

            // Assert the number of tests loaded
            Assert.AreEqual(2, testRunner.Tests.Count, "Incorrect number of tests parsed");

            // Assert the test attributes have been correclty loaded
            Assert.AreEqual("test1", testRunner.Tests[0].Id, "Invalid test id found.");
            Assert.AreEqual("2", testRunner.Tests[1].Id, "Invalid test id found.");

            // Assert the commands in the first test have been correctly loaded
            Assert.AreEqual(2, testRunner.Tests[0].Commands.Count, string.Format("Incorrect number of commands parsed for test with id {0}", testRunner.Tests[0].Id));

            Command command = testRunner.Tests[0].Commands[0];
            Assert.NotNull(testRunner.Errors);
            Assert.IsFalse(testRunner.ErrorsOccured);
            Assert.AreEqual(CommandType.GoTo, command.CommandType, "Incorrect command type found in first test");
            Assert.AreEqual("GotoHome", command.Id, "Incorrect command id found in first test");
            Assert.AreEqual("http://www.google.co.uk", command.Arguments[0], "Incorrect command arguments found in first test");

            Assert.AreEqual(1, testRunner.Tests[1].Commands.Count, string.Format("Incorrect number of commands parsed for test with id {0}", testRunner.Tests[1].Id));
            command = testRunner.Tests[1].Commands[0];
            Assert.AreEqual(CommandType.GoTo, command.CommandType, "Incorrect command type found in second test");
            Assert.AreEqual("GotoHome2", command.Id, "Incorrect command id found in second test");
            Assert.AreEqual("testpage2.htm", command.Arguments[0], "Incorrect command arguments found in second test");
        }