Beispiel #1
0
        /// <summary>
        /// Execute import work items from TFS to Word process.
        /// </summary>
        public void Import()
        {
            SyncServiceTrace.I(Resources.ImportWorkItems);
            SyncServiceFactory.GetService <IInfoStorageService>().ClearAll();

            // check whether cursor is not inside the table
            if (WordSyncHelper.IsCursorInTable(WordDocument.ActiveWindow.Selection))
            {
                SyncServiceTrace.W(Resources.WordToTFS_Error_TableInsertInTable);
                MessageBox.Show(Resources.WordToTFS_Error_TableInsertInTable, Resources.MessageBox_Title, MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            // disable all other functionality
            if (WordRibbon != null)
            {
                WordRibbon.ResetBeforeOperation(DocumentModel);
                WordRibbon.DisableAllControls(DocumentModel);
            }

            // display progress dialog
            var progressService = SyncServiceFactory.GetService <IProgressService>();

            progressService.ShowProgress();
            progressService.NewProgress(Resources.GetWorkItems_Title);
            IsImporting = true;

            // start background thread to execute the import
            var backgroundWorker = new BackgroundWorker();

            backgroundWorker.DoWork             += DoImport;
            backgroundWorker.RunWorkerCompleted += ImportFinished;
            backgroundWorker.RunWorkerAsync(backgroundWorker);
        }
        /// <summary>
        /// Background method to find the work items from TFS.
        /// </summary>
        private void DoFind(object sender, DoWorkEventArgs e)
        {
            SyncServiceTrace.D(Resources.FindWorkItems);

            var progressService = SyncServiceFactory.GetService <IProgressService>();

            progressService.ShowProgress();
            progressService.NewProgress(Resources.GetWorkItems_Title);

            var queryConfiguration = new QueryConfiguration();

            foreach (var workItem in _workItems)
            {
                queryConfiguration.ByIDs.Add(workItem);
            }

            queryConfiguration.ImportOption = QueryImportOption.IDs;

            _source.Open(queryConfiguration.ByIDs.ToArray());

            EnsureTfsLazyLoadingFinished(_source);

            _cancellationTokenSource.Cancel();
            _cancellationTokenSource = new CancellationTokenSource();
            var token = _cancellationTokenSource.Token;

            FoundWorkItems = (from wi in _source.WorkItems
                              select new DataItemModel <SynchronizedWorkItemViewModel>(new SynchronizedWorkItemViewModel(wi, null, _destination, _documentModel, token))
            {
                IsChecked = true
            }).ToList();
        }
Beispiel #3
0
        /// <summary>
        /// Background method to import the work items from TFS.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">A <see cref="DoWorkEventArgs"/> that contains the event data.</param>
        private void DoImport(object sender, DoWorkEventArgs e)
        {
            SyncServiceTrace.I(Resources.ImportWorkItems);
            var workItemSyncService = SyncServiceFactory.GetService <IWorkItemSyncService>();
            var configService       = SyncServiceFactory.GetService <IConfigurationService>();

            // save query configuration to document
            DocumentModel.SaveQueryConfiguration(_queryConfiguration);
            DocumentModel.Save();

            // set actual selected configuration
            var configuration = configService.GetConfiguration(WordDocument);

            var ignoreFormatting  = configuration.IgnoreFormatting;
            var conflictOverwrite = configuration.ConflictOverwrite;

            configuration.ActivateMapping(DocumentModel.MappingShowName);
            DocumentModel.Configuration.IgnoreFormatting = ignoreFormatting;
            configuration.ConflictOverwrite = conflictOverwrite;
            configuration.IgnoreFormatting  = ignoreFormatting;

            var config = SyncServiceFactory.GetService <IConfigurationService>().GetConfiguration(WordDocument);
            var source = SyncServiceFactory.CreateTfs2008WorkItemSyncAdapter(DocumentModel.TfsServer, DocumentModel.TfsProject, null, config);

            _importWordAdapter = SyncServiceFactory.CreateWord2007TableWorkItemSyncAdapter(WordDocument, configuration);

            _importWordAdapter.PrepareDocumentForLongTermOperation();
            //////////
            _importWordAdapter.ProcessOperations(configuration.PreOperations);
            var importWorkItems = (from wim in FoundWorkItems
                                   where wim.IsChecked
                                   select wim.Item).ToList();

            // search for already existing work items in word and ask whether to overide them
            if (!(source.Open(importWorkItems.Select(x => x.TfsItem.Id).ToArray()) && _importWordAdapter.Open(null)))
            {
                return;
            }

            if (importWorkItems.Select(x => x.TfsItem.Id).Intersect(_importWordAdapter.WorkItems.Select(x => x.Id)).Any())
            {
                SyncServiceTrace.W(Resources.TFSExport_ExistingWorkItems);
                if (
                    System.Windows.Forms.MessageBox.Show((IWin32Window)WordRibbon,
                                                         Resources.TFSExport_ExistingWorkItems,
                                                         Resources.MessageBox_Title,
                                                         MessageBoxButtons.YesNo,
                                                         MessageBoxIcon.Question,
                                                         MessageBoxDefaultButton.Button2, 0) == DialogResult.No)
                {
                    return;
                }
            }

            workItemSyncService.Refresh(source, _importWordAdapter, importWorkItems.Select(x => x.TfsItem), configuration);
            _importWordAdapter.ProcessOperations(configuration.PostOperations);
        }
        /// <summary>
        /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
        /// </summary>
        public void Dispose()
        {
            var service = SyncServiceFactory.GetService <IProgressService>();

            if (service != null)
            {
                service.DetachModel();
            }
        }
Beispiel #5
0
        /// <summary>
        /// Method to check if cancellation has been triggered by user or an error already has occured.
        /// Returns <c>true</c> if user has not cancelled and no error has occured yet, otherwise <c>false</c>.
        /// </summary>
        /// <returns></returns>
        public bool CheckIfContinue()
        {
            var infoService     = SyncServiceFactory.GetService <IInfoStorageService>();
            var progressService = SyncServiceFactory.GetService <IProgressService>();

            var check = (_useProgressService && progressService.ProgressCanceled) || infoService.UserInformation.Any(x => x.Type == UserInformationType.Error);

            return(!check);
        }
        /// <summary>
        /// Occurs when the background operation has completed, has been canceled, or has raised an exception.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">A <see cref="RunWorkerCompletedEventArgs"/> that contains the event data.</param>
        private void ImportFinished(object sender, RunWorkerCompletedEventArgs e)
        {
            e.Error.NotifyIfException("Failed to import work items.");

            IsImporting = false;
            var progressService = SyncServiceFactory.GetService <IProgressService>();

            progressService.HideProgress();

            SyncServiceTrace.I(Resources.WorkItemsAreImported);
        }
Beispiel #7
0
        /// <summary>
        /// Execute method for 'Create Report'.
        /// </summary>
        /// <param name="parameter">Parameter for command.</param>
        private void ExecuteCreateReportCommand(object parameter)
        {
            var infoStorage = SyncServiceFactory.GetService <IInfoStorageService>();

            if (infoStorage != null)
            {
                infoStorage.ClearAll();
            }

            StartBackgroundWorker(true, CreateReport);
        }
        /// <summary>
        /// Get the necessary services
        /// </summary>
        private void GetService()
        {
            _workItemSyncService = SyncServiceFactory.GetService <IWorkItemSyncService>();
            _configService       = SyncServiceFactory.GetService <IConfigurationService>();
            _configuration       = _configService.GetConfiguration(_wordDocument);


            _tfsService  = SyncServiceFactory.CreateTfsService(_documentModel.TfsServer, _documentModel.TfsProject, _documentModel.Configuration);
            _source      = SyncServiceFactory.CreateTfs2008WorkItemSyncAdapter(_documentModel.TfsServer, _documentModel.TfsProject, null, _configuration);
            _destination = SyncServiceFactory.CreateWord2007TableWorkItemSyncAdapter(_wordDocument, _configuration);
        }
Beispiel #9
0
        /// <summary>
        /// Process an Operation
        /// </summary>
        private void ProcessPostOperations()
        {
            //Process Pre Operations
            // Get the necessary objects.
            var config = SyncServiceFactory.GetService <IConfigurationService>().GetConfiguration(Document);
            // Create Report helper
            var operation        = config.ConfigurationTest.GetPostOperationsForTestSpecification();
            var testReportHelper = new TestReportHelper(TestAdapter, testReportOperation, config, CancellationPending);

            testReportHelper.ProcessOperations(operation);
            testReportOperation.UndoPreparationsDocumentForLongTermOperation();
        }
Beispiel #10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ProgressWindow"/> class.
        /// </summary>
        /// <remarks>
        /// Call this method in GUI thread.
        /// </remarks>
        public ProgressWindow()
        {
            InitializeComponent();
            var service = SyncServiceFactory.GetService <IProgressService>();

            if (service != null)
            {
                service.AttachModel(_model);
            }
            DataContext = _model;
            KeyDown    += ProgressWindow_KeyDown;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="PublishingStateControl"/> class.
        /// </summary>
        /// <param name="document">The document this panel is attached to.</param>
        public PublishingStateControl(Document document)
        {
            InitializeComponent();

            AttachedDocument = document;
            var syncService = SyncServiceFactory.GetService <ISyncServiceModel>();

            DocumentModel = syncService.GetModel(document);

            _storageService = SyncServiceFactory.GetService <IInfoStorageService>();
            _storageService.ClearAll();
            DataContext = this;
        }
Beispiel #12
0
        /// <summary>
        /// Logs an exception to file and creates an entry in the info storage service.
        /// If the exception is null, nothing is logged.
        /// </summary>
        /// <param name="exception">Exception that occurred or null.</param>
        /// <param name="title">Title of the user information entry.</param>
        public static void NotifyIfException(this Exception exception, string title)
        {
            if (exception != null)
            {
                SyncServiceTrace.LogException(exception);

                var infoStorage = SyncServiceFactory.GetService <IInfoStorageService>();
                if (infoStorage != null)
                {
                    infoStorage.NotifyError(title, exception);
                }
            }
        }
Beispiel #13
0
        /// <summary>
        /// Execute find work items process to fill up the Find list box.
        /// </summary>
        public void FindWorkItems()
        {
            SaveQueryConfiguration();
            SyncServiceTrace.I(Resources.FindWorkItems);

            // check whether is at least one link type selected
            if (QueryConfiguration.UseLinkedWorkItems && IsCustomLinkType && QueryConfiguration.LinkTypes.Count == 0)
            {
                MessageBox.Show(Resources.WordToTFS_Error_LinkTypesNotSelected, Resources.MessageBox_Title, MessageBoxButton.OK, MessageBoxImage.Exclamation);
                return;
            }

            // parse IDs
            if (ImportOption == QueryImportOption.IDs && !ParseIDs(QueryConfiguration.ByIDs))
            {
                return;
            }

            if (ImportOption == QueryImportOption.TitleContains)
            {
                QueryConfiguration.ByTitle = ImportTitleContains;
            }

            // disable all other functionality
            if (WordRibbon != null)
            {
                WordRibbon.ResetBeforeOperation(DocumentModel);
                WordRibbon.DisableAllControls(DocumentModel);
            }

            // display progress dialog
            var progressService = SyncServiceFactory.GetService <IProgressService>();

            progressService.ShowProgress();
            progressService.NewProgress(Resources.GetWorkItems_Title);
            IsFinding = true;

            TaskScheduler scheduler = null;

            try
            {
                scheduler = TaskScheduler.FromCurrentSynchronizationContext();
            }
            catch (InvalidOperationException)
            {
                scheduler = TaskScheduler.Current;
            }

            Task.Factory.StartNew(DoFind).ContinueWith(FindFinished, scheduler);
        }
Beispiel #14
0
        /// <summary>
        /// Occurs when the background operation has completed, has been canceled, or has raised an exception.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">A <see cref="RunWorkerCompletedEventArgs"/> that contains the event data.</param>
        private void ImportFinished(object sender, RunWorkerCompletedEventArgs e)
        {
            e.Error.NotifyIfException("Failed to import work items.");

            IsImporting = false;
            _importWordAdapter.UndoPreparationsDocumentForLongTermOperation();
            var progressService = SyncServiceFactory.GetService <IProgressService>();

            progressService.HideProgress();

            // enable all other functionality
            WordRibbon?.EnableAllControls(DocumentModel);
            SyncServiceTrace.I(Resources.ImportFinished);
        }
Beispiel #15
0
        /// <summary>
        /// Occurs when the background operation has completed, has been canceled, or has raised an exception.
        /// </summary>
        private void FindFinished(Task task)
        {
            IsFinding = false;
            var progressService = SyncServiceFactory.GetService <IProgressService>();

            progressService.HideProgress();

            // enable all other functionality
            if (WordRibbon != null)
            {
                WordRibbon.EnableAllControls(DocumentModel);
            }

            SyncServiceTrace.I(Resources.FindFinished);
        }
        /// <summary>
        /// Call this method to bind the active document to the TFS project.
        /// </summary>
        public void BindProject()
        {
            if (TfsDocumentBound)
            {
                return;
            }

            var tfs = SyncServiceFactory.GetService <ITeamFoundationServerMaintenance>();

            if (tfs == null)
            {
                return;
            }

            var serverUrl   = string.Empty;
            var projectName = string.Empty;

            if (!string.IsNullOrEmpty(Configuration.DefaultProjectName) && !string.IsNullOrEmpty(Configuration.DefaultServerUrl))
            {
                if (!tfs.ValidateConnectionSettings(Configuration.DefaultServerUrl, Configuration.DefaultProjectName, out serverUrl, out projectName))
                {
                    //Publish error if connection fails
                    PublishConnectionError(Resources.Error_Wrong_Connection_Short, Resources.Error_Wrong_Connection_Long);
                    return;
                }
            }
            else
            {
                try
                {
                    if (!tfs.SelectOneTfsProject(out serverUrl, out projectName))
                    {
                        return;
                    }
                }
                catch (Exception e)
                {
                    PublishConnectionError(Resources.Error_TeamPickerFailed_Short, Resources.Error_TeamPickerFailed_Long);
                    SyncServiceTrace.W(Resources.Error_TeamPickerFailed_Long);
                    SyncServiceTrace.W(e.Message);
                    return;
                }
            }

            SetDocumentVariableValue(ConstTfsBound, ConstTfsBound, null);
            SetDocumentVariableValue(ConstTfsServer, serverUrl, null);
            SetDocumentVariableValue(ConstTfsProject, projectName, null);
        }
        /// <summary>
        /// Open browser and navigate to a page that allows to edit the destination work item of publish information.
        /// </summary>
        private void ExecuteBrowseHome(object sender, ExecutedRoutedEventArgs e)
        {
            var pubinfo = e.Parameter as IUserInformation;

            if ((pubinfo == null) || (pubinfo.Destination == null))
            {
                return;
            }

            // Get link to team foundation server web access and insert work item id into url.
            var config = SyncServiceFactory.GetService <IConfigurationService>().GetConfiguration(AttachedDocument);
            var source = SyncServiceFactory.CreateTfs2008WorkItemSyncAdapter(DocumentModel.TfsServer, DocumentModel.TfsProject, null, config);
            var url    = source.GetWorkItemEditorUrl(pubinfo.Destination.Id);

            System.Diagnostics.Process.Start(url.ToString());
        }
        /// <summary>
        /// Execute find work items process to fill up the Find list box.
        /// </summary>
        public void FindWorkItems()
        {
            SaveQueryConfiguration();
            SyncServiceTrace.I(Resources.FindWorkItems);

            if (SelectedQuery == null)
            {
                QueryConfiguration.ImportOption = QueryImportOption.IDs;

                var wordAdapter = SyncServiceFactory.CreateWord2007TableWorkItemSyncAdapter(DocumentModel.WordDocument, DocumentModel.Configuration);
                wordAdapter.Open(null);

                QueryConfiguration.ByIDs.Clear();

                foreach (var workItem in wordAdapter.WorkItems)
                {
                    if (!workItem.IsNew)
                    {
                        QueryConfiguration.ByIDs.Add(workItem.Id);
                    }
                }
            }

            // check whether is at least one link type selected
            if (QueryConfiguration.UseLinkedWorkItems && IsCustomLinkType && QueryConfiguration.LinkTypes.Count == 0)
            {
                MessageBox.Show(Resources.WordToTFS_Error_LinkTypesNotSelected, Resources.MessageBox_Title, MessageBoxButton.OK, MessageBoxImage.Exclamation);
                return;
            }

            // disable all other functionality
            if (WordRibbon != null)
            {
                WordRibbon.ResetBeforeOperation(DocumentModel);
                WordRibbon.DisableAllControls(DocumentModel);
            }

            // display progress dialog
            var progressService = SyncServiceFactory.GetService <IProgressService>();

            progressService.ShowProgress();
            progressService.NewProgress(Resources.QueryWorkItems_Title);
            IsFinding = true;

            Task.Factory.StartNew(DoFind).ContinueWith(FindFinished, TaskScheduler.FromCurrentSynchronizationContext());
        }
        /// <summary>
        /// Publish the information that the connection settings are wrong
        /// </summary>
        /// <param name="text"></param>
        /// <param name="explanation"></param>
        private static void PublishConnectionError(string text, string explanation)
        {
            var info = new UserInformation
            {
                Text        = text,
                Explanation = string.Format(explanation),
                Type        = UserInformationType.Error,
            };

            SyncServiceTrace.W("{0}:{1}", info.Text, info.Explanation);

            var infoStorage = SyncServiceFactory.GetService <IInfoStorageService>();

            if (infoStorage != null)
            {
                infoStorage.AddItem(info);
            }
        }
Beispiel #20
0
        /// <summary>
        /// Create a new Instance of the ErrorModel
        /// </summary>
        /// <param name="title">Title to be shown on the pane</param>
        /// <param name="dispatcher">The dispatcher of the user interface thread.</param>
        public ErrorModel(string title, Dispatcher dispatcher)
        {
            Title       = title;
            _dispatcher = dispatcher;
            Errors      = new ObservableCollection <IUserInformation>();

            var storageService = SyncServiceFactory.GetService <IInfoStorageService>();

            // TODO unregister from infostorage when window is hidden
            storageService.UserInformation.CollectionChanged += PublishingInformationOnCollectionChanged;

            _dispatcher.Invoke((Action)(() =>
            {
                foreach (var item in storageService.UserInformation)
                {
                    Errors.Add(item);
                }
            }));
        }
        /// <summary>
        /// Verifies this instance.
        /// </summary>
        public IList <IConfigurationFieldItem> GetWronglyMappedFields()
        {
            var serverUrl   = GetDocumentVariableValue(ConstTfsServer, null);
            var projectName = GetDocumentVariableValue(ConstTfsProject, null);

            if (string.IsNullOrEmpty(serverUrl) || string.IsNullOrEmpty(projectName))
            {
                return(new List <IConfigurationFieldItem>());
            }

            // verify template
            var veryfier      = new TemplateVerifier();
            var configuration = SyncServiceFactory.GetService <IConfigurationService>().GetConfiguration(WordDocument);
            var adapter       = SyncServiceFactory.CreateTfs2008WorkItemSyncAdapter(serverUrl, projectName, null, configuration);

            if (!veryfier.VerifyTemplateMapping(this, (ITfsService)adapter, configuration))
            {
                return(veryfier.WrongMappedFields);
            }
            return(new List <IConfigurationFieldItem>());
        }
Beispiel #22
0
        /// <summary>
        /// The method writes out the configuration information.
        /// </summary>
        private void CreateConfigurationPart()
        {
            // Get the necessary objects.
            var config     = SyncServiceFactory.GetService <IConfigurationService>().GetConfiguration(Document);
            var testReport = SyncServiceFactory.CreateWord2007TestReportAdapter(Document, config);

            // Create report helper
            var testReportHelper = new TestReportHelper(TestAdapter, testReport, config, CancellationPending);

            // Insert header of test configurations
            var templateName = config.ConfigurationTest.ConfigurationTestSpecification.TestConfigurationElementTemplate;

            testReportHelper.InsertHeaderTemplate(config.ConfigurationTest.GetHeaderTemplate(templateName));

            // Determine configurations
            var configList = new List <ITfsTestConfiguration>();

            //if (SelectedTestConfiguration.Id == AllTestConfigurations.AllTestConfigurationsId)
            //{
            foreach (var testConfiguration in TestConfigurations)
            {
                if (testConfiguration.Id == AllTestConfigurations.AllTestConfigurationsId)
                {
                    continue;
                }
                configList.Add(testConfiguration);
            }
            //}
            //else
            //    configList.Add(SelectedTestConfiguration);
            // Iterate through configurations
            foreach (var testConfiguration in configList)
            {
                testReportHelper.InsertTestConfiguration(templateName, TestAdapter.GetTestConfigurationDetail(testConfiguration));
            }
        }
Beispiel #23
0
        public static void Main(string[] args)
        {
            var commands = GetCommands();
            var code     = ConsoleCommandDispatcher.DispatchCommand(commands, args, Console.Out);

            var infoService = SyncServiceFactory.GetService <IInfoStorageService>(); //internally initialized by Adapter

            if (infoService != null && infoService.UserInformation.Count > 0)
            {
                foreach (var info in infoService.UserInformation)
                {
                    switch (info.Type)
                    {
                    case UserInformationType.Success:
                        Console.ForegroundColor = ConsoleColor.Green;
                        break;

                    case UserInformationType.Warning:
                    case UserInformationType.Unmodified:
                        Console.ForegroundColor = ConsoleColor.Yellow;
                        code = -2;
                        break;

                    case UserInformationType.Error:
                    case UserInformationType.Conflicting:
                    default:
                        Console.ForegroundColor = ConsoleColor.Red;
                        code = -2;
                        break;
                    }
                    Console.WriteLine(info.ToString());
                    Console.ResetColor();
                }
            }
            HandleReturnCode(code);
        }
Beispiel #24
0
        /// <summary>
        /// The method creates report structured by iteration path.
        /// </summary>
        /// <param name="testSuite"><see cref="ITfsTestSuite"/> is the source of test cases to write out.</param>
        private void CreateReportByIterationPath(ITfsTestSuite testSuite)
        {
            SyncServiceTrace.D("Creating report by iteration path...");
            if (testSuite == null)
            {
                SyncServiceTrace.D("Test suite is null");
                return;
            }
            // Get the necessary objects.
            var config     = SyncServiceFactory.GetService <IConfigurationService>().GetConfiguration(Document);
            var testReport = SyncServiceFactory.CreateWord2007TestReportAdapter(Document, config);
            // Get the detailed test plan.
            var testPlanDetail = TestAdapter.GetTestPlanDetail(testSuite);

            if (testPlanDetail == null)
            {
                return;
            }
            // Get the detailed test suite.
            var testSuiteDetail = TestAdapter.GetTestSuiteDetail(testSuite);

            if (testSuiteDetail == null)
            {
                return;
            }

            // Create report helper
            var testReportHelper = new TestReportHelper(TestAdapter, testReport, config, CancellationPending);
            // Insert test plan template
            var templateName = config.ConfigurationTest.ConfigurationTestSpecification.TestPlanTemplate;

            testReportHelper.InsertTestPlanTemplate(templateName, testPlanDetail);
            // Insert test suite template
            templateName = config.ConfigurationTest.ConfigurationTestSpecification.RootTestSuiteTemplate;
            testReportHelper.InsertTestSuiteTemplate(templateName, testSuiteDetail);

            // TODO MIS THIS IS THE ONLY PLACE WHERE GetAllTestCases can be called in context of the configuration template... Check late if it is enough only extend GetAllTestCases for at this single place here with the additional parameter
            // Get test cases of the test suite - with test cases in sub test suites
            var expandSharedSteps = config.ConfigurationTest.ExpandSharedSteps;
            var testCases         = TestAdapter.GetAllTestCases(testSuiteDetail.TestSuite, expandSharedSteps);

            SyncServiceTrace.D("Number of test cases:" + testCases.Count);
            // Create test case helper
            var helper = new TestCaseHelper(testCases, SelectedDocumentStructureType);
            // Get all path elements from all test cases
            var pathElements = helper.GetPathElements(SkipLevels);

            // Iterate through path elements
            foreach (var pathElement in pathElements)
            {
                // Insert heading
                testReportHelper.InsertHeadingText(pathElement.PathPart, pathElement.Level - SkipLevels);
                // Get sorted test cases
                var sortedTestCases = helper.GetTestCases(pathElement, SelectedTestCaseSortType);
                if (sortedTestCases != null && sortedTestCases.Count > 0)
                {
                    // Write out the common part of test case block
                    templateName = config.ConfigurationTest.ConfigurationTestSpecification.TestCaseElementTemplate;
                    testReportHelper.InsertHeaderTemplate(config.ConfigurationTest.GetHeaderTemplate(templateName));
                    // Iterate all test cases
                    foreach (var testCase in sortedTestCases)
                    {
                        if (CancellationPending())
                        {
                            return;
                        }
                        // Write out the test case part
                        testReportHelper.InsertTestCase(templateName, testCase);
                    }
                }
            }
            // Remove the inserted bookmarks
            testReport.RemoveBookmarks();

            // Common part
            if (IncludeTestConfigurations && SelectedConfigurationPositionType == Contracts.Enums.Model.ConfigurationPositionType.BeneathTestPlan)
            {
                CreateConfigurationPart();
            }
        }
Beispiel #25
0
        /// <summary>
        /// The method creates unstructured report - writes out all test cases in one block.
        /// </summary>
        /// <param name="testSuite"><see cref="ITfsTestSuite"/> is the source of test cases to write out.</param>
        private void CreateReportUnstructured(ITfsTestSuite testSuite)
        {
            if (testSuite == null)
            {
                return;
            }
            // Get the necessary objects.
            var config     = SyncServiceFactory.GetService <IConfigurationService>().GetConfiguration(Document);
            var testReport = SyncServiceFactory.CreateWord2007TestReportAdapter(Document, config);
            // Get the detailed test plan.
            var testPlanDetail = TestAdapter.GetTestPlanDetail(testSuite);

            if (testPlanDetail == null)
            {
                return;
            }
            // Get the detailed test suite.
            var testSuiteDetail = TestAdapter.GetTestSuiteDetail(testSuite);

            if (testSuiteDetail == null)
            {
                return;
            }

            // Create report helper
            var testReportHelper = new TestReportHelper(TestAdapter, testReport, config, CancellationPending);
            // Insert test plan template
            var templateName = config.ConfigurationTest.ConfigurationTestSpecification.TestPlanTemplate;

            testReportHelper.InsertTestPlanTemplate(templateName, testPlanDetail);

            // Common part
            if (IncludeTestConfigurations && SelectedConfigurationPositionType == Contracts.Enums.Model.ConfigurationPositionType.BeneathTestPlan)
            {
                CreateConfigurationPart();
            }

            // Insert test suite template
            templateName = config.ConfigurationTest.ConfigurationTestSpecification.RootTestSuiteTemplate;
            var expandSharedSteps = config.ConfigurationTest.ExpandSharedSteps;

            testReportHelper.InsertTestSuiteTemplate(templateName, testSuiteDetail);

            // Get test cases of the test suite - with test cases in sub test suites
            var testCases = TestAdapter.GetAllTestCases(testSuiteDetail.TestSuite, expandSharedSteps);

            // TestCasesHelper need document structure, but the enumerations has not value 'None'
            // We will use the functionality without this structure capability
            var helper = new TestCaseHelper(testCases, SelectedDocumentStructureType);
            // Get sorted test cases
            var sortedTestCases = helper.GetTestCases(SelectedTestCaseSortType);

            // Test if test cases exists
            if (sortedTestCases != null && sortedTestCases.Count > 0)
            {
                // Write out the common part of test case block
                templateName = config.ConfigurationTest.ConfigurationTestSpecification.TestCaseElementTemplate;
                testReportHelper.InsertHeaderTemplate(config.ConfigurationTest.GetHeaderTemplate(templateName));
                // Iterate all test cases
                foreach (var testCase in sortedTestCases)
                {
                    if (CancellationPending())
                    {
                        return;
                    }
                    // Write out the test case part
                    testReportHelper.InsertTestCase(templateName, testCase);
                }
            }
        }