Beispiel #1
0
        private void CreateAdapterForTeamProject()
        {
            _adapter = new Tfs2012SyncAdapter(_testServerConfiguration.TeamProjectCollectionUrl, _testServerConfiguration.TeamProjectName, null, _testServerConfiguration.Configuration);
            var resultOfAdapterOpening = _adapter.Open(new[] { CommonConfiguration.RequirementId, CommonConfiguration.IssueId });

            InvalidateTestIfNotTrue(resultOfAdapterOpening, "Adapter.Open() did not succeed.");
        }
Beispiel #2
0
        public void TfsWorkItem_SetValueHTML_ShouldAttachHTMLImages()
        {
            var filename = Path.GetTempPath() + "AIT\\image.jpg";
            var dirName  = Path.GetDirectoryName(filename);

            if (dirName == null)
            {
                Assert.Fail("File does not exist.");
            }
            Directory.CreateDirectory(dirName);

            using (var streamWriter = new StreamWriter(File.Open(filename, FileMode.Create)))
            {
                streamWriter.Write("sdfdsf");
            }

            _requirement.WorkItem.Attachments.Clear();
            var html = string.Format(CultureInfo.InvariantCulture, "<html><body><span>FOO <img src=\"{0}\"/> BAR</span></body></html>", filename);

            _requirement.Fields[_testServerConfiguration.HtmlFieldReferenceName].Value = html;
            Assert.IsTrue(_requirement.IsDirty);
            Assert.AreEqual(0, _adapter.Save().Count);

            var adapter = new Tfs2012SyncAdapter(_testServerConfiguration.TeamProjectCollectionUrl, _testServerConfiguration.TeamProjectName, null, _testServerConfiguration.Configuration);

            Assert.IsTrue(adapter.Open(new[] { CommonConfiguration.RequirementId }));
            var requirement = (TfsWorkItem)adapter.WorkItems.Find(CommonConfiguration.RequirementId);

            Assert.IsTrue(requirement.Fields[_testServerConfiguration.HtmlFieldReferenceName].Value.Contains("FOO"));
            Assert.IsTrue(requirement.Fields[_testServerConfiguration.HtmlFieldReferenceName].Value.Contains("BAR"));

            Assert.AreEqual(1, requirement.WorkItem.AttachedFileCount);
        }
Beispiel #3
0
        public void TfsWorkItem_GetSetMicroDocument_ShouldAttachMicroDocumentAndLoadIt()
        {
            var filename = Path.GetTempPath() + "AIT\\System.Description.docx";
            var dirName  = Path.GetDirectoryName(filename);

            if (dirName == null)
            {
                Assert.Fail("File does not exist.");
            }
            Directory.CreateDirectory(dirName);
            var content = Guid.NewGuid();

            using (var streamWriter = new StreamWriter(File.Open(filename, FileMode.Create)))
            {
                streamWriter.Write(content);
            }

            _issue.Fields["System.Description"].MicroDocument = filename;
            Assert.IsTrue(_issue.IsDirty);
            _adapter.Save();
            Assert.IsTrue(_issue.WorkItem.AttachedFileCount > 0);

            var adapter = new Tfs2012SyncAdapter(_testServerConfiguration.TeamProjectCollectionUrl, _testServerConfiguration.TeamProjectName, null, _testServerConfiguration.Configuration);

            Assert.IsTrue(adapter.Open(new[] { CommonConfiguration.IssueId }));

            var issue = (TfsWorkItem)adapter.WorkItems.Find(CommonConfiguration.IssueId);

            Assert.IsTrue(File.Exists((string)issue.Fields["System.Description"].MicroDocument));

            var actualContent = File.ReadAllLines((string)issue.Fields["System.Description"].MicroDocument);

            Assert.AreEqual(content.ToString(), actualContent[0]);
        }
Beispiel #4
0
        /// <summary>
        /// Helper method to get work items from tfs
        /// </summary>
        /// <param name="ids"></param>
        /// <param name="serverConfiguration"></param>
        /// <returns></returns>
        private IEnumerable <IWorkItem> GetTfsWorkItems(int[] ids, ServerConfiguration serverConfiguration)
        {
            var configuration = serverConfiguration.Configuration;
            var tfsAdapter    = new Tfs2012SyncAdapter(serverConfiguration.TeamProjectCollectionUrl, serverConfiguration.TeamProjectName, null, configuration);

            tfsAdapter.Open(ids);
            return(tfsAdapter.WorkItems);
        }
Beispiel #5
0
        public void TfsWorkItem_ChangePlainTextField_ShouldBeSaved()
        {
            _requirement.Fields["Microsoft.VSTS.Common.Triage"].Value = "Triaged";
            _adapter.Save();

            _requirement.Fields["Microsoft.VSTS.Common.Triage"].Value = "Pending";
            Assert.AreEqual("Pending", _requirement.Fields["Microsoft.VSTS.Common.Triage"].Value);
            _adapter.Save();

            var adapter = new Tfs2012SyncAdapter(_testServerConfiguration.TeamProjectCollectionUrl, _testServerConfiguration.TeamProjectName, null, _testServerConfiguration.Configuration);

            Assert.IsTrue(adapter.Open(new[] { CommonConfiguration.RequirementId }));
            var requirement = (TfsWorkItem)adapter.WorkItems.Find(CommonConfiguration.RequirementId);

            Assert.AreEqual("Pending", requirement.Fields["Microsoft.VSTS.Common.Triage"].Value);
        }