Dev2.Runtime.ServiceModel.PluginServices.Test C# (CSharp) Method

Test() public method

public Test ( string args, System.Guid workspaceId, System.Guid dataListId ) : RecordsetList
args string
workspaceId System.Guid
dataListId System.Guid
return RecordsetList
        public RecordsetList Test(string args, Guid workspaceId, Guid dataListId)
        {
            try
            {
           
                
                var service = JsonConvert.DeserializeObject<PluginService>(args,new JsonSerializerSettings
            {
                TypeNameHandling = TypeNameHandling.Objects
            });
                var pluginSourceFromCatalog = _resourceCatalog.GetResource<PluginSource>(workspaceId, service.Source.ResourceID);
                if (pluginSourceFromCatalog == null)
                {
                    try
                    {
                        var xmlStr = Resources.ReadXml(workspaceId, ResourceType.PluginSource, service.Source.ResourceID.ToString());
                        if (!string.IsNullOrEmpty(xmlStr))
                        {
                            var xml = XElement.Parse(xmlStr);
                            pluginSourceFromCatalog = new PluginSource(xml);
                        }
                    }
                    catch(Exception)
                    {
                        //ignore the exception
                    }
                }
                if (pluginSourceFromCatalog != null)
                {
                    service.Source = pluginSourceFromCatalog;
                }
                return FetchRecordset(service, true);
            }
            catch(Exception ex)
            {
                RaiseError(ex);
                return new RecordsetList { new Recordset { HasErrors = true, ErrorMessage = ex.Message } };
            }
        }

Usage Example

        public void PluginServices_Test_WhenTestingPluginReturningJsonString_ExpectValidPaths()
        {
            //------------Setup for test--------------------------
            var path = UnpackDLL("PrimativesTestDLL");

            if(string.IsNullOrEmpty(path))
            {
                Assert.Fail("Failed to unpack required DLL [ PrimativesTestDLL ] ");
            }

            var pluginServices = new PluginServices();
            var serviceDef = JsonResource.Fetch("PrimitivePluginReturningJsonString");

            //------------Execute Test---------------------------
            var result = pluginServices.Test(serviceDef, Guid.Empty, Guid.Empty);
            ////------------Assert Results-------------------------
            Assert.AreEqual(1, result[0].Fields.Count);
            StringAssert.Contains(result[0].Fields[0].Alias, "message");
            StringAssert.Contains(result[0].Fields[0].Name, "message");
            StringAssert.Contains(result[0].Fields[0].Path.ActualPath, "message");
            StringAssert.Contains(result[0].Fields[0].Path.SampleData, "Howzit__COMMA__");
        }