コード例 #1
0
        public void BuildValuedTypeParams_GivenValid_ShouldPassThrough()
        {
            //---------------Set up test pack-------------------
            var pipeMock        = new Mock <INamedPipeClientStreamWrapper>();
            var memoryStream    = new MemoryStream();
            var serializeObject = JsonConvert.SerializeObject(GetType());

            memoryStream.WriteByte(Encoding.ASCII.GetBytes(serializeObject)[0]);
            pipeMock.Setup(wrapper => wrapper.GetInternalStream()).Returns(memoryStream);
            var client               = IpcClient.GetIPCExecutor(pipeMock.Object);
            var type                 = typeof(ComPluginRuntimeHandler);
            var methodInfo           = type.GetMethod("BuildValuedTypeParams", BindingFlags.Static | BindingFlags.NonPublic);
            ComPluginInvokeArgs args = new ComPluginInvokeArgs
            {
                ClsId      = adodbConnectionClassId,
                Is32Bit    = false,
                Method     = "ToString",
                Parameters = new List <MethodParameter>()
                {
                    new MethodParameter()
                    {
                        Value    = "hi",
                        TypeName = typeof(string).FullName
                    }
                }
            };

            //---------------Assert Precondition----------------
            Assert.IsNotNull(client);
            //---------------Execute Test ----------------------
            var enumerable = methodInfo.Invoke("BuildValuedTypeParams", new object[] { args }) as IEnumerable <object>;

            //---------------Test Result -----------------------
            Assert.AreEqual(1, enumerable?.Count());
        }
コード例 #2
0
        /// <summary>
        /// Lists the namespaces.
        /// </summary>
        /// <param name="classId">The assembly location.</param>
        /// <param name="is32Bit"></param>
        /// <returns></returns>
        List <string> ListNamespaces(string classId, bool is32Bit)
        {
            try
            {
                if (is32Bit)
                {
                    var execute       = IpcClient.GetIPCExecutor(_clientStreamWrapper).Invoke(classId.ToGuid(), "", Execute.GetNamespaces, new ParameterInfoTO[] { });
                    var namespaceList = execute as List <string>;
                    return(namespaceList);
                }
                var type           = GetType(classId, false);
                var loadedAssembly = type.Assembly;
                // ensure we flush out the rubbish that GAC brings ;)
                var namespaces = loadedAssembly.GetTypes()
                                 .Select(t => t.FullName)
                                 .Distinct()
                                 .Where(q => q.IndexOf("`", StringComparison.Ordinal) < 0 &&
                                        q.IndexOf("+", StringComparison.Ordinal) < 0 &&
                                        q.IndexOf("<", StringComparison.Ordinal) < 0 &&
                                        !q.StartsWith("_")).ToList();

                return(namespaces);
            }
            catch (BadImageFormatException e)
            {
                Dev2Logger.Error(e, GlobalConstants.WarewolfError);
                throw;
            }
        }
コード例 #3
0
        Type GetType(string classId, bool is32Bit)
        {
            Guid.TryParse(classId, out Guid clasID);
            var  is64BitProcess = Environment.Is64BitProcess;
            Type type;

            if (is64BitProcess && is32Bit)
            {
                try
                {
                    var execute = IpcClient.GetIPCExecutor(_clientStreamWrapper).Invoke(clasID, "", Execute.GetType, new ParameterInfoTO[] { });
                    type = execute as Type;
                }
                catch (Exception ex)
                {
                    Dev2Logger.Error("GetType", ex, GlobalConstants.WarewolfError);
                    type = Type.GetTypeFromCLSID(clasID, true);
                }
            }
            else
            {
                type = Type.GetTypeFromCLSID(clasID, true);
            }
            return(string.IsNullOrEmpty(classId) ? null : type);
        }
コード例 #4
0
        public void WarewolfCOMIPCClient_Execute_GetType_ShouldReturnType()
        {
            //------------Setup for test--------------------------
            var clsid = new Guid(ComPluginRuntimeHandlerTest.adodbConnectionClassId);

            //------------Execute Test---------------------------
            var execute = (KeyValuePair <bool, string>)IpcClient.GetIPCExecutor().Invoke(clsid, "", Execute.GetType, new ParameterInfoTO[] { });

            //------------Assert Results-------------------------
            Assert.IsNotNull(execute.Value);
        }
コード例 #5
0
        public void ExecuteSpecifiedMethod_GivenConnection_ReturnSuccess()
        {
            //---------------Set up test pack-------------------
            var classId = new Guid(ComPluginRuntimeHandlerTest.adodbConnectionClassId);
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            var execute = (KeyValuePair <bool, string>)IpcClient.GetIPCExecutor().Invoke(classId, "Open", Execute.ExecuteSpecifiedMethod, new ParameterInfoTO[] { });

            //---------------Test Result -----------------------

            Assert.IsNotNull(execute.Value);
        }
コード例 #6
0
        public void GetMethods_GivenConnection_ShouldReturnMethodList()
        {
            //---------------Set up test pack-------------------
            var classId = new Guid(ComPluginRuntimeHandlerTest.adodbConnectionClassId);

            //---------------Execute Test ----------------------
            var execute    = IpcClient.GetIPCExecutor().Invoke(classId, "", Execute.GetMethods, new ParameterInfoTO[] { });
            var enumerable = execute as List <MethodInfoTO>;

            //---------------Test Result -----------------------
            Assert.IsNotNull(enumerable);
            Assert.AreEqual(30, enumerable.Count);
        }
コード例 #7
0
        public void GetIPCExecutor_GivenPipeStream_ShouldResult()
        {
            //---------------Set up test pack-------------------
            var pipeMock = new Mock <INamedPipeClientStreamWrapper>();
            var client   = new IpcClient(pipeMock.Object);

            //---------------Assert Precondition----------------
            Assert.IsNotNull(client);
            //---------------Execute Test ----------------------
            var ipcExecutor = IpcClient.GetIPCExecutor(pipeMock.Object);

            //---------------Test Result -----------------------
            Assert.IsNotNull(ipcExecutor);
            Assert.IsFalse(ReferenceEquals(client, ipcExecutor));
        }
コード例 #8
0
        public void Dispose_PassThrough()
        {
            //---------------Set up test pack-------------------
            var pipeMock = new Mock <INamedPipeClientStreamWrapper>();

            pipeMock.Setup(wrapper => wrapper.Dispose()).Verifiable();
            pipeMock.Setup(wrapper => wrapper.Close()).Verifiable();

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            using (var client = IpcClient.GetIPCExecutor(pipeMock.Object))
            {
                Assert.IsNotNull(client);
            }
            //---------------Test Result -----------------------
            pipeMock.VerifyAll();
        }
コード例 #9
0
        MethodInfo ExecuteComPlugin(ComPluginInvokeArgs setupInfo, out object pluginResult)
        {
            if (!string.IsNullOrEmpty(setupInfo.ClsId))
            {
                if (setupInfo.Is32Bit)
                {
                    var strings = setupInfo.Parameters.Select(parameter => new ParameterInfoTO {
                        Name = parameter.Name, DefaultValue = parameter.Value, TypeName = parameter.TypeName
                    }).ToArray();
                    pluginResult = IpcClient.GetIPCExecutor(_clientStreamWrapper).Invoke(setupInfo.ClsId.ToGuid(), setupInfo.Method, Execute.ExecuteSpecifiedMethod, strings);
                    return(null);
                }
                var typeList       = BuildTypeList(setupInfo.Parameters);
                var valuedTypeList = TryBuildValuedTypeParams(setupInfo);
                var type           = GetType(setupInfo.ClsId, setupInfo.Is32Bit);
                var methodToRun    = type.GetMethod(setupInfo.Method, typeList.ToArray()) ??
                                     type.GetMethod(setupInfo.Method);
                if (methodToRun == null && typeList.Count == 0)
                {
                    methodToRun = type.GetMethod(setupInfo.Method);
                }
                var instance = Activator.CreateInstance(type);

                if (methodToRun != null)
                {
                    if (methodToRun.ReturnType == typeof(void))
                    {
                        methodToRun.Invoke(instance,
                                           BindingFlags.InvokeMethod | BindingFlags.IgnoreCase | BindingFlags.Public, null,
                                           valuedTypeList.ToArray(), CultureInfo.InvariantCulture);
                    }
                    else
                    {
                        pluginResult = methodToRun.Invoke(instance,
                                                          BindingFlags.InvokeMethod | BindingFlags.IgnoreCase | BindingFlags.Public, null,
                                                          valuedTypeList.ToArray(), CultureInfo.InvariantCulture);
                        return(methodToRun);
                    }
                }
            }
            pluginResult = null;
            return(null);
        }
コード例 #10
0
        public void Invoke_GivenExecuteSpecifiedMethod_ShouldReturnResult()
        {
            //---------------Set up test pack-------------------
            var pipeMock        = new Mock <INamedPipeClientStreamWrapper>();
            var memoryStream    = new MemoryStream();
            var serializeObject = JsonConvert.SerializeObject(GetType());

            memoryStream.WriteByte(Encoding.ASCII.GetBytes(serializeObject)[0]);
            pipeMock.Setup(wrapper => wrapper.GetInternalStream()).Returns(memoryStream);
            var client = IpcClient.GetIPCExecutor(pipeMock.Object);

            //---------------Assert Precondition----------------
            Assert.IsNotNull(client);
            //---------------Execute Test ----------------------
            var invoke = client.Invoke(Guid.Parse(adodbConnectionClassId), "ToString", Execute.ExecuteSpecifiedMethod, new ParameterInfoTO[] { });

            //---------------Test Result -----------------------
            Assert.IsNull(invoke);
        }
コード例 #11
0
        void Run(bool interactiveMode)
        {
            Tracker.StartServer();

            // ** Perform Moq Installer Actions For Development ( DEBUG config ) **
#if DEBUG
            try
            {
                var miq = MoqInstallerActionFactory.CreateInstallerActions();
                miq.ExecuteMoqInstallerActions();
            }
            catch (Exception e)
            {
                throw new Exception("Ensure you are running as an Administrator. Mocking installer actions for DEBUG config failed to create Warewolf Administrators group and/or to add current user to it [ " + e.Message + " ]", e);
            }
#endif

            try
            {
                SetWorkingDirectory();
                LoadHostSecurityProvider();
                MigrateOldTests();
                InitializeServer();
                LoadSettingsProvider();
                ConfigureLoggging();
                _ipcIpcClient = IpcClient.GetIPCExecutor();
                var catalog = LoadResourceCatalog();
                StartWebServer();
                _timer = new Timer(PerformTimerActions, null, 1000, GlobalConstants.NetworkComputerNameQueryFreq);
                StartPulseLogger();
                LoadPerformanceCounters();
                LoadServerWorkspace();
                LoadActivityCache(catalog);
                LoadTestCatalog();
                ServerLoop(interactiveMode);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                Dev2Logger.Error("Error Starting Server", e);
                Stop(true, 0);
            }
        }
コード例 #12
0
        public ServiceMethodList ListMethods(string classId, bool is32Bit)
        {
            var serviceMethodList = new List <ServiceMethod>();
            var orderMethodsList  = new ServiceMethodList();

            classId = classId.Replace("{", "").Replace("}", "");
            if (is32Bit)
            {
                var execute = IpcClient.GetIPCExecutor(_clientStreamWrapper).Invoke(classId.ToGuid(), "", Execute.GetMethods, new ParameterInfoTO[] { });
                if (execute is List <MethodInfoTO> ipcMethods)
                {
                    ServiceMethodList(ref serviceMethodList, orderMethodsList, ipcMethods);
                    return(orderMethodsList);
                }
            }
            if (string.IsNullOrEmpty(classId))
            {
                return(new ServiceMethodList());
            }
            var type        = Type.GetTypeFromCLSID(classId.ToGuid(), true);
            var methodInfos = type.GetMethods();

            methodInfos.ToList().ForEach(info =>
            {
                var serviceMethod = new ServiceMethod {
                    Name = info.Name
                };
                var parameterInfos = info.GetParameters().ToList();
                parameterInfos.ForEach(parameterInfo =>
                                       serviceMethod.Parameters.Add(
                                           new MethodParameter
                {
                    DefaultValue = parameterInfo.DefaultValue?.ToString() ?? string.Empty,
                    EmptyToNull  = false,
                    IsRequired   = true,
                    Name         = parameterInfo.Name,
                    TypeName     = parameterInfo.ParameterType.AssemblyQualifiedName
                }));
                orderMethodsList.Add(serviceMethod);
            });
            return(orderMethodsList);
        }
コード例 #13
0
 void OpenCOMStream()
 {
     Write("Opening named pipe client stream for COM IPC... ");
     _ipcIpcClient = IpcClient.GetIPCExecutor();
     WriteLine("done.");
 }