/// <summary>
        /// The export test result.
        /// </summary>
        /// <param name="assemblyLocation">
        /// The assembly location.
        /// </param>
        /// <param name="pathToReport">
        /// The path to report.
        /// </param>
        /// <param name="testName">
        /// The test name.
        /// </param>
        /// <param name="dtmStudioTestTempData">
        /// The dt mstudio test temp data.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public bool ExportTestResult(FileInfo assemblyLocation, string pathToReport, string testName, DTMstudioTestData dtmStudioTestTempData)
        {
            var directory = new DirectoryInfo(assemblyLocation.Directory.FullName);
            var result    = false;
            ResolveEventHandler resolveEventHandler = (s, e) => { return(this.OnResolve(e, directory)); };

            AppDomain.CurrentDomain.AssemblyResolve += resolveEventHandler;

            Assembly.LoadFrom(assemblyLocation.FullName);

            var assemblies = AppDomain.CurrentDomain.GetAssemblies();

            var assembly = assemblies.First(a => a.Location == assemblyLocation.FullName);

            var instances = from t in assembly.GetTypes() where t.GetInterfaces().Contains(typeof(IExportResultToTestManagement)) && t.GetConstructor(Type.EmptyTypes) != null select Activator.CreateInstance(t) as IExportResultToTestManagement;

            foreach (var instance in instances)
            {
                try
                {
                    result = instance.ExportTestResult(pathToReport, testName, dtmStudioTestTempData);
                    break;
                }
                catch (Exception ex)
                {
                    Log.ErrorEx(this, ex, MethodBase.GetCurrentMethod().Name);
                    return(result);
                }
            }

            AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve -= resolveEventHandler;
            return(result);
        }
        /// <summary>
        /// The get methods infos.
        /// </summary>
        /// <param name="directoryName">
        /// The directory name.
        /// </param>
        /// <param name="assemblyFileName">
        /// The assembly file name.
        /// </param>
        /// <returns>
        /// The <see cref="EhMethodInfo"/>.
        /// </returns>
        internal EhMethodInfoCollection GetTestScriptInformationMethodsInfos(string directoryName, string assemblyFileName)
        {
            var methodInfos = new EhMethodInfoCollection();

            var directory = new DirectoryInfo(directoryName);
            ResolveEventHandler resolveEventHandler = (s, e) => { return(this.OnReflectionOnlyResolve(e, directory)); };

            AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += resolveEventHandler;
            Assembly reflectionOnlyAssembly = AppDomain.CurrentDomain.ReflectionOnlyGetAssemblies().First();

            foreach (Type type in reflectionOnlyAssembly.GetTypes())
            {
                try
                {
                    ObjectHandle oh = Activator.CreateInstanceFrom(assemblyFileName, type.ToString());
                    object       o  = oh.Unwrap();
                    Type         to = o.GetType();

                    foreach (var methodInfo in to.GetMethods())
                    {
                        var customAttributes = methodInfo.GetCustomAttributes(false);

                        if (customAttributes.Length > 0)
                        {
                            foreach (var customAttribut in customAttributes)
                            {
                                if (customAttribut is TestScriptInformation)
                                {
                                    var ehMethodInfo = new EhMethodInfo();

                                    ehMethodInfo.ParameterInfo = this.GetParameterInfos(methodInfo);

                                    ehMethodInfo.CustomAttributGuid           = (customAttribut as TestScriptInformation).Guid;
                                    ehMethodInfo.CustomAttributTestDefinition = (customAttribut as TestScriptInformation).TestDefinition.ToString();
                                    ehMethodInfo.CustomAttributTestScript     = (customAttribut as TestScriptInformation).TestScript;

                                    ehMethodInfo.MethodFullName = methodInfo.DeclaringType.FullName;

                                    // ehMethodInfo.AssemblyFullPath = methodInfo.DeclaringType.Assembly.Location;
                                    ehMethodInfo.AssemblyFullPath = assemblyFileName;

                                    ehMethodInfo.MethodName        = methodInfo.Name;
                                    ehMethodInfo.MethodDisplayName = this.GetDisplayName(methodInfo);
                                    ehMethodInfo.Namespace         = methodInfo.DeclaringType.Namespace;
                                    ehMethodInfo.ClassName         = methodInfo.ReflectedType.Name;
                                    ehMethodInfo.MemberType        = methodInfo.MemberType.ToString();

                                    methodInfos.Add(ehMethodInfo);
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Log.ErrorEx(this, ex, MethodBase.GetCurrentMethod().Name);
                    string test = string.Empty;
                }
            }

            AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve -= resolveEventHandler;
            return(methodInfos);
        }
        /// <summary>
        /// Recursive method to read by object.
        /// </summary>
        /// <param name="executionObject">
        /// The execution object.
        /// </param>
        /// <returns>
        /// The <see cref="ExecutionObject"/>.
        /// </returns>
        private ExecutionObject ReadByObject(ExecutionObject executionObject)
        {
            Log.Enter(this, MethodBase.GetCurrentMethod().Name);
            if (executionObject != null)
            {
                var currentExecutionObject = new ExecutionObject(executionObject);

                foreach (var testObject in currentExecutionObject.ExecutionData.TestMethods)
                {
                    if (testObject.GetType() == typeof(TestSuite))
                    {
                        // Add new TestReportInfos with related TestSuiteName
                        var testReportInfo = new TestReportInfo(testObject.DisplayName);
                        currentExecutionObject.TestReportInfos.Add(testReportInfo);
                        currentExecutionObject.CurrentTestReportInfo = testReportInfo;

                        // Recursvive call
                        currentExecutionObject.CurrentTestObject         = testObject;
                        currentExecutionObject.ExecutionData.TestMethods = ((TestCollection)testObject).TestObjects;
                        currentExecutionObject = this.ReadByObject(currentExecutionObject);
                    }
                    else if (testObject.GetType() == typeof(TestFolder) && testObject.Parent.GetType() == typeof(TestSuite))
                    {
                        // Recursvive call
                        currentExecutionObject.CurrentTestObject         = testObject;
                        currentExecutionObject.ExecutionData.TestMethods = ((TestCollection)testObject).TestObjects;
                        currentExecutionObject = this.ReadByObject(currentExecutionObject);
                    }
                    else if (testObject.GetType() == typeof(TestFolder) && testObject.Parent.GetType() != typeof(TestSuite) && testObject.Parent != null)
                    {
                        string targetFolder = currentExecutionObject.ReportFolderTestCases;

                        if (!Directory.Exists(targetFolder))
                        {
                            Directory.CreateDirectory(targetFolder);
                        }

                        // Add new TestReportInfos without related TestSuites
                        var testReportInfo = new TestReportInfo(string.Empty);
                        currentExecutionObject.TestReportInfos.Add(testReportInfo);
                        currentExecutionObject.CurrentTestReportInfo = testReportInfo;

                        // Recursvive call
                        currentExecutionObject.CurrentTestObject         = testObject;
                        currentExecutionObject.ExecutionData.TestMethods = ((TestCollection)testObject).TestObjects;
                        currentExecutionObject = this.ReadByObject(currentExecutionObject);
                    }
                    else if (testObject.GetType() == typeof(TestCase))
                    {
                        this.reportFileName = string.Empty;
                        try
                        {
                            currentExecutionObject.TestCaseName    = testObject.DisplayName;
                            currentExecutionObject.CurrentTestCase = (TestCase)testObject;

                            /* Manipulation der Ausgabe bevor der Bericht abgeschlossen ist, weil die Ausführung
                             * abgebrochen werden können soll, ohne dass dabei die neue Formatierung "vergessen" wird.
                             * Neue Styles ersetzen die Ranorex Styles */
                            this.reportFileName = TestCaseReportHandler.PrepareReporting(ref currentExecutionObject);
                            InfrastructureHandler.ManipulateDetailReportLayout(this.reportFileName);
                            InfrastructureHandler.ReplaceReportStyleSheet(this.reportFileName, "EHReportDetails");
                            string       source   = Path.Combine(currentExecutionObject.DtmStudioTestData.DeviceTypeTestProject.ExecutionPath, "Report");
                            string       target   = currentExecutionObject.ReportFolderTestCases;
                            const string FileName = "EHReportDetails";
                            InfrastructureHandler.CopyCustomizedReportDefaultStyle(source, target, FileName);
                            InfrastructureHandler.DeleteRanorexStyle(currentExecutionObject.ReportFolderTestCases);
                            InfrastructureHandler.InsertHTMLCodeToReport(Path.Combine(currentExecutionObject.ReportFolderTestCases, "EHReportDetails.xsl"), currentExecutionObject.DtmStudioTestData.DeviceTypeProject.DeviceFunctions, currentExecutionObject.DtmStudioTestData.ReportData.FirmwareInformation.AdditionalInformation);

                            // Ende des Kommentars
                            if (testObject.IsActive)
                            {
                                Log.Info(this, "Execute active Testobject -> TestCase");
                                TestObjectHandler.Execute(currentExecutionObject, testObject.Guid);
                            }
                            else
                            {
                                Log.Info(this, "Log inactive Testobject -> TestCase");
                                TestReport.SetCurrentTestResult(TestResult.Skipped);
                            }
                        }
                        catch (Exception exception)
                        {
                            Log.ErrorEx(this, exception, "A Critical Error Occured");
                            Console.WriteLine("A Critical Error Occured: " + exception.Message);
                            TestReport.SetCurrentTestResult(TestResult.Failed);
                        }
                        finally
                        {
                            var testCaseInfo = new TestCaseInfo();
                            TestCaseReportHandler.FinishReporting(ref currentExecutionObject, ref testCaseInfo);
                            currentExecutionObject.DtmStudioTestData.ReportData.ResultOfTest = testCaseInfo.TestCaseResult.ToString();

                            // Nachbearbeitung notwendig, da Ranorex mit jedem Schritt die Styledaten neu hineinkopiert
                            InfrastructureHandler.InsertReportData(testCaseInfo.TestCasePathAndName, currentExecutionObject.DtmStudioTestData);
                            InfrastructureHandler.ManipulateDetailReportLayout(this.reportFileName);
                            InfrastructureHandler.ReplaceReportStyleSheet(this.reportFileName, "EHReportDetails");
                            InfrastructureHandler.DeleteRanorexStyle(currentExecutionObject.ReportFolderTestCases);
                            InfrastructureHandler.InsertHTMLCodeToReport(Path.Combine(currentExecutionObject.ReportFolderTestCases, "EHReportDetails.xsl"), currentExecutionObject.DtmStudioTestData.DeviceTypeProject.DeviceFunctions, currentExecutionObject.DtmStudioTestData.ReportData.FirmwareInformation.AdditionalInformation);

                            // Ende des Kommentars

                            // Datenbank Aufruf
                            InfrastructureHandler.ExportTestResult(testCaseInfo.TestCasePathAndName, currentExecutionObject.TestCaseName, currentExecutionObject.DtmStudioTestData);
                        }
                    }
                    else
                    {
                        Log.Info(this, "Unhandled Type: " + typeof(TestObject));
                        Console.WriteLine("Unhandled Type:" + typeof(TestObject));
                    }
                }

                return(currentExecutionObject);
            }

            Log.Error(this, "ExecutionObject is Null before execution");
            Console.WriteLine("ExecutionObject is Null before execution");
            return(null);
        }