Exemplo n.º 1
0
        private void ButtonGenerateHtmlFile_Click(object sender, EventArgs e)
        {
            if (AvailableSummary)
            {
                // Modify HTML template
                CreateReportHTML();

                // Modify Dataset in chart-bar.js
                EditBarChartDatasets();

                // Modify Dataset in chart-pie.js
                EditPieChartDatasets();

                if (CurrentPanel != null)
                {
                    CurrentPanel.Hide();
                }

                ButtonPanelHTMLOpenInBrowser.Visible = true;
                ButtonPanelHTMLOpenInBrowser.BringToFront();
                PanelReportCreated.Show();
                CurrentPanel = PanelReportCreated;
                CurrentPanel.Refresh();

                PictureBoxPanelHTML.Image = Image.FromFile("..\\..\\..\\static\\report-created.png");
                PictureBoxPanelHTML.Refresh();
                CurrentPanel.Refresh();

                string path = Path.GetFullPath(Directory.GetCurrentDirectory() + "\\..\\..\\..\\template\\report.html");
                NotifyLoadFile.ShowBalloonTip(100, "HTML Report Available", "Path: " + path, ToolTipIcon.Info);
                TestPlan.ClearResults();
            }
        }
        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);
            }
        }