Example #1
0
        public void loadCSharpScriptsGuiOnSeparateAppDomainUsingWCF_ManualWay()
        {
            // create Wcf Host
            var wcfHostName = "loadCSharpScriptsGui";
            var wcfHost     = O2WcfUtils.createWcfHostAndStartIt(wcfHostName);
            IO2WcfKernelMessage o2WcfClientProxy = wcfHost.getClientProxy();

            Assert.That(o2WcfClientProxy.allOK(), "o2WcfProxy was not OK");

            // create separateAppDomain
            var testAppDomain    = "AppDomainWithCSharpScripts";
            var targetAssemblies = new List <string> {
                typeof(StartCSharpScriptGui).Assembly.Location
            };
            var directoryWithSourceAssemblies = DI.config.hardCodedO2LocalBuildDir;
            var dependentAssemblies           = new CecilAssemblyDependencies(targetAssemblies, new List <string> {
                directoryWithSourceAssemblies
            }).calculateDependencies();

            o2WcfClientProxy.createAppDomainWithDlls(testAppDomain, new List <string>(dependentAssemblies.Values));

            // will just open an empty O2 Gui
            //o2WcfClientProxy.invokeOnAppDomainObject(testAppDomain, "O2AscxGUI", "launch",null);

            // open the CSharpScripts O2 Module by simulating the Main execution invocation
            o2WcfClientProxy.invokeOnAppDomainObject(testAppDomain, typeof(StartCSharpScriptGui).FullName, "Main", new object[0]);

            o2WcfClientProxy.invokeOnAppDomainObject(testAppDomain, "O2AscxGUI", "logInfo", new[] { "Hello from Unit test" });
            //   Processes.Sleep(2000);
            o2WcfClientProxy.invokeOnAppDomainObject(testAppDomain, "O2AscxGUI", "close", null);
            //  o2WcfClientProxy.invokeOnAppDomainObject(testAppDomain);
            //O2WcfUtils.
            wcfHost.stopHost();
        }
Example #2
0
        public void createGuiOnRemoteO2Kernel()
        {
            DI.log.info("Creating empty AscxGui via Remote O2Kernel");
            var newAppDomain            = "o2AscxGui";
            var dllToLoadInNewAppDomain = new List <string> {
                "O2_External_WinFormsUI.dll", "WeifenLuo.WinFormsUI.Docking.dll", "O2_Kernel.exe", "O2_DotNetWrappers.dll"
            };

            Assert.That(o2WcfProxy.createAppDomainWithDlls(newAppDomain, dllToLoadInNewAppDomain), "AppDomain Creation Failed");
            //Assert.Fail("Add check for isGuiAvailable");
            Assert.That(null != o2WcfProxy.invokeOnAppDomainObject(newAppDomain, "O2AscxGUI O2_External_WinFormsUI", "launch", null), "invokeOnAppDomainObject failed");
            Assert.That((bool)o2WcfProxy.invokeOnAppDomainObject(newAppDomain, "O2AscxGUI", "isGuiLoaded", new object[0]), "isGuiLoaded should be true here");
            DI.log.info("O2AscxGUI.isGuiLoaded = {0}", o2WcfProxy.invokeOnAppDomainObject(newAppDomain, "O2AscxGUI", "isGuiLoaded", new object[0]));
        }
        public void runTestsViaWcfProxy(IO2WcfKernelMessage o2WcfProxy)
        {
            // first thing to do is to create a new AppDomain that has all the required dlls for the two main types we want to load ascx_CirAnalysis and O2AscxGUI
            var testAppDomain    = "AppDomainWithCirData";
            var targetAssemblies = new List <string> {
                typeof(ascx_CirAnalysis).Assembly.Location, typeof(O2AscxGUI).Assembly.Location
            };
            var dependentAssemblies = new CecilAssemblyDependencies(targetAssemblies, new List <string> {
                DI.config.hardCodedO2LocalBuildDir
            }).calculateDependencies();

            o2WcfProxy.createAppDomainWithDlls(testAppDomain, new List <string>(dependentAssemblies.Values));

            // remote O2 Kernel is all set, now let's open the ascx_CirAnalyis control
            var ascxControlName = "Cir Analysis";

            o2WcfProxy.invokeOnAppDomainObject(testAppDomain, typeof(O2AscxGUI).FullName, "openAscxAsForm", new object[] { typeof(ascx_CirAnalysis).FullName, ascxControlName });

            // make sure it is there
            Assert.That((bool)o2WcfProxy.invokeOnAppDomainObject(testAppDomain, typeof(O2AscxGUI).FullName, "isAscxLoaded", new object[] { ascxControlName }), "isAscxLoaded should be true here");
            Assert.That(false == (bool)o2WcfProxy.invokeOnAppDomainObject(testAppDomain, typeof(O2AscxGUI).FullName, "isAscxLoaded", new object[] { "dummyControlName" }), "isAscxLoaded should be false here");

            // now load some CirData into it
            o2WcfProxy.O2Messages("executeOnAscxSync", new object[] { ascxControlName, "loadO2CirDataFile", new [] { DI.config.ExecutingAssembly } });

            // and retrive the data as string lists
            var cirClasses   = o2WcfProxy.getStringListFromAscxControl(ascxControlName, "getClasses", new string[0]);
            var cirFunctions = o2WcfProxy.getStringListFromAscxControl(ascxControlName, "getFunctions", new string[0]);

            Assert.That(cirClasses.Count > 0 && cirFunctions.Count > 0, "There were no classes or functions returned in cirClasses");
            DI.log.info("There were {0} classes returned", cirClasses.Count);
            DI.log.info("There were {0} functions returned", cirFunctions.Count);

            // close the control and its parant form
            o2WcfProxy.invokeOnAppDomainObject(testAppDomain, typeof(O2AscxGUI).FullName, "closeAscxParent", new object[] { ascxControlName });
        }
        public void runTestsViaWcfProxy(IO2WcfKernelMessage o2WcfProxy)
        {
            // first thing to do is to create a new AppDomain that has all the required dlls for the two main types we want to load ascx_CirAnalysis and O2AscxGUI
            var testAppDomain = "AppDomainWithCirData";
            var targetAssemblies = new List<string> { typeof(ascx_CirAnalysis).Assembly.Location, typeof(O2AscxGUI).Assembly.Location };
            var dependentAssemblies = new CecilAssemblyDependencies(targetAssemblies, new List<string> { DI.config.hardCodedO2LocalBuildDir }).calculateDependencies();
            o2WcfProxy.createAppDomainWithDlls(testAppDomain, new List<string>(dependentAssemblies.Values));
            
            // remote O2 Kernel is all set, now let's open the ascx_CirAnalyis control
            var ascxControlName = "Cir Analysis";
            o2WcfProxy.invokeOnAppDomainObject(testAppDomain, typeof(O2AscxGUI).FullName, "openAscxAsForm", new object[] { typeof(ascx_CirAnalysis).FullName, ascxControlName });

            // make sure it is there
            Assert.That((bool)o2WcfProxy.invokeOnAppDomainObject(testAppDomain, typeof(O2AscxGUI).FullName, "isAscxLoaded", new object[] { ascxControlName }), "isAscxLoaded should be true here");
            Assert.That(false == (bool)o2WcfProxy.invokeOnAppDomainObject(testAppDomain, typeof(O2AscxGUI).FullName, "isAscxLoaded", new object[] { "dummyControlName" }), "isAscxLoaded should be false here");

            // now load some CirData into it
            o2WcfProxy.O2Messages("executeOnAscxSync", new object[] { ascxControlName, "loadO2CirDataFile", new [] { DI.config.ExecutingAssembly } });

            // and retrive the data as string lists
            var cirClasses = o2WcfProxy.getStringListFromAscxControl(ascxControlName, "getClasses", new string[0]);
            var cirFunctions = o2WcfProxy.getStringListFromAscxControl(ascxControlName, "getFunctions", new string[0]);

            Assert.That(cirClasses.Count > 0 && cirFunctions.Count >0, "There were no classes or functions returned in cirClasses");
            DI.log.info("There were {0} classes returned", cirClasses.Count);                        
            DI.log.info("There were {0} functions returned", cirFunctions.Count);                        
                        
            // close the control and its parant form
            o2WcfProxy.invokeOnAppDomainObject(testAppDomain, typeof(O2AscxGUI).FullName, "closeAscxParent", new object[] { ascxControlName });            
        }