Example #1
0
        public void IntegrationTest_PublishOfWorkItemWithUnclosedList_ShouldNotBePublished()
        {
            var systemVariableMock = new Mock <ISystemVariableService>();

            _ignoreFailOnUserInforation = true;

            var serverConfig = CommonConfiguration.TfsTestServerConfiguration(_testContext);

            serverConfig.Configuration.IgnoreFormatting = false;
            var requirementConf = serverConfig.Configuration.GetWorkItemConfiguration("Requirement");

            // import an workitems to use the structure as example for the new workitem
            var importItems = GetTfsWorkItems(new[] { serverConfig.HtmlRequirementId }, serverConfig).ToList();

            Refresh(serverConfig, importItems);

            //Add Bullet points to the table.
            _document.Tables[1].Cell(3, 1).Range.ListFormat.ApplyBulletDefault();
            var bulletItems = new[] { "One", "Two", "Three" };

            for (int i = 0; i < bulletItems.Length; i++)
            {
                string bulletItem = bulletItems[i];
                if (i < bulletItems.Length - 1)
                {
                    bulletItem = bulletItem + "\n";
                }
                _document.Tables[1].Cell(3, 1).Range.InsertBefore(bulletItem);
            }

            //delete the id
            _document.Tables[1].Cell(2, 3).Range.Text = string.Empty;
            _document.Tables[1].Cell(2, 1).Range.Text = "TestTitle";

            var createdWorkItem = new WordTableWorkItem(_document.Tables[1], "Requirement", serverConfig.Configuration, requirementConf);

            // publish
            var publishWorkItems = new List <IWorkItem>();

            publishWorkItems.Add(createdWorkItem);

            var configuration = serverConfig.Configuration;
            var tfsAdapter    = new Tfs2012SyncAdapter(serverConfig.TeamProjectCollectionUrl, serverConfig.TeamProjectName, null, configuration);
            var wordAdapter   = new Word2007TableSyncAdapter(_document, configuration);

            var syncService = new WorkItemSyncService(systemVariableMock.Object);

            syncService.Publish(wordAdapter, tfsAdapter, publishWorkItems, false, configuration);

            //Get the information storage
            var informationStorage = SyncServiceFactory.GetService <IInfoStorageService>();
            var error = informationStorage.UserInformation.FirstOrDefault(x => x.Type == UserInformationType.Error);

            //Test that an error was thrown
            Assert.IsNotNull(error);

            //Clear the information storage
            informationStorage.UserInformation.Clear();
        }
Example #2
0
        /// <summary>
        /// Helper method to get a work item from word
        /// </summary>
        /// <param name="ids"></param>
        /// <param name="serverConfiguration"></param>
        /// <returns></returns>
        private IEnumerable <IWorkItem> GetWordWorkItems(int[] ids, ServerConfiguration serverConfiguration)
        {
            var configuration = serverConfiguration.Configuration;
            var wordAdapter   = new Word2007TableSyncAdapter(_document, configuration);

            wordAdapter.Open(ids);
            return(wordAdapter.WorkItems);
        }
        public void WordTableWorkItem_AddLinks_ShouldReplaceLinksIfOverwriteIsFalse()
        {
            var target      = new WordTableWorkItem(_testDocument.Tables[1], "Requirement", CommonConfiguration.Configuration, CommonConfiguration.Configuration.GetWorkItemConfiguration("Requirement"));
            var fakeAdapter = new Word2007TableSyncAdapter(_testDocument, CommonConfiguration.Configuration);

            fakeAdapter.Open(null);
            target.AddLinks(fakeAdapter, new[] { 4, 5 }, "Child", false);
            Assert.IsTrue(_testDocument.Tables[1].Cell(2, 2).Range.Text.StartsWith("4,5", StringComparison.OrdinalIgnoreCase));
        }
Example #4
0
        /// <summary>
        /// Helper method to refresh information
        /// </summary>
        /// <param name="serverConfiguration"></param>
        /// <param name="workItems"></param>
        private void Refresh(ServerConfiguration serverConfiguration, IEnumerable <IWorkItem> workItems)
        {
            var systemVariableMock = new Mock <ISystemVariableService>();
            var configuration      = serverConfiguration.Configuration;
            var tfsAdapter         = new Tfs2012SyncAdapter(serverConfiguration.TeamProjectCollectionUrl, serverConfiguration.TeamProjectName, null, configuration);
            var wordAdapter        = new Word2007TableSyncAdapter(_document, configuration);

            var syncService = new WorkItemSyncService(systemVariableMock.Object);

            syncService.Refresh(tfsAdapter, wordAdapter, workItems, configuration);
            FailOnUserInformation();
        }
        public void WordTableWorkItem_AddBookmarks_DocumentAndRequirementShouldContainBookmark()
        {
            var target      = new WordTableWorkItem(_testDocument.Tables[1], "Requirement", CommonConfiguration.Configuration, CommonConfiguration.Configuration.GetWorkItemConfiguration("Requirement"));
            var fakeAdapter = new Word2007TableSyncAdapter(_testDocument, CommonConfiguration.Configuration);

            fakeAdapter.Open(null);

            Assert.IsNotNull(target);
            //Desription should contain a Bookmark
            Assert.AreEqual(_testDocument.Tables[1].Cell(3, 1).Range.Bookmarks.Count, 1);
            Assert.AreEqual(_testDocument.Tables[1].Cell(3, 1).Range.Bookmarks[1].Name, CommonConfiguration.BookmarkName);

            //Title should not contain a Bookmark
            Assert.AreNotEqual(_testDocument.Tables[1].Cell(2, 1).Range.Bookmarks.Count, 1);

            //The First Bookmark in the document should be the one from the configuration
            Assert.AreEqual(_testDocument.Bookmarks[1].Name, CommonConfiguration.BookmarkName);

            //The Value of the the Bookmarkshould be the value of the Description
            Assert.IsTrue(_testDocument.Tables[1].Cell(3, 1).Range.Text.Contains(_testDocument.Bookmarks[1].Range.Text));
        }