public void ComPluginSourceContructorWithDefaultExpectedInitializesProperties() { var source = new ComPluginSource(); Assert.AreEqual(Guid.Empty, source.ResourceID); Assert.AreEqual("ComPluginSource", source.ResourceType); }
// POST: Service/PluginServices/Namespaces public virtual NamespaceList Namespaces(ComPluginSource args, Guid workspaceId, Guid dataListId) { var result = new NamespaceList(); try { if (args != null) { var broker = new ComPluginBroker(); return(broker.GetNamespaces(args)); } } catch (BadImageFormatException e) { RaiseError(e); throw; } catch (Exception ex) when(ex is COMException) { throw; } catch (Exception ex) { RaiseError(ex); } return(result); }
public void DsfComDllActivity_ExecutionImpl_Catch_Common_IsNotNull_Expect_NoError() { //-----------------------Arrange--------------------- var mockEsbChannel = new Mock <IEsbChannel>(); var mockPluginAction = new Mock <IPluginAction>(); var mockResourceCatalog = new Mock <IResourceCatalog>(); var mockDSFDataObject = new Mock <IDSFDataObject>(); var mockOutputDescription = new Mock <IOutputDescription>(); var mockPath = new Mock <IPath>(); var mockDataSourceShape = new Mock <IDataSourceShape>(); var comPluginSource = new ComPluginSource() { ClsId = "some ClsID" }; Thread.CurrentPrincipal = null; var identity = new GenericIdentity("User"); var currentPrincipal = new GenericPrincipal(identity, new[] { "Role1", "Roll2" }); Thread.CurrentPrincipal = currentPrincipal; Common.Utilities.ServerUser = currentPrincipal; var dataListID = Guid.NewGuid(); var environment = new ExecutionEnvironment(); var outputs = new List <IServiceOutputMapping> { new ServiceOutputMapping() }; var dsfComDllActivity = new TestDsfComDllActivity() { ResourceCatalog = mockResourceCatalog.Object, Method = mockPluginAction.Object, Inputs = new List <IServiceInput>() { new ServiceInput("[[a]]", "asa") }, Outputs = outputs, OutputDescription = mockOutputDescription.Object }; mockDataSourceShape.Setup(o => o.Paths).Returns(new List <IPath> { mockPath.Object }); mockPluginAction.Setup(o => o.Method).Returns("TestMethod"); mockResourceCatalog.Setup(o => o.GetResource <ComPluginSource>(It.IsAny <Guid>(), It.IsAny <Guid>())).Returns(comPluginSource); mockOutputDescription.Setup(o => o.DataSourceShapes).Returns(new List <IDataSourceShape> { mockDataSourceShape.Object }); mockOutputDescription.Setup(o => o.Format).Returns(OutputFormats.ShapedXML); mockDSFDataObject.Setup(o => o.DataListID).Returns(dataListID); mockDSFDataObject.Setup(o => o.Environment).Returns(environment); //-----------------------Act------------------------- dsfComDllActivity.TestExecutionImpl(mockEsbChannel.Object, mockDSFDataObject.Object, "TestInput", "TestOutput", out ErrorResultTO errorResult, 0); //-----------------------Assert---------------------- mockResourceCatalog.Verify(o => o.GetResource <ComPluginSource>(It.IsAny <Guid>(), It.IsAny <Guid>()), Times.Once); Assert.AreEqual(comPluginSource.ClsId, dsfComDllActivity._comPluginInvokeArgs.ClsId); Assert.AreEqual(0, errorResult.FetchErrors().Count); }
public IComPluginSource FetchSource(Guid pluginSourceId) { var xaml = _queryProxy.FetchResourceXaml(pluginSourceId); var db = new ComPluginSource(xaml.ToXElement()); var def = new ComPluginSourceDefinition(db); return(def); }
public void ComPluginSourceContructorWithInvalidXmlExpectedDoesNotThrowExceptionAndInitializesProperties() { var xml = new XElement("root"); var source = new ComPluginSource(xml); Assert.AreNotEqual(Guid.Empty, source.ResourceID); Assert.IsTrue(source.IsUpgraded); Assert.AreEqual("ComPluginSource", source.ResourceType); }
/// <summary> /// Fetches the name space list object. /// </summary> /// <param name="pluginSource">The plugin source.</param> /// <returns></returns> public NamespaceList FetchNamespaceListObject(ComPluginSource pluginSource) { var interrogatePlugin = ReadNamespaces(pluginSource.ClsId, pluginSource.Is32Bit); var namespacelist = new NamespaceList(); namespacelist.AddRange(interrogatePlugin); namespacelist.Add(new NamespaceItem()); return(namespacelist); }
public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace) { ExecuteMessage msg = new ExecuteMessage(); Dev2JsonSerializer serializer = new Dev2JsonSerializer(); try { Dev2Logger.Info("Save Com Plugin Source"); StringBuilder resourceDefinition; values.TryGetValue("ComPluginSource", out resourceDefinition); var src = serializer.Deserialize <ComPluginSourceDefinition>(resourceDefinition); if (src.ResourcePath == null) { src.ResourcePath = string.Empty; } if (src.ResourcePath.EndsWith("\\")) { src.ResourcePath = src.ResourcePath.Substring(0, src.ResourcePath.LastIndexOf("\\", StringComparison.Ordinal)); } ComPluginSource res1; var existingSource = ResourceCat.GetResource(GlobalConstants.ServerWorkspaceID, src.Name); if (existingSource != null) { res1 = existingSource as ComPluginSource; } else { res1 = new ComPluginSource { ResourceID = src.Id, ClsId = src.ClsId, Is32Bit = src.Is32Bit, ComName = src.SelectedDll.Name, ResourceName = src.ResourceName }; } ResourceCat.SaveResource(GlobalConstants.ServerWorkspaceID, res1, src.ResourcePath); msg.HasError = false; } catch (Exception err) { msg.HasError = true; msg.Message = new StringBuilder(err.Message); Dev2Logger.Error(err); } return(serializer.SerializeToBuilder(msg)); }
public void ComPluginSourceToXmlWithNullPropertiesExpectedSerializesPropertiesAsEmpty() { var expected = new ComPluginSource { ClsId = null, Is32Bit = false, }; var xml = expected.ToXml(); var actual = new ComPluginSource(xml); Assert.AreEqual(expected.ResourceType, actual.ResourceType); Assert.AreEqual("", actual.ClsId); Assert.AreEqual(false, actual.Is32Bit); }
public void ComPluginSourceToXmlExpectedSerializesProperties() { var expected = new ComPluginSource { ClsId = "Plugins\\someDllIMadeUpToTest.dll", Is32Bit = false, }; var xml = expected.ToXml(); var actual = new ComPluginSource(xml); Assert.AreEqual(expected.ResourceType, actual.ResourceType); Assert.AreEqual(expected.ClsId, actual.ClsId); Assert.AreEqual(expected.Is32Bit, actual.Is32Bit); }
public void Execute_GivenResourceDefination_GivenExising_ShouldReturnResourceDefinationMsg() { //---------------Set up test pack------------------- var serializer = new Dev2JsonSerializer(); var source = new ComPluginSourceDefinition() { Id = Guid.Empty, ResourceName = "Name", ClsId = Guid.NewGuid().ToString(), ResourcePath = Environment.CurrentDirectory, SelectedDll = new DllListing() { Name = "k" } }; var compressedExecuteMessage = new CompressedExecuteMessage(); var serializeToJsonString = source.SerializeToJsonString(new DefaultSerializationBinder()); compressedExecuteMessage.SetMessage(serializeToJsonString); var values = new Dictionary <string, StringBuilder> { { "ComPluginSource", source.SerializeToJsonStringBuilder() } }; var catalog = new Mock <IResourceCatalog>(); var comPluginSource = new ComPluginSource(); catalog.Setup(resourceCatalog => resourceCatalog.GetResource(It.IsAny <Guid>(), source.ResourceName, It.IsAny <string>(), It.IsAny <string>())).Returns(comPluginSource); catalog.Setup(resourceCatalog => resourceCatalog.SaveResource(It.IsAny <Guid>(), comPluginSource, It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())); var saveComPluginSource = new SaveComPluginSource(catalog.Object); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- StringBuilder jsonResult = saveComPluginSource.Execute(values, null); var result = serializer.Deserialize <ExecuteMessage>(jsonResult); //---------------Test Result ----------------------- Assert.IsFalse(result.HasError); catalog.Verify(resourceCatalog => resourceCatalog.GetResource(It.IsAny <Guid>(), source.ResourceName, It.IsAny <string>(), It.IsAny <string>())); catalog.Verify(resourceCatalog => resourceCatalog.SaveResource(It.IsAny <Guid>(), comPluginSource, It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())); }
static IResource ComPlusgInResource() { IResource resource = new ComPluginSource(); return(resource); }
public void ComPluginSourceContructorWithNullXmlExpectedThrowsArgumentNullException() { var source = new ComPluginSource(null); }
public static NamespaceList GetNamespaces(ComPluginSource pluginSource) { var runtime = CreateInvokeAppDomain(); return(runtime.FetchNamespaceListObject(pluginSource)); }