示例#1
0
        static List <IServiceTestModelTO> RunListOfTests(IDSFDataObject dataObject, IPrincipal userPrinciple, Guid workspaceGuid, Dev2JsonSerializer serializer, IResourceCatalog catalog, ITestCatalog testCatalog)
        {
            var testResults = new List <IServiceTestModelTO>();
            var taskList    = new List <Task>();

            foreach (var testsResourceId in dataObject.TestsResourceIds)
            {
                var allTests = testCatalog.Fetch(testsResourceId);
                foreach (var test in allTests)
                {
                    var dataObjectClone = dataObject.Clone();
                    dataObjectClone.Environment = new ExecutionEnvironment();
                    dataObjectClone.TestName    = test.TestName;
                    var res = catalog.GetResource(GlobalConstants.ServerWorkspaceID, testsResourceId);
                    dataObjectClone.ServiceName = res.ResourceName;
                    dataObjectClone.ResourceID  = res.ResourceID;
                    var resourcePath = res.GetResourcePath(GlobalConstants.ServerWorkspaceID).Replace("\\", "/");
                    var lastTask     = ServiceTestExecutor.GetTaskForTestExecution(resourcePath, userPrinciple, workspaceGuid,
                                                                                   serializer, testResults, dataObjectClone);
                    taskList.Add(lastTask);
                }
            }
            Task.WaitAll(taskList.ToArray());
            return(testResults);
        }
示例#2
0
        public static DataListFormat RunMultipleTestBatches(this IDSFDataObject dataObject, IPrincipal userPrinciple, Guid workspaceGuid,
                                                            Dev2JsonSerializer serializer, DataListFormat formatter,
                                                            IResourceCatalog catalog, ITestCatalog testCatalog,
                                                            ref string executePayload)
        {
            foreach (var testsResourceId in dataObject.TestsResourceIds)
            {
                var allTests    = testCatalog.Fetch(testsResourceId);
                var taskList    = new List <Task>();
                var testResults = new List <IServiceTestModelTO>();
                foreach (var test in allTests)
                {
                    dataObject.ResourceID = testsResourceId;
                    var dataObjectClone = dataObject.Clone();
                    dataObjectClone.Environment = new ExecutionEnvironment();
                    dataObjectClone.TestName    = test.TestName;
                    var res          = catalog.GetResource(GlobalConstants.ServerWorkspaceID, testsResourceId);
                    var resourcePath = res.GetResourcePath(GlobalConstants.ServerWorkspaceID).Replace("\\", "/");

                    var lastTask = ServiceTestExecutor.GetTaskForTestExecution(resourcePath, userPrinciple, workspaceGuid,
                                                                               serializer, testResults, dataObjectClone);
                    taskList.Add(lastTask);
                }
                Task.WaitAll(taskList.ToArray());

                formatter = DataListFormat.CreateFormat("JSON", EmitionTypes.JSON, "application/json");
                var objArray = (from testRunResult in testResults
                                where testRunResult != null
                                select testRunResult.BuildTestResultForWebRequest()
                                ).ToList();

                executePayload = executePayload + Environment.NewLine + serializer.Serialize(objArray);
            }
            return(formatter);
        }
示例#3
0
        static List <IServiceTestModelTO> RunAllTestsForWorkflow(IDSFDataObject dataObject, string serviceName, IPrincipal userPrinciple, Guid workspaceGuid, Dev2JsonSerializer serializer, ITestCatalog testCatalog)
        {
            var allTests    = testCatalog.Fetch(dataObject.ResourceID) ?? new List <IServiceTestModelTO>();
            var taskList    = new List <Task>();
            var testResults = new List <IServiceTestModelTO>();

            foreach (var test in allTests.Where(to => to.Enabled))
            {
                dataObject.ResourceID = test.ResourceId;
                var dataObjectClone = dataObject.Clone();
                dataObjectClone.Environment = new ExecutionEnvironment();
                dataObjectClone.TestName    = test.TestName;
                dataObjectClone.ServiceName = serviceName;
                var lastTask = ServiceTestExecutor.GetTaskForTestExecution(serviceName, userPrinciple, workspaceGuid,
                                                                           serializer, testResults, dataObjectClone);
                taskList.Add(lastTask);
            }
            Task.WaitAll(taskList.ToArray());
            return(testResults);
        }
示例#4
0
        // ReSharper disable once RedundantAssignment
        public static IEnumerable <JObject> RunSingleTestBatch(this IDSFDataObject dataObject, string serviceName, IPrincipal userPrinciple, Guid workspaceGuid, Dev2JsonSerializer serializer, ITestCatalog catalog, ref DataListFormat formatter)
        {
            var allTests    = catalog.Fetch(dataObject.ResourceID) ?? new List <IServiceTestModelTO>();
            var taskList    = new List <Task>();
            var testResults = new List <IServiceTestModelTO>();

            foreach (var test in allTests.Where(to => to.Enabled))
            {
                var dataObjectClone = dataObject.Clone();
                dataObjectClone.Environment = new ExecutionEnvironment();
                dataObjectClone.TestName    = test.TestName;
                var lastTask = ServiceTestExecutor.GetTaskForTestExecution(serviceName, userPrinciple, workspaceGuid, serializer,
                                                                           testResults, dataObjectClone);
                taskList.Add(lastTask);
            }
            Task.WaitAll(taskList.ToArray());

            formatter = DataListFormat.CreateFormat("JSON", EmitionTypes.JSON, "application/json");
            return((from testRunResult in testResults
                    where testRunResult != null
                    select testRunResult.BuildTestResultForWebRequest()
                    ).ToList());
        }