public void OneHopQueryReturnsATwoLevelTreeOfWorkItems() { // Arrange QueryDefinition query = new QueryDefinition("Test", TestHelper.OneHopQuery); // Act WorkItemTree ans = this.sut.QueryRunner.QueryForWorkItems(query, new CancellationToken()); // Assert int count = 0; int maxLevel = int.MinValue; int minLevel = int.MaxValue; foreach (WorkItemTreeNode node in ans.DepthFirstNodes()) { count++; maxLevel = Math.Max(maxLevel, node.Level); minLevel = Math.Min(minLevel, node.Level); } VerifyAndDumpWorkItemTree(ans.RootNodes, 0); Assert.IsTrue(count > 0, "The query did not return any work items."); Assert.AreEqual <int>(0, minLevel, "The root nodes should be at level 0."); Assert.AreEqual <int>(1, maxLevel, "There should be more than no more than two levels in the result."); }
public void CanGetFullHistoryOfAWorkItem() { // Arrange QueryDefinition query = new QueryDefinition("Test", TestHelper.AllFieldTypesQuery + " WHERE [System.Id] = 21406"); // Act WorkItemTree ans = this.sut.QueryRunner.QueryForWorkItems(query, new CancellationToken()); // Assert ITfsWorkItem item = ans.DepthFirstNodes().First().WorkItem; string expect = @"<html><head/><body>11/03/2011 10:25:11 Resolved with changeset 24111.<br>11/03/2011 10:19:43 <no comment><br>10/03/2011 10:16:27 Associated with changeset 23952.<br>10/03/2011 10:14:22 Did some research and need some advice from the Word Product Group. Have sent email and now awaiting response.<br>10/03/2011 09:21:46 <no comment><br></body></html>"; Assert.AreEqual(expect, item["System.History"], "History not correct"); }
public void HtmlFieldGetsHtmlTagWrapper() { // Arrange QueryDefinition query = new QueryDefinition("Test", TestHelper.AllFieldTypesQuery + " WHERE [System.Id] = 21404"); // Act WorkItemTree ans = this.sut.QueryRunner.QueryForWorkItems(query, new CancellationToken()); // Assert ITfsWorkItem item = ans.DepthFirstNodes().First().WorkItem; string actual = item["Microsoft.VSTS.TCM.ReproSteps"].ToString(); Assert.IsTrue(actual.StartsWith("<html><head/><body><P"), "Field is not well-formed HTML, field content is: " + actual); Assert.IsTrue(actual.EndsWith("</P></body></html>"), "Field is not well-formed HTML, field content is: " + actual); }
public void FlatListQueryReturnsAFlatListOfWorkItems() { // Arrange QueryDefinition query = new QueryDefinition("Test", TestHelper.FlatQuery); // Act WorkItemTree ans = this.sut.QueryRunner.QueryForWorkItems(query, new CancellationToken()); // Assert int count = 0; foreach (WorkItemTreeNode node in ans.DepthFirstNodes()) { count++; Assert.AreEqual <int>(0, node.Level, "Flat list nodes should all be level 0"); } Assert.IsTrue(count > 0, "The query did not return any work items"); VerifyAndDumpWorkItemTree(ans.RootNodes, 0); }
public void DepthFirstIterationTest() { // Arrange WorkItemTreeNode node0 = new WorkItemTreeNode(null, 0); WorkItemTreeNode node0_0 = new WorkItemTreeNode(null, 1); WorkItemTreeNode node0_0_0 = new WorkItemTreeNode(null, 2); WorkItemTreeNode node0_0_1 = new WorkItemTreeNode(null, 2); WorkItemTreeNode node1 = new WorkItemTreeNode(null, 0); WorkItemTreeNode node1_0 = new WorkItemTreeNode(null, 0); node0.Children.Add(node0_0); node0_0.Children.Add(node0_0_0); node0_0.Children.Add(node0_0_1); node1.Children.Add(node1_0); WorkItemTree sut = new WorkItemTree(); sut.RootNodes.Add(node0); sut.RootNodes.Add(node1); // Act IEnumerator <WorkItemTreeNode> e = sut.DepthFirstNodes().GetEnumerator(); // Assert Assert.IsTrue(e.MoveNext()); Assert.AreSame(node0, e.Current); Assert.IsTrue(e.MoveNext()); Assert.AreSame(node0_0, e.Current); Assert.IsTrue(e.MoveNext()); Assert.AreSame(node0_0_0, e.Current); Assert.IsTrue(e.MoveNext()); Assert.AreSame(node0_0_1, e.Current); Assert.IsTrue(e.MoveNext()); Assert.AreSame(node1, e.Current); Assert.IsTrue(e.MoveNext()); Assert.AreSame(node1_0, e.Current); }