public void ComPluginServicesMethodsWithInvalidArgsExpectedReturnsEmptyList() { var services = new ComPluginServices(); var result = services.Methods(new ComPluginService(), Guid.Empty, Guid.Empty); Assert.AreEqual(0, result.Count); }
public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace) { var serializer = new Dev2JsonSerializer(); try { var pluginSource = serializer.Deserialize <ComPluginSourceDefinition>(values["source"]); var ns = serializer.Deserialize <INamespaceItem>(values["namespace"]); // ReSharper disable MaximumChainedReferences ComPluginServices services = new ComPluginServices(); var src = ResourceCatalog.Instance.GetResource <ComPluginSource>(GlobalConstants.ServerWorkspaceID, pluginSource.Id); //src.AssemblyName = ns.FullName; ComPluginService svc = new ComPluginService(); if (ns != null) { svc.Namespace = ns.FullName; svc.Source = src; } else { svc.Source = src; } var serviceMethodList = services.Methods(svc, Guid.Empty, Guid.Empty); var methods = serviceMethodList.Select(a => new PluginAction { FullName = ns?.FullName, Inputs = a.Parameters.Select(x => new ServiceInput(x.Name, x.DefaultValue ?? "") { Name = BuildServiceInputName(x.Name, x.TypeName) , EmptyIsNull = x.EmptyToNull , RequiredField = x.IsRequired , TypeName = x.TypeName } as IServiceInput).ToList(), Method = a.Name, Variables = a.Parameters.Select(x => new NameValue() { Name = x.Name + " (" + x.TypeName + ")", Value = "" } as INameValue).ToList(), } as IPluginAction).ToList(); return(serializer.SerializeToBuilder(new ExecuteMessage() { HasError = false, Message = serializer.SerializeToBuilder(methods) })); } catch (Exception e) { return(serializer.SerializeToBuilder(new ExecuteMessage() { HasError = true, Message = new StringBuilder(e.Message) })); } }
public void ComPluginServicesMethodsWithValidArgsExpectedReturnsList() { var service = CreatePluginService(); var workspaceID = Guid.NewGuid(); EnvironmentVariables.GetWorkspacePath(workspaceID); var services = new ComPluginServices(); var result = services.Methods(service, workspaceID, Guid.Empty); Assert.IsTrue(result.Count > 5, "Not enough items in COM server method list."); }
public void ComPluginServicesMethodsWithValidArgsExpectedReturnsList() { var service = CreatePluginService(); var workspaceID = Guid.NewGuid(); EnvironmentVariables.GetWorkspacePath(workspaceID); var services = new ComPluginServices(); var result = services.Methods(service, workspaceID, Guid.Empty); Assert.AreEqual(55, result.Count); }
public override StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace) { var serializer = new Dev2JsonSerializer(); try { var pluginSource = serializer.Deserialize <ComPluginSourceDefinition>(values["source"]); var ns = serializer.Deserialize <INamespaceItem>(values["namespace"]); var services = new ComPluginServices(); var src = ResourceCatalog.Instance.GetResource <ComPluginSource>(GlobalConstants.ServerWorkspaceID, pluginSource.Id); var svc = new ComPluginService(); if (ns != null) { svc.Namespace = ns.FullName; svc.Source = src; } else { svc.Source = src; } var serviceMethodList = new ServiceMethodList(); var task = Task.Run(() => { return(serviceMethodList = services.Methods(svc, Guid.Empty, Guid.Empty)); }); try { var timeoutAfter = task.TimeoutAfter(TimeSpan.FromSeconds(3)); serviceMethodList = timeoutAfter.Result; } catch (Exception e) { Dev2Logger.Error(e, GlobalConstants.WarewolfError); } var methods = serviceMethodList.Select(a => new PluginAction { FullName = ns?.FullName, Inputs = a.Parameters.Select(x => new ServiceInput(x.Name, x.DefaultValue ?? "") { Name = BuildServiceInputName(x.Name, x.TypeName) , EmptyIsNull = x.EmptyToNull , RequiredField = x.IsRequired , TypeName = x.TypeName } as IServiceInput).ToList(), Method = a.Name, Variables = a.Parameters.Select(x => new NameValue { Name = x.Name + " (" + x.TypeName + ")", Value = "" } as INameValue).ToList(), } as IPluginAction).ToList(); return(serializer.SerializeToBuilder(new ExecuteMessage { HasError = false, Message = serializer.SerializeToBuilder(methods) })); } catch (Exception e) { return(serializer.SerializeToBuilder(new ExecuteMessage() { HasError = true, Message = new StringBuilder(e.Message) })); } }