Пример #1
0
        /// <summary>
        /// The main.
        /// </summary>
        /// <param name="args">
        /// The args.
        /// </param>
        public static void Main(string[] args)
        {
            var assemblyPath = @"P:\EH.PCSW.Testautomation.TestFramework\ReleaseBin\Release\EH.PCPS.TestAutomation.Testlibrary.dll";

            //for (int i = 0; i < 100; i++)
            //{
            //    var methodIndos = AssemblyProxy.GetTestScriptMethodsFromAssembly(assemblyPath);

            //    foreach (var methodIndo in methodIndos)
            //    {
            //        Console.WriteLine(methodIndo.DeclaringType.FullName + "." + methodIndo.Name);
            //    }

            //    Console.WriteLine("-------------------------------------------------------------");
            //}


            for (int i = 0; i < 100; i++)
            {
                var methodIndos = AssemblyProxy.GetTestSuitesFileFromAssemby(@"Assembly v1.0.dll");

                foreach (var methodIndo in methodIndos)
                {
                    Console.WriteLine(methodIndo);

                    File.Delete(methodIndo);
                }

                Console.WriteLine("-------------------------------------------------------------");
            }

            Console.ReadLine();
        }
Пример #2
0
        /// <summary>
        /// InvariantAssert
        /// </summary>
        internal static void InvariantAssert()
        {
            AssemblyProxy p = new AssemblyProxy();

#if TESTBUILD_CLR40
            p.Load(@"WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL");
#endif
#if TESTBUILD_CLR20
            p.Load(@"WindowsBase, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL");
#endif
            p.Parameters.Add(false);
            p.ParametersTypes.Add(typeof(bool));
            p.Invoke("MS.Internal.Invariant", "Assert", null);
        }
Пример #3
0
        /// <summary>
        /// Returns the permission set granted to the caller assembly
        /// </summary>
        /// <returns>the granted permission set</returns>
        internal static PermissionSet GetGrantSet()
        {
            // load the mscorlib
            AssemblyProxy ap = new AssemblyProxy();

            ap.Load("mscorlib, Version=1.2.3400.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, ProcessorArchitecture=Neutral");

            // get the permission set granted to this assembly
            ap.Parameters.Add(new PermissionSet(PermissionState.None));
            ap.Parameters.Add(new PermissionSet(PermissionState.None));
            ap.Invoke("System.AppDomain", "nGetGrantSet", AppDomain.CurrentDomain);
            PermissionSet pset = (PermissionSet)ap.Parameters[0];

            ap.Parameters.Clear();
            return(pset);
        }
Пример #4
0
        public void AssemblyProxyTest()
        {
            AssemblyProxy assemblyProxy = new AssemblyProxy("UnitTest", path);

            InstanceProxy instanceProxy = new InstanceProxy(assemblyProxy, assemblyProxy.SupportType.FirstOrDefault());


            var intInvoker = instanceProxy.GetMethodInvoker <TESTINVOKER>("GetInt");
            int i          = intInvoker.Invoke <int>();

            var    methodinvoker = instanceProxy.GetMethodInvoker <TESTINVOKER>("GetString");
            string s             = methodinvoker.Invoke <string>("ABCDEFG");



            instanceProxy.Dispose();
        }
Пример #5
0
 private void RegisterProxiesFromDatabase()
 {
     ProxyManager.RegisterFromAssembly(Assembly.GetExecutingAssembly());
     foreach (var assemblyProxy in AssemblyProxy.GetAssemblyProxies())
     {
         try
         {
             _logger.Information("Loading proxies from - " + assemblyProxy.Assembly.FullName);
             ProxyManager.RegisterFromAssembly(assemblyProxy.Assembly);
         }
         catch (Exception e)
         {
             Console.WriteLine(e);
             throw;
         }
     }
 }
Пример #6
0
        public void UnloadTest()
        {
            Thread.Sleep(1500);
            int           count1        = AppDomain.CurrentDomain.GetAssemblies().Count();
            AssemblyProxy assemblyProxy = new AssemblyProxy("UnitTest", path);
            int           count2        = AppDomain.CurrentDomain.GetAssemblies().Count();

            Assert.IsTrue(count1 == count2);


            Thread.Sleep(1500);

            InstanceProxy instanceProxy = new InstanceProxy(assemblyProxy, assemblyProxy.SupportType.FirstOrDefault());

            count2 = AppDomain.CurrentDomain.GetAssemblies().Count();

            Assert.IsTrue(count1 == count2);
        }
Пример #7
0
        /// <summary>
        /// The add predefined test suites from assembly.
        /// </summary>
        /// <param name="rootObject">
        /// The root object.
        /// </param>
        /// <param name="loadingAssemblyName">
        /// The loading assembly name.
        /// </param>
        /// <param name="deviceFunctions">
        /// </param>
        public void AddPredefinedTestSuitesFromAssembly(TestCollection rootObject, string loadingAssemblyName, List <DeviceFunction> deviceFunctions)
        {
            if (deviceFunctions != null)
            {
                var suitesFiles = AssemblyProxy.GetTestSuitesFileFromAssembly(loadingAssemblyName);

                foreach (var suitesFile in suitesFiles)
                {
                    try
                    {
                        var testConfig = new TestConfiguration();
                        testConfig = testConfig.GetTestConfiguration(suitesFile.ResourceNameFullPath);

                        foreach (var availableTestObject in testConfig.AvailableTestObjects)
                        {
                            if (availableTestObject is TestSuite)
                            {
                                var testSuite = availableTestObject as TestSuite;
                                if (testSuite.TestCategory == TestCategory.DeviceTypeAcceptance)
                                {
                                    testConfig.AvailableTestObjects = FilderTestConfig(deviceFunctions, testSuite.TestObjects);

                                    // var testObjects = this.AddNamespaceToTestObjectCollection(rootObject, string.Format("{0}.{1}.{2}", testSuite.TestDefinition, testSuite.TestCategory, testSuite.TestFocus), testConfig.AvailableTestObjects);
                                    var testObjects = this.AddNamespaceToTestObjectCollection(rootObject, string.Format("{0}", testSuite.TestDefinition), testConfig.AvailableTestObjects);

                                    foreach (var testObject in testObjects)
                                    {
                                        MergeTestObjectCollection(this.TestConfiguration.AvailableTestObjects, testObject as TestCollection);
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.ErrorEx(this, ex, string.Format("AddPredefinedTestSuitesFromAssembly: {0} - {1}", suitesFile.ResourceNameFullPath, ex.Message));
                    }
                    finally
                    {
                        File.Delete(suitesFile.ResourceNameFullPath);
                    }
                }
            }
        }
Пример #8
0
        /// <summary>
        /// The get method info from assembly.
        /// </summary>
        /// <param name="assemblyName">
        /// The assembly name.
        /// </param>
        /// <returns>
        /// The <see cref="EhMethodInfo"/>.
        /// </returns>
        public EhMethodInfoCollection GetMethodInfoFromAssembly(string assemblyName)
        {
            Log.Enter(this, string.Format("GetTestScriptMethodsFromAssembly: {0}", assemblyName));

            try
            {
                if (File.Exists(assemblyName))
                {
                    return(AssemblyProxy.GetTestScriptMethodsFromAssembly(assemblyName));
                }

                Log.Error(this, string.Format("The {0} file does not exist", assemblyName));
            }
            catch (Exception ex)
            {
                Log.ErrorEx(this, ex, string.Format("GetTestScriptMethodsFromAssembly: {0}", ex.Message));
            }

            return(null);
        }
        /// <summary>
        /// The get setup delivery device functions from assembly.
        /// </summary>
        /// <param name="testFrameworkAssemblyPath">
        /// The test framework assembly path.
        /// </param>
        /// <returns>
        /// The <see cref="DeviceFunction"/>.
        /// </returns>
        public static List <DeviceFunction> GetSetupDeliveryDeviceFunctionsFromAssembly(string testFrameworkAssemblyPath)
        {
            var deviceFunctionList = new List <DeviceFunction>();

            var suitesFiles = AssemblyProxy.GetTestSuitesFileFromAssembly(testFrameworkAssemblyPath);

            foreach (var suitesFile in suitesFiles)
            {
                try
                {
                    var testConfig = new TestConfiguration();
                    testConfig = testConfig.GetTestConfiguration(suitesFile.ResourceNameFullPath);

                    foreach (var availableTestObject in testConfig.AvailableTestObjects)
                    {
                        if (availableTestObject is TestSuite)
                        {
                            var testSuite = availableTestObject as TestSuite;
                            if (testSuite.TestCategory == TestCategory.SetupDelivery)
                            {
                                var deviceFunction = new DeviceFunction
                                {
                                    DisplayName = testSuite.TestFocus.ToString(),
                                    Name        = testSuite.TestFocus.ToString(),
                                    Active      = true,
                                    Version     = new Version()
                                };

                                deviceFunctionList.Add(deviceFunction);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Log.ErrorEx(null, ex, string.Format("AddPredefinedTestSuitesFromAssembly: {0} - {1}", suitesFile.ResourceNameFullPath, ex.Message));
                }
            }

            return(deviceFunctionList);
        }
Пример #10
0
        public static void ShutdownApplication(Application app)
        {
            AssemblyProxy ap = new AssemblyProxy();

            //This now works because PKT and version #'s have been static for multiple releases.
#if TESTBUILD_CLR40
            ap.Load("PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL");
#endif
#if TESTBUILD_CLR20
            ap.Load("PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL");
#endif
            //This works, but only if the assembly's already loaded.
            //This turns out not to be true in our basic scenarios 1-6 (no framework loaded yet).
            //ap.Load("PresentationFramework");

            //This works in all cases.  There's just the problem of the API being deprecated.
            //Hopefully they don't remove it entirely.
            //ap.LoadWithPartialName("PresentationFramework");

            ap.Invoke("System.Windows.Application", "ShutdownImpl", app);
        }
Пример #11
0
        /// <summary>
        /// The add test suites from assembly.
        /// </summary>
        /// <param name="loadingAssemblyName">
        /// The loading assembly name.
        /// </param>
        private void AddTestSuitesFromAssembly(string loadingAssemblyName)
        {
            var suitesFiles = AssemblyProxy.GetTestSuitesFileFromAssembly(loadingAssemblyName);

            foreach (var suitesFile in suitesFiles)
            {
                var testConfig = new TestConfiguration();

                var allAvailableTestObjects = testConfig.GetTestConfiguration(suitesFile.ResourceNameFullPath).AvailableTestObjects;

                var testObjectNamespace = Path.GetFileNameWithoutExtension(Path.GetFileNameWithoutExtension(suitesFile.ResourceName));

                var testObjects = this.AddNamespaceToTestObjectCollection(testObjectNamespace, allAvailableTestObjects);

                foreach (var testObject in testObjects)
                {
                    MergeTestObjectCollection(this.TestConfiguration.AvailableTestObjects, testObject as TestCollection);
                }

                File.Delete(suitesFile.ResourceNameFullPath);
            }
        }
Пример #12
0
        private XmlDocument GetDocument(AssemblyProxy assembly)
        {
            XmlDocument document = null;

            if (!_cache.TryGetValue(assembly, out document))
            {
                var path = assembly.Location;

                path = Path.ChangeExtension(path, ".xml");

                if (File.Exists(path))
                {
                    document = new XmlDocument();

                    document.Load(path);
                }

                _cache.Add(assembly, document);
            }

            return(document);
        }
Пример #13
0
        private static void RegComponent(string dllFile)
        {
            AssemblyProxy ap = new AssemblyProxy(dllFile);

            ap.regAssembly();
        }