예제 #1
0
        /// <summary>
        /// Occurs if any test result data in <see cref="ISyncServiceModel"/> was changed.
        /// </summary>
        /// <param name="sender">Sender of the event.</param>
        /// <param name="e">Empty event data.</param>
        private void HandleTestReportDataChangedEvent(object sender, SyncServiceEventArgs e)
        {
            if (e.DocumentName != Document.Name || e.DocumentFullName != Document.FullName)
            {
                return;
            }

            ViewDispatcher.Invoke(() => CreateReportCommand.CallEventCanExecuteChanged());
            OperationActive = SyncServiceDocumentModel.TestReportRunning;
        }
예제 #2
0
        /// <summary>
        /// The method creates report for selected test suite.
        /// </summary>
        public void CreateReport()
        {
            SyncServiceTrace.D("Creating report...");
            SyncServiceDocumentModel.TestReportRunning = true;
            try
            {
                ProcessPreOperations();

                // Common part
                if (IncludeTestConfigurations && SelectedConfigurationPositionType == Contracts.Enums.Model.ConfigurationPositionType.AboveTestPlan)
                {
                    CreateConfigurationPart();
                }
                if (CreateDocumentStructure)
                {
                    switch (SelectedDocumentStructureType)
                    {
                    case DocumentStructureType.AreaPath:
                        CreateReportByAreaPath(SelectedTestSuite);
                        break;

                    case DocumentStructureType.IterationPath:
                        CreateReportByIterationPath(SelectedTestSuite);
                        break;

                    case DocumentStructureType.TestPlanHierarchy:
                        CreateReportByTestPlanHierarchy(SelectedTestSuite);
                        break;
                    }
                }
                else
                {
                    CreateReportUnstructured(SelectedTestSuite);
                }
                if (!CancellationPending())
                {
                    // Set the 'Report generated' only if the report was not canceled
                    SyncServiceDocumentModel.TestReportGenerated = true;
                    if (ViewDispatcher != null)
                    {
                        ViewDispatcher.Invoke(() => CreateReportCommand.CallEventCanExecuteChanged());
                    }
                    StoreReportData();
                }


                var config           = SyncServiceFactory.GetService <IConfigurationService>().GetConfiguration(Document);
                var testReport       = SyncServiceFactory.CreateWord2007TestReportAdapter(Document, config);
                var testReportHelper = new TestReportHelper(TestAdapter, testReport, config, CancellationPending);

                if (TestReportingProgressCancellationService.CheckIfContinue())
                {
                    testReportHelper.CreateSummaryPage(WordDocument, SelectedTestPlan);
                    ProcessPostOperations();
                }
                else
                {
                    SyncServiceTrace.I("Skipped creation of summary page and processing post operations because of error or cancellation.");
                }
            }
            catch (Exception ex)
            {
                var infoStorageService = SyncServiceFactory.GetService <IInfoStorageService>();
                if (infoStorageService == null)
                {
                    throw;
                }
                IUserInformation info = new UserInformation
                {
                    Text        = Resources.TestSpecification_Error,
                    Explanation = ex is OperationCanceledException ? ex.Message : ex.ToString(),
                    Type        = UserInformationType.Error
                };
                infoStorageService.AddItem(info);
            }
            finally
            {
                SyncServiceDocumentModel.TestReportRunning = false;
            }
        }