Esempio n. 1
0
        public void SourcesWithValidArgsExpectedReturnsList()
        {
            var workspaceID   = Guid.NewGuid();
            var workspacePath = EnvironmentVariables.GetWorkspacePath(workspaceID);

            try
            {
                const int Modulo        = 2;
                const int ExpectedCount = 6;
                for (var i = 0; i < ExpectedCount; i++)
                {
                    var resource = new Resource
                    {
                        ResourceID   = Guid.NewGuid(),
                        ResourceName = string.Format("My Name {0}", i),
                        ResourcePath = string.Format("My Path {0}", i),
                        ResourceType = (i % Modulo == 0) ? ResourceType.DbSource : ResourceType.Unknown
                    };
                    ResourceCatalog.Instance.SaveResource(workspaceID, resource);
                }
                var resources = new Dev2.Runtime.ServiceModel.Resources();
                var result    = resources.Sources("{\"resourceType\":\"" + ResourceType.DbSource + "\"}", workspaceID, Guid.Empty);

                Assert.AreEqual(ExpectedCount / Modulo, result.Count);
            }
            finally
            {
                if (Directory.Exists(workspacePath))
                {
                    DirectoryHelper.CleanUp(workspacePath);
                }
            }
        }
Esempio n. 2
0
        public void Paths_Expected_JSONSources()
        {
            var workspaceID   = Guid.NewGuid();
            var workspacePath = EnvironmentVariables.GetWorkspacePath(workspaceID);
            var servicesPath  = Path.Combine(workspacePath, "Services");
            var sourcesPath   = Path.Combine(workspacePath, "Sources");
            var pluginsPath   = Path.Combine(workspacePath, "Plugins");

            try
            {
                Directory.CreateDirectory(servicesPath);
                Directory.CreateDirectory(sourcesPath);
                Directory.CreateDirectory(pluginsPath);

                var xml = XmlResource.Fetch("Calculate_RecordSet_Subtract");
                xml.Save(Path.Combine(servicesPath, "Calculate_RecordSet_Subtract.xml"));

                xml = XmlResource.Fetch("HostSecurityProviderServerSigned");
                xml.Save(Path.Combine(sourcesPath, "HostSecurityProviderServerSigned.xml"));

                var testResources = new Dev2.Runtime.ServiceModel.Resources();
                var actual        = testResources.Paths("", workspaceID, Guid.Empty);
                Assert.AreEqual("[\"Integration Test Services\\\\Calculate_RecordSet_Subtract\"]", actual);
            }
            finally
            {
                if (Directory.Exists(workspacePath))
                {
                    DirectoryHelper.CleanUp(workspacePath);
                }
            }
        }
Esempio n. 3
0
        public void SourcesWithInvalidArgsExpectedReturnsEmptyList()
        {
            var resources = new Dev2.Runtime.ServiceModel.Resources();
            var result    = resources.Sources("xxxx", Guid.Empty, Guid.Empty);

            Assert.AreEqual(0, result.Count);
        }
        public void Paths_Expected_JSONSources()
        {
            var workspaceID = Guid.NewGuid();
            var workspacePath = EnvironmentVariables.GetWorkspacePath(workspaceID);
            var servicesPath = Path.Combine(workspacePath, "Services");
            var sourcesPath = Path.Combine(workspacePath, "Sources");
            var pluginsPath = Path.Combine(workspacePath, "Plugins");
            try
            {
                Directory.CreateDirectory(servicesPath);
                Directory.CreateDirectory(sourcesPath);
                Directory.CreateDirectory(pluginsPath);

                var xml = XmlResource.Fetch("Calculate_RecordSet_Subtract");
                xml.Save(Path.Combine(servicesPath, "Calculate_RecordSet_Subtract.xml"));

                xml = XmlResource.Fetch("HostSecurityProviderServerSigned");
                xml.Save(Path.Combine(sourcesPath, "HostSecurityProviderServerSigned.xml"));

                var testResources = new Dev2.Runtime.ServiceModel.Resources();
                var actual = testResources.Paths("", workspaceID, Guid.Empty);
                Assert.AreEqual("[\"Integration Test Services\\\\Calculate_RecordSet_Subtract\"]", actual);
            }
            finally
            {
                if(Directory.Exists(workspacePath))
                {
                    DirectoryHelper.CleanUp(workspacePath);
                }
            }
        }
Esempio n. 5
0
        // ReSharper disable InconsistentNaming
        public void Resources_UnitTest_PluginPathsAndNames_AllServicePathsExeptWorkflows()
        // ReSharper restore InconsistentNaming
        {
            //Isolate PathsAndNames for workflows as a functional unit
            var workspaceID   = Guid.NewGuid();
            var workspacePath = EnvironmentVariables.GetWorkspacePath(workspaceID);

            try
            {
                const int Modulo             = 3;
                const int TotalResourceCount = 9;
                for (var i = 0; i < TotalResourceCount; i++)
                {
                    var resource = new Resource
                    {
                        ResourceID   = Guid.NewGuid(),
                        ResourceName = string.Format("My Name {0}", i),
                        ResourcePath = string.Format("My Path {0}\\{1}", i, string.Format("My Name {0}", i))
                    };

                    switch (i % Modulo)
                    {
                    case 0:
                        resource.ResourcePath = ResourceType.WorkflowService + "\\" + resource.ResourceName;
                        resource.ResourceType = ResourceType.WorkflowService;
                        break;

                    case 1:
                        resource.ResourcePath = ResourceType.DbService + "\\" + resource.ResourceName;
                        resource.ResourceType = ResourceType.DbService;
                        break;

                    case 2:
                        resource.ResourcePath = ResourceType.PluginService + "\\" + resource.ResourceName;
                        resource.ResourceType = ResourceType.PluginService;
                        break;
                    }
                    ResourceCatalog.Instance.SaveResource(workspaceID, resource);
                }
                var          resources    = new Dev2.Runtime.ServiceModel.Resources();
                const string ExpectedJson = "{\"Names\":[\"My Name 1\",\"My Name 4\",\"My Name 7\"],\"Paths\":[\"DbService\"]}";

                //Run PathsAndNames
                var actualJson = resources.PathsAndNames("DbService", workspaceID, Guid.Empty);

                //Assert CorrectListReturned
                Assert.AreEqual(ExpectedJson, actualJson, "Incorrect list of names and paths for workflow services");
            }
            finally
            {
                if (Directory.Exists(workspacePath))
                {
                    DirectoryHelper.CleanUp(workspacePath);
                }
            }
        }
Esempio n. 6
0
        public void DataListInputVariablesWhereInvalidArgsExpectEmptyString()
        {
            //------------Setup for test--------------------------
            var resources = new Dev2.Runtime.ServiceModel.Resources();
            //------------Execute Test---------------------------
            var result = resources.DataListInputVariables("xxxx", Guid.Empty, Guid.Empty);

            //------------Assert Results-------------------------
            Assert.AreEqual("", result);
        }
Esempio n. 7
0
        public void DataListInputWhereValidArgsDataListHasNoInputsExpectEmptyString()
        {
            //------------Setup for test--------------------------
            var workspaceID = Guid.NewGuid();

            var workspacePath = EnvironmentVariables.GetWorkspacePath(workspaceID);

            try
            {
                string completePath = Path.Combine(workspacePath, "Bugs");
                if (Directory.Exists(completePath))
                {
                    Directory.Delete(completePath);
                }
                var xml          = XmlResource.Fetch("Bug6619");
                var resourcePath = xml.Element("Category");
                Directory.CreateDirectory(completePath);
                Assert.IsNotNull(resourcePath);
                xml.Save(Path.Combine(workspacePath, resourcePath.Value + ".xml"));
                var resources = new Dev2.Runtime.ServiceModel.Resources();
                //-----------------Assert Preconditions-----------------------------
                Assert.IsNotNull(resourcePath);
                var resource = ResourceCatalog.Instance.GetResource(workspaceID, resourcePath.Value);
                Assert.IsNotNull(resource);
                //------------Execute Test---------------------------
                var dataListInputVariables = resources.DataListInputVariables(resource.ResourceID.ToString(), workspaceID, Guid.Empty);
                //------------Assert Results-------------------------
                Assert.IsTrue(string.IsNullOrEmpty(dataListInputVariables));
            }
            finally
            {
                if (Directory.Exists(workspacePath))
                {
                    DirectoryHelper.CleanUp(workspacePath);
                }
            }
        }
        public void SourcesWithValidArgsExpectedReturnsList()
        {
            var workspaceID = Guid.NewGuid();
            var workspacePath = EnvironmentVariables.GetWorkspacePath(workspaceID);
            try
            {
                const int Modulo = 2;
                const int ExpectedCount = 6;
                for(var i = 0; i < ExpectedCount; i++)
                {
                    var resource = new Resource
                    {
                        ResourceID = Guid.NewGuid(),
                        ResourceName = string.Format("My Name {0}", i),
                        ResourcePath = string.Format("My Path {0}", i),
                        ResourceType = (i % Modulo == 0) ? ResourceType.DbSource : ResourceType.Unknown
                    };
                    ResourceCatalog.Instance.SaveResource(workspaceID, resource);
                }
                var resources = new Dev2.Runtime.ServiceModel.Resources();
                var result = resources.Sources("{\"resourceType\":\"" + ResourceType.DbSource + "\"}", workspaceID, Guid.Empty);

                Assert.AreEqual(ExpectedCount / Modulo, result.Count);
            }
            finally
            {
                if(Directory.Exists(workspacePath))
                {
                    DirectoryHelper.CleanUp(workspacePath);
                }
            }
        }
 public void SourcesWithInvalidArgsExpectedReturnsEmptyList()
 {
     var resources = new Dev2.Runtime.ServiceModel.Resources();
     var result = resources.Sources("xxxx", Guid.Empty, Guid.Empty);
     Assert.AreEqual(0, result.Count);
 }
        // ReSharper disable InconsistentNaming
        public void Resources_UnitTest_PluginPathsAndNames_WorkflowServicesAreIncluded()
        // ReSharper restore InconsistentNaming
        {
            //Isolate PathsAndNames for workflows as a functional unit
            var workspaceID = Guid.NewGuid();
            var workspacePath = EnvironmentVariables.GetWorkspacePath(workspaceID);
            try
            {
                const int Modulo = 4;
                const int TotalResourceCount = 9;
                for (var i = 0; i < TotalResourceCount; i++)
                {
                    var resource = new Resource
                    {
                        ResourceID = Guid.NewGuid(),
                        ResourceName = string.Format("My Name {0}", i),
                        ResourcePath = string.Format("My Path {0}\\{1}", i, string.Format("My Name {0}", i))
                    };

                    switch (i % Modulo)
                    {
                        case 0:
                            resource.ResourcePath = ResourceType.WorkflowService + "\\" + resource.ResourceName;
                            resource.ResourceType = ResourceType.WorkflowService;
                            break;
                        case 1:
                            resource.ResourcePath = ResourceType.DbService + "\\" + resource.ResourceName;
                            resource.ResourceType = ResourceType.DbService;
                            break;
                        case 2:
                            resource.ResourcePath = ResourceType.PluginService + "\\" + resource.ResourceName;
                            resource.ResourceType = ResourceType.PluginService;
                            break;
                        case 3:
                            resource.ResourcePath = ResourceType.ServerSource + "\\" + resource.ResourceName;
                            resource.ResourceType = ResourceType.ServerSource;
                            break;
                    }
                    ResourceCatalog.Instance.SaveResource(workspaceID, resource);
                }
                var resources = new Dev2.Runtime.ServiceModel.Resources();
                const string ExpectedJson = "{\"Names\":[\"My Name 3\",\"My Name 7\"],\"Paths\":[\"ServerSource\"]}";

                //Run PathsAndNames
                var actualJson = resources.PathsAndNames("ServerSource", workspaceID,Guid.Empty);

                //Assert CorrectListReturned
                Assert.AreEqual(ExpectedJson, actualJson, "Incorrect list of names and paths for workflow services");
            }
            finally
            {
                if (Directory.Exists(workspacePath))
                {
                    DirectoryHelper.CleanUp(workspacePath);
                }
            }
        }
        public void DataListInputWhereValidArgsDataListHasNoInputsExpectEmptyString()
        {
            //------------Setup for test--------------------------
            var workspaceID = Guid.NewGuid();

            var workspacePath = EnvironmentVariables.GetWorkspacePath(workspaceID);
            try
            {
                string completePath = Path.Combine(workspacePath, "Bugs");
                if(Directory.Exists(completePath))
                {
                    Directory.Delete(completePath);
                }
                var xml = XmlResource.Fetch("Bug6619");
                var resourcePath = xml.Element("Category");
                Directory.CreateDirectory(completePath);
                Assert.IsNotNull(resourcePath);
                xml.Save(Path.Combine(workspacePath, resourcePath.Value + ".xml"));
                var resources = new Dev2.Runtime.ServiceModel.Resources();
                //-----------------Assert Preconditions-----------------------------
                Assert.IsNotNull(resourcePath);
                var resource = ResourceCatalog.Instance.GetResource(workspaceID, resourcePath.Value);
                Assert.IsNotNull(resource);
                //------------Execute Test---------------------------
                var dataListInputVariables = resources.DataListInputVariables(resource.ResourceID.ToString(), workspaceID, Guid.Empty);
                //------------Assert Results-------------------------
                Assert.IsTrue(string.IsNullOrEmpty(dataListInputVariables));
            }
            finally
            {
                if(Directory.Exists(workspacePath))
                {
                    DirectoryHelper.CleanUp(workspacePath);
                }
            }
        }
 public void DataListInputVariablesWhereInvalidArgsExpectEmptyString()
 {
     //------------Setup for test--------------------------
     var resources = new Dev2.Runtime.ServiceModel.Resources();
     //------------Execute Test---------------------------
     var result = resources.DataListInputVariables("xxxx", Guid.Empty, Guid.Empty);
     //------------Assert Results-------------------------
     Assert.AreEqual("", result);
 }