public void TestReportingProgressCancellationServiceTest_ContinueFalseWhenProgressNotCanceledAndNoeErrorExist()
        {
            var progressService = new Mock <IProgressService>();

            progressService.SetupGet(x => x.ProgressCanceled).Returns(false);
            SyncServiceFactory.RegisterService(progressService.Object);

            var infoStorageService = new Mock <IInfoStorageService>();

            infoStorageService.SetupGet(x => x.UserInformation).
            Returns(new InfoCollection <IUserInformation>()
            {
                new UserInformation()
                {
                    Type = UserInformationType.Warning
                }
            });

            SyncServiceFactory.RegisterService(infoStorageService.Object);
            var cancelTrueServiceInstance = new TestReportingProgressCancellationService(true);

            var shouldContinue = cancelTrueServiceInstance.CheckIfContinue();

            Assert.AreEqual(shouldContinue, true);
        }
        public void TestReportingProgressCancellationServiceTest_ContinueFalseWhenProgressCanceledTrue()
        {
            //Arrange
            var progressService = new Mock <IProgressService>();

            progressService.SetupGet(x => x.ProgressCanceled).Returns(true);
            SyncServiceFactory.RegisterService(progressService.Object);
            var infoStorageService = new Mock <IInfoStorageService>();

            SyncServiceFactory.RegisterService(infoStorageService.Object);
            var cancelTrueServiceInstance = new TestReportingProgressCancellationService(true);

            //Act
            var shouldContinue = cancelTrueServiceInstance.CheckIfContinue();

            Assert.AreEqual(shouldContinue, false);
        }
예제 #3
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;
            }
        }