public void Verify_grab_docx_name_is_not_case_sensitive()
        {
            WordTemplateFolderManager sut = CreateSutForTemplate_1_A();
            var expected = Path.Combine(GetTemplate1AFolder(), "Product Backlog Item.docx");

            Assert.That(sut.GetTemplateFor("Product BACKLOG Item"), Is.EqualTo(expected));
        }
        public void Verify_default_name_if_Work_item_type_does_not_esixts()
        {
            WordTemplateFolderManager sut = CreateSutForTemplate_1_A();
            var expected = Path.Combine(GetTemplate1AFolder(), "WorkItem.docx");

            Assert.That(sut.GetTemplateFor("This type does not exists"), Is.EqualTo(expected));
        }
Пример #3
0
        public override void Assemble(
            WordManipulator manipulator,
            Dictionary <string, object> parameters,
            ConnectionManager connectionManager,
            WordTemplateFolderManager wordTemplateFolderManager,
            string teamProjectName)
        {
            parameters = parameters.ToDictionary(k => k.Key, v => v.Value); //clone
            //If we do not have query parameters we have a single query or we can have parametrized query with iterationPath
            var            queries        = PrepareQueries(parameters);
            WorkItemManger workItemManger = new WorkItemManger(connectionManager);

            workItemManger.SetTeamProject(teamProjectName);

            foreach (var query in queries)
            {
                var workItems = workItemManger.ExecuteQuery(query).Take(Limit);

                if (String.IsNullOrEmpty(TableTemplate))
                {
                    foreach (var workItem in workItems)
                    {
                        if (!SpecificTemplates.TryGetValue(workItem.Type.Name, out var templateName))
                        {
                            templateName = wordTemplateFolderManager.GetTemplateFor(workItem.Type.Name);
                        }
                        else
                        {
                            templateName = wordTemplateFolderManager.GenerateFullFileName(templateName);
                        }

                        manipulator.InsertWorkItem(workItem, templateName, true, parameters);
                    }
                }
                else
                {
                    //We have a table template, we want to export work item as a list
                    var tableFile = wordTemplateFolderManager.GenerateFullFileName(TableTemplate);
                    var tempFile  = wordTemplateFolderManager.CopyFileInTempDirectory(tableFile);
                    using (var tableManipulator = new WordManipulator(tempFile, false))
                    {
                        tableManipulator.SubstituteTokens(parameters);
                        tableManipulator.FillTableWithCompositeWorkItems(true, workItems);
                    }
                    manipulator.AppendOtherWordFile(tempFile);
                }
            }

            base.Assemble(manipulator, parameters, connectionManager, wordTemplateFolderManager, teamProjectName);
        }