Esempio n. 1
0
        public string buildRequestBodyTestExecution(TestExecution testExecution)
        {
            FieldsTestExecution fields = new FieldsTestExecution
            {
                project     = testExecution.fields.project,
                priority    = testExecution.fields.priority,
                summary     = testExecution.fields.summary,
                description = testExecution.fields.description,
                labels      = testExecution.fields.labels,
                issuetype   = new FieldByName {
                    name = "Test Execution"
                },
                environment = testExecution.fields.environment,
                versions    = testExecution.fields.versions
            };
            TestExecution testExecClone = new TestExecution {
                fields = fields
            };
            var settings = new JsonSerializerSettings();

            settings.NullValueHandling    = NullValueHandling.Ignore;
            settings.DefaultValueHandling = DefaultValueHandling.Ignore;

            return(JsonConvert.SerializeObject(testExecClone, settings));
        }
Esempio n. 2
0
        public static List <FieldsTestExecution> getDataTestExecution(String pathFile, string projectKey)
        {
            var      result   = new List <FieldsTestExecution>();
            FileInfo fileInfo = new FileInfo(pathFile);

            ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
            ExcelPackage   package   = new ExcelPackage(fileInfo);
            ExcelWorksheet worksheet = package.Workbook.Worksheets.FirstOrDefault();

            // get number of rows and columns in the sheet
            int rows = worksheet.Dimension.Rows; // 20

            for (int i = 2; i <= rows; i++)
            {
                FieldsTestExecution issue = new FieldsTestExecution();
                issue.summary     = getDataCell(worksheet.Cells[i, 1]);
                issue.description = getDataCell(worksheet.Cells[i, 2]);
                issue.labels      = getDataCell(worksheet.Cells[i, 3]).Split(',');
                string             component  = getDataCell(worksheet.Cells[i, 4]);
                List <FieldByName> components = new List <FieldByName>();
                if (!string.IsNullOrEmpty(component.Trim()))
                {
                    string[] componentStrings = component.Split(',');
                    foreach (var p in componentStrings)
                    {
                        if (!string.IsNullOrEmpty(p))
                        {
                            components.Add(new FieldByName {
                                name = p
                            });
                        }
                    }
                }
                issue.components = components.Count > 0 ? components : null;
                string             version  = getDataCell(worksheet.Cells[i, 5]);
                List <FieldByName> versions = new List <FieldByName>();
                if (!string.IsNullOrEmpty(version))
                {
                    string[] versionsString = version.Split(',');
                    foreach (var p in versionsString)
                    {
                        versions.Add(new FieldByName {
                            name = p
                        });
                    }
                }
                issue.versions = versions.Count > 0 ? versions : null;
                issue.priority = new FieldByName {
                    name = getDataCell(worksheet.Cells[i, 6])
                };
                issue.environment     = getDataCell(worksheet.Cells[i, 7]);
                issue.testEnvironment = getDataCell(worksheet.Cells[i, 8]);
                issue.testPlanKey     = getDataCell(worksheet.Cells[i, 9]);
                issue.project         = new FieldByKey {
                    key = projectKey
                };
                result.Add(issue);
            }
            return(result);
        }