Exemplo n.º 1
0
        private void EditPieChartDatasets()
        {
            List <string> chartPie = new List <string>();

            try
            {
                using (StreamReader sr = new StreamReader("..\\..\\..\\template\\assets\\chart-pie.js"))
                {
                    string line;

                    while ((line = sr.ReadLine()) != null)
                    {
                        chartPie.Add(line);
                    }
                }
            }
            catch
            {
                NotifyLoadFile.ShowBalloonTip(100, "Error", "File is not available", ToolTipIcon.Error);
            }

            TestPlan.BuildResults();

            chartPie[4] = "dataFunctionalNewFeatures = [" + TestPlan.FunctionalNewFeaturesResults[1].ToString() + ", " + TestPlan.FunctionalNewFeaturesResults[0].ToString() + "];";
            chartPie[5] = "dataFunctionalEnhancements = [" + TestPlan.FunctionalEnhancementsResults[1].ToString() + ", " + TestPlan.FunctionalEnhancementsResults[0].ToString() + "];";
            chartPie[6] = "dataNonFunctionalNewFeatures = [" + TestPlan.NonFunctionalNewFeaturesResults[1].ToString() + ", " + TestPlan.NonFunctionalNewFeaturesResults[0].ToString() + "];";
            chartPie[7] = "dataNonFunctionalEnhancements = [" + TestPlan.NonFunctionalEnhancementsResults[1].ToString() + ", " + TestPlan.NonFunctionalEnhancementsResults[0].ToString() + "];";

            using (StreamWriter sw = new StreamWriter("..\\..\\..\\template\\assets\\chart-pie.js"))
            {
                foreach (string line in chartPie)
                {
                    sw.WriteLine(line);
                }
            }
        }
        public void PerformChanges(TestPlan _TestPlan)
        {
            try
            {
                Clear();

                _TestPlan.BuildDatasets();
                _TestPlan.BuildResults();

                // Test Plan General Information
                App.Worksheets["Test Plan"].Range["E1"].Value  = _TestPlan.Name;
                App.Worksheets["Test Plan"].Range["E5"].Value  = _TestPlan.Introduction;
                App.Worksheets["Test Plan"].Range["E11"].Value = _TestPlan.SetupEnvironment;
                App.Worksheets["Test Plan"].Range["E15"].Value = _TestPlan.Scope;
                App.Worksheets["Test Plan"].Range["E19"].Value = _TestPlan.Fixes;
                App.Worksheets["Test Plan"].Range["E23"].Value = _TestPlan.Regression;

                // Test Cases
                int          row = 2;
                string       range;
                _Excel.Range selectedCells;

                foreach (TestCase tc in _TestPlan.GetTestCasesReadOnly())
                {
                    App.Worksheets["Test Cases"].Range["A" + row.ToString()].Value = tc.TestArea;
                    App.Worksheets["Test Cases"].Range["B" + row.ToString()].Value = tc.Component;
                    App.Worksheets["Test Cases"].Range["C" + row.ToString()].Value = tc.Type;
                    App.Worksheets["Test Cases"].Range["D" + row.ToString()].Value = tc.ID;
                    App.Worksheets["Test Cases"].Range["E" + row.ToString()].Value = tc.TestScenario;
                    App.Worksheets["Test Cases"].Range["F" + row.ToString()].Value = tc.Description;
                    App.Worksheets["Test Cases"].Range["G" + row.ToString()].Value = tc.Tag;
                    App.Worksheets["Test Cases"].Range["H" + row.ToString()].Value = tc.PreConditions;
                    App.Worksheets["Test Cases"].Range["I" + row.ToString()].Value = tc.Steps;
                    App.Worksheets["Test Cases"].Range["J" + row.ToString()].Value = tc.ExpectedBehaviour;
                    App.Worksheets["Test Cases"].Range["K" + row.ToString()].Value = tc.Status;
                    App.Worksheets["Test Cases"].Range["L" + row.ToString()].Value = tc.Result;
                    App.Worksheets["Test Cases"].Range["M" + row.ToString()].Value = tc.Notes;

                    range         = "A" + row.ToString() + ":" + "M" + row.ToString();
                    selectedCells = App.Worksheets["Test Cases"].Range[range];
                    selectedCells.Borders.Color  = Color.LightGray;
                    selectedCells.Borders.Weight = 2;

                    ++row;
                }

                // Passed - Failed
                App.Worksheets["Charts Data"].Range["A4"].Value = _TestPlan.FunctionalNewFeaturesResults[0];
                App.Worksheets["Charts Data"].Range["B4"].Value = _TestPlan.FunctionalNewFeaturesResults[1];
                App.Worksheets["Charts Data"].Range["C4"].Value = _TestPlan.FunctionalEnhancementsResults[0];
                App.Worksheets["Charts Data"].Range["D4"].Value = _TestPlan.FunctionalEnhancementsResults[1];
                App.Worksheets["Charts Data"].Range["E4"].Value = _TestPlan.NonFunctionalNewFeaturesResults[0];
                App.Worksheets["Charts Data"].Range["F4"].Value = _TestPlan.NonFunctionalNewFeaturesResults[1];
                App.Worksheets["Charts Data"].Range["G4"].Value = _TestPlan.NonFunctionalEnhancementsResults[0];
                App.Worksheets["Charts Data"].Range["H4"].Value = _TestPlan.NonFunctionalEnhancementsResults[1];

                // General Charts | A == 65, Q == 81.
                string[] functionalNF    = _TestPlan.FunctionalNewFeatures.Split(',');
                string[] functionalEN    = _TestPlan.FunctionalEnhancements.Split(',');
                string[] nonFunctionalNF = _TestPlan.NonFunctionalNewFeatures.Split(',');
                string[] nonFunctionalEN = _TestPlan.NonFunctionalEnhancements.Split(',');


                for (int i = 65; i < 82; ++i)
                {
                    App.Worksheets["Charts Data"].Range[(char)i + "8"].Value  = functionalNF[i - 65];
                    App.Worksheets["Charts Data"].Range[(char)i + "12"].Value = functionalEN[i - 65];
                    App.Worksheets["Charts Data"].Range[(char)i + "16"].Value = nonFunctionalNF[i - 65];
                    App.Worksheets["Charts Data"].Range[(char)i + "20"].Value = nonFunctionalEN[i - 65];
                }

                App.ActiveWorkbook.Sheets[1].Select();
                Workbook.Close(true);
                _TestPlan.ClearResults();
                App.Quit();
            }
            catch
            {
                App.Quit();
                MainFormNotifyIcon.ShowBalloonTip(100, "Error", "An error occurred trying to save changes", ToolTipIcon.Error);
            }
        }