Esempio n. 1
0
        /// <summary>
        /// The actual method to get the test set/case/step data.
        /// </summary>
        /// <param name="testDataType"> 0 = testSetData, 1 = testCaseData, 2 = testStepData. </param>
        /// <param name="dataTypeName"> Name where to get the data from. </param>
        /// <param name="dataTypeLocation"> Arguments for the data. </param>
        /// <returns> The test data.</returns>
        private ITestData GetTestData(int testDataType, string dataTypeName, string dataTypeLocation)
        {
            ITestData testData = null;

            switch (testDataType)
            {
            case 0:
                testData = ReflectiveGetter.GetImplementationOfType <ITestSetData>(dataTypeLocation)
                           .Find(x => x.Name.ToLower().Equals(dataTypeName.ToLower()));
                break;

            case 1:
                testData = ReflectiveGetter.GetImplementationOfType <ITestCaseData>(dataTypeLocation)
                           .Find(x => x.Name.ToLower().Equals(dataTypeName.ToLower()));
                break;

            case 2:
                testData = ReflectiveGetter.GetImplementationOfType <ITestStepData>(dataTypeLocation)
                           .Find(x => x.Name.ToLower().Equals(dataTypeName.ToLower()));
                break;

            default:
                throw new Exception("Not a valid testDataType");
            }

            if (testData == null)
            {
                Console.WriteLine($"Sorry we do not currently support reading tests from: {dataTypeName}");
                throw new Exception($"Cannot Find test data type {dataTypeName}");
            }

            testData.SetUp();

            return(testData);
        }
Esempio n. 2
0
        /// <summary>
        /// Opens given Open XML File and returns instance of the package
        /// </summary>
        /// <param name="entry">Test data entry</param>
        /// <param name="editable">Opens the file editable</param>
        /// <returns>Instance of the package</returns>
        private OpenXmlPackage OpenPackage(ITestData entry, bool editable)
        {
            OpenXmlPackage package   = null;
            string         localPath = entry.FilePath;

            this.Log.Comment("Opening ... {0}", localPath);

            if (File.Exists(localPath) == false)
            {
                this.Log.Warning("Skiped...");
                return(package);
            }

            switch (entry.Type)
            {
            case FileType.Word:
                package = WordprocessingDocument.Open(entry.FilePath, editable);
                break;

            case FileType.PowerPoint:
                package = PresentationDocument.Open(entry.FilePath, editable);
                break;

            case FileType.Excel:
                package = SpreadsheetDocument.Open(entry.FilePath, editable);
                break;
            }

            return(package);
        }
Esempio n. 3
0
        public void Evolve_Success(ITestData testData)
        {
            var    fileList = Directory.GetFiles(testData.FilePath).OrderBy(file => file);
            string arguments;

            if (testData.UseConfig)
            {
                WriteConfig(GetConnectionOptionsString(testData));
            }

            foreach (var fileName in fileList)
            {
                arguments = $"{ GetAddArguments(fileName) } { GetConnectionOptionsString(testData) }";
                Assert.Equal(0, Run(arguments));
            }

            string targetEvolution;

            foreach (var fileName in fileList)
            {
                targetEvolution = fileName.Replace(".sql", string.Empty).Replace(testData.FilePath, string.Empty);
                arguments       = $"{ GetExecArguments(targetEvolution) } { GetConnectionOptionsString(testData) }";
                _outputHelper.WriteLine(arguments);
                Assert.Equal(0, Run(arguments));
            }
        }
Esempio n. 4
0
 public FormSession(string path)
 {
     InitializeComponent();
     _SESSION_PATH = path;
     TARGETS       = new List <IPAddress>();
     TEST_DATA     = null;
 }
Esempio n. 5
0
 private void btTest_Click(object sender, EventArgs e)
 {
     btTest.Enabled = false;
     try
     {
         //check if compilation is needed
         _testData = null;
         IObjectTypeUnitTester uc = (IObjectTypeUnitTester)MathNode.GetService(typeof(IObjectTypeUnitTester));
         if (uc != null)
         {
             _testData = uc.UseMemberTest(this);
         }
         if (_testData == null)
         {
             //
             CompileResult result = mathExpCtrl1.CreateMethodCompilerUnit("TestMathExpression", "Test", "TestMathExpression");
             //
             thTest = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(test));
             thTest.SetApartmentState(System.Threading.ApartmentState.STA);
             _testData = new TestData(result);                    //"Test", "TestMathExpression", variables, pointerList, code, imports);
             thTest.Start(_testData);
         }
         timer1.Enabled = true;
     }
     catch (Exception err)
     {
         MathNode.Log(this.FindForm(), err);
     }
     //
     timer1.Enabled = true;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="OrderProcessor`1"/> class.
 /// </summary>
 /// <param name="testData">An instance of <see cref="ITestData`1"/> for order generation.</param>
 /// <param name="invoiceGenerator">An instance of <see cref="IInvoiceGenerator`1"/> for invoice files generation.</param>
 /// <param name="mailManager">An instance of <see cref="IMailManager`1"/> for invoice sending.</param>
 public OrderProcessor(ITestData testData, IInvoiceGenerator invoiceGenerator,
                       IMailManager mailManager)
 {
     this.testData         = testData;
     this.invoiceGenerator = invoiceGenerator;
     this.mailManager      = mailManager;
 }
Esempio n. 7
0
 private void btTest_Click(object sender, EventArgs e)
 {
     btTest.Enabled = false;
     try
     {
         _testData = null;
         //generate the result
         result = root.Export();
         //
         //check if compilation is needed
         IObjectTypeUnitTester uc = (IObjectTypeUnitTester)MathNode.GetService(typeof(IObjectTypeUnitTester));
         if (uc != null)
         {
             _testData = uc.UseMemberTest(this);
         }
         if (_testData == null)
         {
             CompileResult compiled = result.CreateMethodCompilerUnit("TestMathExpression", "Test", "TestMathExpGroup");
             //
             thTest = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(test));
             thTest.SetApartmentState(System.Threading.ApartmentState.STA);
             _testData = new TestData(compiled);
             thTest.Start(_testData);
         }
         //
         timer1.Enabled = true;
     }
     catch (Exception err)
     {
         MathNode.Log(this.FindForm(), err);
     }
 }
Esempio n. 8
0
 /// <summary>
 /// Validate OOXML File with specified file format version
 /// </summary>
 /// <param name="entry">ITestData entry for OOXML File</param>
 /// <param name="fileFormatVersion">File Format Version</param>
 private void VerifyValidation(ITestData entry, FileFormatVersions fileFormatVersion)
 {
     using (var document = this.OpenPackage(entry, false))
     {
         OpenXmlValidator isoValidator = new OpenXmlValidator(fileFormatVersion);
         var errorList = isoValidator.Validate(document);
     }
 }
Esempio n. 9
0
 private void runner_TestFailed(ITestData data, string message, string stackTrace)
 {
     context.BeginInvoke(() =>
     {
         Runner.Runner_TestFailed(data, message, stackTrace);
         UpdateTestCounts();
     });
 }
Esempio n. 10
0
 private void runner_TestTimedOut(ITestData data)
 {
     context.BeginInvoke(() =>
     {
         Runner.Runner_TestTimedOut(data);
         UpdateTestCounts();
     });
 }
Esempio n. 11
0
        public TestParameters(ITestData data)
            : this(data.RunState, data.Arguments)
        {
            TestName = data.TestName;

            foreach (string key in data.Properties.Keys)
            {
                this.Properties[key] = data.Properties[key];
            }
        }
Esempio n. 12
0
 private static void TestOnSerializer(Dictionary<string, ISerDeser> serializers, ITestData original, Dictionary<string, Measurements[]> measurements, int repetition)
 {
     foreach (var serializer in serializers)
     {
         SingleTest(serializer, original, measurements, repetition);
     }
     GC.Collect(); // it has very little impact on speed for repetitions < 100
     GC.WaitForFullGCComplete();
     GC.Collect();
 }
Esempio n. 13
0
 private void Verify(ITestData entry)
 {
     using (var document = this.OpenPackage(entry, false))
     {
         if (this.IsIsoStrictFile(document) == true)
         {
             this.Log.Pass("Opened: {0}", entry.FilePath);
         }
     }
 }
Esempio n. 14
0
        /// <summary>
        /// Construct a ParameterSet from an object implementing ITestData
        /// </summary>
        /// <param name="data"></param>
        public TestParameters(ITestData data)
        {
            RunState = data.RunState;
            Properties = new PropertyBag();

            TestName = data.TestName;
            OriginalArguments = Arguments = data.Arguments;

            foreach (string key in data.Properties.Keys)
                this.Properties[key] = data.Properties[key];
        }
Esempio n. 15
0
        private string GetConnectionOptionsString(ITestData testData)
        {
            var connectionParams = $"--user {testData.User} " +
                                   $"--password {testData.Password} " +
                                   $"--server {testData.Server} " +
                                   $"--instance {testData.Instance} " +
                                   $"--port {testData.Port} " +
                                   $"--type {testData.Type}";

            return(connectionParams);
        }
Esempio n. 16
0
        protected void InitializeTestDataInstance()
        {
#if USE_INTERFACE
            TestData = container.Resolve <ITestData>();
#endif
#if USE_CONFIGURATION
            TestData = container.Resolve <ITestData>();
#endif
#if USE_OBJ_PROXY
            TestData = container.Resolve <TestData>();
#endif
        }
Esempio n. 17
0
        /// <summary>
        /// Construct a ParameterSet from an object implementing ITestData
        /// </summary>
        /// <param name="data"></param>
        public TestParameters(ITestData data)
        {
            RunState = data.RunState;
            Properties = new PropertyBag();

            TestName = data.TestName;

            InitializeAguments(data.Arguments);

            foreach (string key in data.Properties.Keys)
                this.Properties[key] = data.Properties[key];
        }
Esempio n. 18
0
        /// <summary>
        /// Construct a ParameterSet from an object implementing ITestData
        /// </summary>
        /// <param name="data"></param>
        public TestParameters(ITestData data)
        {
            RunState   = data.RunState;
            Properties = new PropertyBag();

            TestName          = data.TestName;
            OriginalArguments = Arguments = data.Arguments;

            foreach (string key in data.Properties.Keys)
            {
                this.Properties[key] = data.Properties[key];
            }
        }
Esempio n. 19
0
        public bool LoadData(ITestData test)
        {
            data = (MethodTestData)test;
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(data.FullContents);
            testData = doc.DocumentElement.SelectSingleNode(data.XPath);
            if (testData == null)
            {
                throw new MathException(string.Format(System.Globalization.CultureInfo.InvariantCulture, "Invalid xpath '{0}' for the test node", data.XPath));
            }
            return(true);
        }
Esempio n. 20
0
 public IStepResult EnterData(ITestData data)
 {
     for (int i = 0; i < this.TestData.Numbers.Count - 1; i++)
     {
         this.MainForm.ClickNumber(this.TestData.Numbers[i]);
         this.MainForm.ClickPlus();
     }
     this.MainForm.ClickNumber(this.TestData.Numbers.Last());
     if (this.TestData.Mode == CalcMode.Statistic)
     {
         this.MainForm.ClickPlus();
     }
     return(new StepResult());
 }
Esempio n. 21
0
        /// <summary>
        /// Construct a ParameterSet from an object implementing ITestData
        /// </summary>
        /// <param name="data"></param>
        public TestParameters(ITestData data)
        {
            RunState   = data.RunState;
            Properties = new PropertyBag();

            TestName = data.TestName;

            InitializeAguments(data.Arguments);

            foreach (string key in data.Properties.Keys)
            {
                this.Properties[key] = data.Properties[key];
            }
        }
Esempio n. 22
0
        public virtual IStepResult Precondition_OpenCalc(ITestData data)
        {
            base.AppWrapper = new ApplicationWrapper(this.TestData.AppPath);
            this.MainWindow = this.AppWrapper.GetWindow(title: this.TestData.MainWindowTitle);

            var result = new StepResult();

            if (this.MainWindow == null)
            {
                LogicalFail("Window didn't open in specified time.", true);
                return(result);
            }
            InteractionTimeout.Wait(1000);
            return(result);
        }
Esempio n. 23
0
        public IStepResult CheckResult(ITestData data)
        {
            this.MainForm.ClickEquals();
            var calcResult = this.MainForm.GetResult();

            var sum         = int.Parse(calcResult);
            var expectedSum = this.TestData.Numbers.Sum();

            if (sum != expectedSum)
            {
                var message = string.Format("The sum is different. Expected: {0}, Actual: {1}", expectedSum, sum);
                LogicalFail(message, skipAll: false);
            }
            return(null);
        }
Esempio n. 24
0
        private static void SingleTest(KeyValuePair<string, ISerDeser> serializer, ITestData original, Dictionary<string, Measurements[]> measurements, int repetition)
        {
            var sw = Stopwatch.StartNew();
            var serialized = serializer.Value.Serialize<Person>(original);

            measurements[serializer.Key][repetition].Size = serialized.Length;

            var processed = serializer.Value.Deserialize<Person>(serialized);

            sw.Stop();
            measurements[serializer.Key][repetition].Time = sw.ElapsedTicks;
            Report.TimeAndDocument(serializer.Key, sw.ElapsedTicks, serialized);
            var errors = original.Compare(processed);
            errors[0] = serializer.Key + errors[0];
            Report.Errors(errors);
        }
Esempio n. 25
0
        public override IStepResult Precondition_OpenCalc(ITestData data)
        {
            base.Precondition_OpenCalc(null);
            switch (this.TestData.Mode)
            {
            case CalcMode.Statistic:
                this.MainForm = new CalcStatForm(this.MainWindow);
                break;

            default:
                this.MainForm = new CalcStandardForm(this.MainWindow);
                break;
            }

            this.MainForm.InitializeFormControls();
            return(null);
        }
Esempio n. 26
0
        public OpenXmlPackage OpenDocument(ITestData entry, bool isEditable)
        {
            switch (entry.Type)
            {
            case FileType.Word:
                return(WordprocessingDocument.Open(entry.FilePath, isEditable));

            case FileType.Excel:
                return(SpreadsheetDocument.Open(entry.FilePath, isEditable));

            case FileType.PowerPoint:
                return(PresentationDocument.Open(entry.FilePath, isEditable));

            default:
                return(null);
            }
        }
Esempio n. 27
0
 public HomeController(ITestData test)
 {
     _test = test;
 }
Esempio n. 28
0
 public OpenXmlPackage OpenDocument(ITestData entry, bool isEditable)
 {
     switch (entry.Type)
     {
         case FileType.Word:
             return WordprocessingDocument.Open(entry.FilePath, isEditable);
         case FileType.Excel:
             return SpreadsheetDocument.Open(entry.FilePath, isEditable);
         case FileType.PowerPoint:
             return PresentationDocument.Open(entry.FilePath, isEditable);
         default:
             return null;
     }
 }
 private readonly ITestData testData;                     // represents a bounded context
 public TestService(ITestData testData)
 {
     this.testData = testData;
 }
        public bool LoadData(ITestData test)
        {
            try
            {
                _testData = (TestData)test;
                //provide drawing attributes for parameters
                mroot = new MathNodeRoot();
                if (_testData.Parameters.Count > 2)
                {
                    mroot.ChildNodeCount = _testData.Parameters.Count;
                }
                parameters.Properties.Clear();
                for (int i = 0; i < _testData.Parameters.Count; i++)
                {
                    mroot[i] = (MathNode)_testData.Parameters[i].CloneExp(mroot);
                    parameters.Properties.Add(new PropertySpec(_testData.Parameters[i].VariableName + ":" + _testData.Parameters[i].CodeVariableName, _testData.Parameters[i].VariableType.Type));
                }
                foreach (IPropertyPointer pp in _testData.Pointers)
                {
                    parameters.Properties.Add(new PropertySpec(pp.ToString() + ":" + pp.CodeName, pp.ObjectType));                    //.PointerDataType));
                }
                //
                CodeGeneratorOptions o = new CodeGeneratorOptions();
                o.BlankLinesBetweenMembers = false;
                o.BracingStyle             = "C";
                o.ElseOnClosing            = false;
                o.IndentString             = "    ";
                //
                CSharpCodeProvider cs = new CSharpCodeProvider();
                StringWriter       sw;
                sw = new StringWriter();
                cs.GenerateCodeFromCompileUnit(_testData.CU, sw, o);
                //
                string sCode = sw.ToString();
                sw.Close();
                //
                int pos = sCode.IndexOf("a tool.");
                if (pos > 0)
                {
                    sCode = sCode.Substring(0, pos) + "Limnor Visual Object Builder." + sCode.Substring(pos + 7);
                }
                //
                textBox1.Text = sCode;
                //
                CompilerParameters cp = new CompilerParameters();
                foreach (AssemblyRef ar in _testData.Assemblies)
                {
                    MathNode.AddImportLocation(ar.Location);
                }
                foreach (string s in MathNode.ImportLocations)
                {
                    cp.ReferencedAssemblies.Add(s);
                }
                cp.GenerateExecutable = false;
                CompilerResults crs = cs.CompileAssemblyFromDom(cp, new CodeCompileUnit[] { _testData.CU });
                if (crs.Errors.HasErrors)
                {
                    MathNode.Trace("Error compiling.");
                    MathNode.IndentIncrement();
                    FormCompilerError dlg = new FormCompilerError();
                    for (int i = 0; i < crs.Errors.Count; i++)
                    {
                        MathNode.Trace(crs.Errors[i].ToString());
                        dlg.AddItem(crs.Errors[i]);
                    }
                    MathNode.IndentDecrement();
                    dlg.TopLevel = false;
                    dlg.Parent   = this;
                    dlg.Show();
                    dlg.TopMost = true;
                    dlg.BringToFront();
                }
                else
                {
                    Type[] types = crs.CompiledAssembly.GetExportedTypes();
                    if (types != null)
                    {
                        for (int i = 0; i < types.Length; i++)
                        {
                            if (types[i].Name == _testData.ClassName)
                            {
                                _mi = types[i].GetMethod(_testData.MethodName);
                                if (_mi != null)
                                {
                                    break;
                                }
                            }
                        }
                    }
                }
                textBox2.Text = MathNode.GetLogContents();
                return(true);
            }
            catch (Exception err)
            {
                MathNode.Log(this, err);
                textBox2.Text = MathNode.GetLogContents();
            }

            return(false);
        }
Esempio n. 31
0
        private void GetTestResultStatus(ITestData td)
        {
            //set the test status
            var results = LoadResults(Results);

            if (results != null)
            {
                //find our results in the results
                var mainSuite = results.testsuite;
                var ourSuite  =
                    results.testsuite.results.Items
                    .Cast <testsuiteType>()
                    .FirstOrDefault(s => s.name == td.Fixture.Name);
                var ourTest = ourSuite.results.Items
                              .Cast <testcaseType>().FirstOrDefault(t => t.name == td.Name);

                switch (ourTest.result)
                {
                case "Cancelled":
                    td.TestStatus = TestStatus.Cancelled;
                    break;

                case "Error":
                    td.TestStatus = TestStatus.Error;
                    break;

                case "Failure":
                    td.TestStatus = TestStatus.Failure;
                    break;

                case "Ignored":
                    td.TestStatus = TestStatus.Ignored;
                    break;

                case "Inconclusive":
                    td.TestStatus = TestStatus.Inconclusive;
                    break;

                case "NotRunnable":
                    td.TestStatus = TestStatus.NotRunnable;
                    break;

                case "Skipped":
                    td.TestStatus = TestStatus.Skipped;
                    break;

                case "Success":
                    td.TestStatus = TestStatus.Success;
                    break;
                }

                if (ourTest.Item == null)
                {
                    return;
                }
                var failure = ourTest.Item as failureType;
                if (failure == null)
                {
                    return;
                }

                //if (_vm != null && _vm.UiDispatcher != null)
                //{
                //    _vm.UiDispatcher.BeginInvoke((Action)(() => td.ResultData.Add(
                //        new ResultData()
                //        {
                //            StackTrace = failure.stacktrace,
                //            Message = failure.message
                //        })));
                //}

                //Dispatcher.CurrentDispatcher.BeginInvoke((Action)(() => td.ResultData.Add(
                //        new ResultData()
                //        {
                //            StackTrace = failure.stacktrace,
                //            Message = failure.message
                //        })));

                td.ResultData.Add(
                    new ResultData()
                {
                    StackTrace = failure.stacktrace,
                    Message    = failure.message
                });
            }
        }
Esempio n. 32
0
 public IStepResult Postcondition_Close(ITestData data)
 {
     this.AppWrapper.Dispose();
     WrapperPool.ClearWrapperPool();
     return(null);
 }
Esempio n. 33
0
 private void OnTestTimedOut(ITestData data)
 {
     if (TestTimedOut != null)
     {
         TestTimedOut(data);
     }
 }
Esempio n. 34
0
        private static void GetTestResultStatus(ITestData td)
        {
            //set the test status
            var results = LoadResults(_results);
            if (results != null)
            {
                //find our results in the results
                var mainSuite = results.testsuite;
                var ourSuite =
                    results.testsuite.results.Items
                        .Cast<testsuiteType>()
                        .FirstOrDefault(s => s.name == td.Fixture.Name);
                var ourTest = ourSuite.results.Items
                    .Cast<testcaseType>().FirstOrDefault(t => t.name == td.Name);

                switch (ourTest.result)
                {
                    case "Cancelled":
                        td.TestStatus = TestStatus.Cancelled;
                        break;
                    case "Error":
                        td.TestStatus = TestStatus.Error;
                        break;
                    case "Failure":
                        td.TestStatus = TestStatus.Failure;
                        break;
                    case "Ignored":
                        td.TestStatus = TestStatus.Ignored;
                        break;
                    case "Inconclusive":
                        td.TestStatus = TestStatus.Inconclusive;
                        break;
                    case "NotRunnable":
                        td.TestStatus = TestStatus.NotRunnable;
                        break;
                    case "Skipped":
                        td.TestStatus = TestStatus.Skipped;
                        break;
                    case "Success":
                        td.TestStatus = TestStatus.Success;
                        break;
                }

                if (ourTest.Item == null) return;
                var failure = ourTest.Item as failureType;
                if (failure == null) return;

                if (_vm != null && _vm.UiDispatcher != null)
                {
                    _vm.UiDispatcher.BeginInvoke((Action)(()=> td.ResultData.Add(
                        new ResultData()
                        {
                            StackTrace = failure.stacktrace,
                            Message = failure.message
                        })));
                }
            }
        }
Esempio n. 35
0
        public static void RunTest(ITestData td)
        {
            var path = Path.Combine(_workingDirectory, td.Name + ".txt");

            CreateJournal(path, td.Name, td.Fixture.Name, td.Fixture.Assembly.Path, _results, td.ModelPath);

            var startInfo = new ProcessStartInfo()
            {
                FileName = _revitPath,
                WorkingDirectory = _workingDirectory,
                Arguments = path,
                UseShellExecute = false
            };

            Console.WriteLine("Running {0}", path);
            var process = new Process { StartInfo = startInfo };
            process.Start();

            var timedOut = false;

            if (_isDebug)
            {
                process.WaitForExit();
            }  
            else
            {
                var time = 0;
                while(!process.WaitForExit(1000))
                //if (!process.WaitForExit(_timeout))
                {
                    Console.Write(".");
                    time += 1000;
                    if (time > _timeout)
                    {
                        Console.WriteLine("Test timed out.");
                        td.TestStatus = TestStatus.TimedOut;
                        timedOut = true;
                        break;
                    }
                }
                if (timedOut)
                {
                    if(!process.HasExited)
                        process.Kill();
                }
            }

            if(!timedOut && _gui)
                GetTestResultStatus(td);

            _runCount --;
            if (_runCount == 0)
            {
                OnTestRunsComplete();
            }
        }
 void runner_TestFailed(ITestData data, string message, string stackTrace)
 {
     context.BeginInvoke(() => Runner.Runner_TestFailed(data, message, stackTrace));
 }
 void runner_TestTimedOut(ITestData data)
 {
     context.BeginInvoke(()=>Runner.Runner_TestTimedOut(data));
 }
Esempio n. 38
0
 public Test(ITestData testData)
 {
     _testData = testData;
 }
Esempio n. 39
0
 private void OnTestComplete(ITestData data)
 {
     if (TestComplete != null)
     {
         TestComplete(new List<ITestData>(){data}, Results);
     }
 }
Esempio n. 40
0
        /// <summary>
        /// Setup the selected test.
        /// </summary>
        /// <param name="td"></param>
        /// <param name="continuous"></param>
        private void SetupIndividualTest(ITestData td, bool continuous = false)
        {
            if (td.ShouldRun == false)
                return;

            try
            {
                if (!File.Exists(td.ModelPath))
                {
                    throw new Exception(String.Format("Specified model path: {0} does not exist.", td.ModelPath));
                }

                if (!File.Exists(td.Fixture.Assembly.Path))
                {
                    throw new Exception(String.Format("The specified assembly: {0} does not exist.",
                        td.Fixture.Assembly.Path));
                }

                if (!File.Exists(AssemblyPath))
                {
                    throw new Exception(
                        String.Format("The specified RTF assembly does not exist: {0} does not exist.",
                            td.Fixture.Assembly.Path));
                }

                var journalPath = Path.Combine(WorkingDirectory, td.Name + ".txt");

                // If we're running in continuous mode, then all tests will share
                // the same journal path
                if (continuous)
                {
                    journalPath = batchJournalPath;
                }
                td.JournalPath = journalPath;

                if (continuous)
                {
                    InitializeJournal(journalPath);
                    AddToJournal(journalPath, td.Name, td.Fixture.Name, td.Fixture.Assembly.Path, Results, td.ModelPath);
                }
                else
                {
                    CreateJournal(journalPath, td.Name, td.Fixture.Name, td.Fixture.Assembly.Path, Results, td.ModelPath);
                }

            }
            catch (Exception ex)
            {
                if (td == null) return;
                td.TestStatus = TestStatus.Failure;
            }
        }
Esempio n. 41
0
 private void OnTestFailed(ITestData data, string message, string stackTrace)
 {
     if (TestFailed != null)
     {
         TestFailed(data, message, stackTrace);
     }
 }
Esempio n. 42
0
 public static void Runner_TestTimedOut(ITestData data)
 {
     data.ResultData.Clear();
     data.ResultData.Add(new ResultData() { Message = "Test timed out." });
 }
Esempio n. 43
0
        private void ProcessTest(ITestData td, string journalPath)
        {
            var startInfo = new ProcessStartInfo()
            {
                FileName = RevitPath,
                WorkingDirectory = WorkingDirectory,
                Arguments = journalPath,
                UseShellExecute = false
            };

            Console.WriteLine("Running {0}", journalPath);
            var process = new Process { StartInfo = startInfo };
            process.Start();

            var timedOut = false;

            if (IsDebug)
            {
                process.WaitForExit();
            }
            else
            {
                var time = 0;
                while (!process.WaitForExit(1000))
                {
                    Console.Write(".");
                    time += 1000;
                    if (time > Timeout)
                    {
                        td.TestStatus = TestStatus.Failure;
                        OnTestTimedOut(td);

                        timedOut = true;
                        break;
                    }
                }
                if (timedOut)
                {
                    if (!process.HasExited)
                        process.Kill();
                }
            }

            if (!timedOut)
            {
                OnTestComplete(td);
            }
        }
Esempio n. 44
0
        public void RunTest(ITestData td)
        {
            if (!File.Exists(AddinPath))
            {
                CreateAddin(AddinPath, AssemblyPath);
            }

            var journalPath = Path.Combine(WorkingDirectory, td.Name + ".txt");
            CreateJournal(journalPath, td.Name, td.Fixture.Name, td.Fixture.Assembly.Path, Results, td.ModelPath);

            var startInfo = new ProcessStartInfo()
            {
                FileName = RevitPath,
                WorkingDirectory = WorkingDirectory,
                Arguments = journalPath,
                UseShellExecute = false
            };

            Console.WriteLine("Running {0}", journalPath);
            var process = new Process { StartInfo = startInfo };
            process.Start();

            var timedOut = false;

            if (IsDebug)
            {
                process.WaitForExit();
            }
            else
            {
                var time = 0;
                while (!process.WaitForExit(1000))
                {
                    Console.Write(".");
                    time += 1000;
                    if (time > Timeout)
                    {
                        Console.WriteLine("Test timed out.");
                        td.TestStatus = TestStatus.TimedOut;
                        timedOut = true;
                        break;
                    }
                }
                if (timedOut)
                {
                    if (!process.HasExited)
                        process.Kill();
                }
            }

            if (!timedOut && Gui)
                GetTestResultStatus(td);

            RunCount--;
            if (RunCount == 0)
            {
                OnTestRunsComplete();
            }
        }
Esempio n. 45
0
 public static void Runner_TestFailed(ITestData data, string message, string stackTrace)
 {
     data.ResultData.Clear();
     data.ResultData.Add(new ResultData() { Message = message, StackTrace = stackTrace });
 }
Esempio n. 46
0
 public List<string> Compare(ITestData comparable)
 {
     return ComparePerson((Person)comparable);
 }
Esempio n. 47
0
 public IStepResult SwitchMode(ITestData data)
 {
     this.MainForm.SwitchMode(this.TestData.Mode);
     return(null);
 }
Esempio n. 48
0
        public void RunTest(ITestData td)
        {
            if (!File.Exists(AddinPath))
            {
                CreateAddin(AddinPath, AssemblyPath);
            }

            var journalPath = Path.Combine(WorkingDirectory, td.Name + ".txt");

            CreateJournal(journalPath, td.Name, td.Fixture.Name, td.Fixture.Assembly.Path, Results, td.ModelPath);

            var startInfo = new ProcessStartInfo()
            {
                FileName         = RevitPath,
                WorkingDirectory = WorkingDirectory,
                Arguments        = journalPath,
                UseShellExecute  = false
            };

            Console.WriteLine("Running {0}", journalPath);
            var process = new Process {
                StartInfo = startInfo
            };

            process.Start();

            var timedOut = false;

            if (IsDebug)
            {
                process.WaitForExit();
            }
            else
            {
                var time = 0;
                while (!process.WaitForExit(1000))
                {
                    Console.Write(".");
                    time += 1000;
                    if (time > Timeout)
                    {
                        Console.WriteLine("Test timed out.");
                        td.TestStatus = TestStatus.TimedOut;
                        timedOut      = true;
                        break;
                    }
                }
                if (timedOut)
                {
                    if (!process.HasExited)
                    {
                        process.Kill();
                    }
                }
            }

            if (!timedOut && Gui)
            {
                GetTestResultStatus(td);
            }

            RunCount--;
            if (RunCount == 0)
            {
                OnTestRunsComplete();
            }
        }
Esempio n. 49
0
        public static void RunTest(ITestData td)
        {
            var path = Path.Combine(_workingDirectory, td.Name + ".txt");

            CreateJournal(path, td.Name, td.Fixture.Name, td.Fixture.Assembly.Path, _results, td.ModelPath);

            var startInfo = new ProcessStartInfo()
            {
                FileName = _revitPath,
                WorkingDirectory = _workingDirectory,
                Arguments = path
            };

            Console.WriteLine("Running {0}", path);
            var process = new Process { StartInfo = startInfo };
            process.Start();

            if (_isDebug)
                process.WaitForExit();
            else
                process.WaitForExit(120000);

            _runCount --;
            if (_runCount == 0)
            {
                OnTestRunsComplete();
            }
        }
Esempio n. 50
0
 public ComplexTestData(ITestData data)
 {
     this.SimpleData = data;
 }