public void ShapeHelper_Test_GetNestedShapes_GroupWithSubGroups() { // group with subgroups var page = this.GetNewPage(); var active_window = page.Application.ActiveWindow; var shape0 = page.DrawRectangle(0, 0, 1, 1); var shape1 = page.DrawRectangle(2, 0, 3, 1); var group0 = VisioAutomationTest.SelectAndGroup(active_window, new[] { shape0, shape1 }); page.Application.ActiveWindow.DeselectAll(); var shape2 = page.DrawRectangle(0, 3, 1, 4); var shape3 = page.DrawRectangle(2, 0, 5, 6); var group1 = VisioAutomationTest.SelectAndGroup(active_window, new[] { shape2, shape3 }); page.Application.ActiveWindow.Selection.DeselectAll(); var group2 = VisioAutomationTest.SelectAndGroup(active_window, new[] { group0, group1 }); page.Application.ActiveWindow.Selection.DeselectAll(); var shapes = VisioAutomation.Shapes.ShapeHelper.GetNestedShapes(group2); Assert.AreEqual(7, shapes.Count); Assert.IsTrue(shapes.Contains(shape0)); Assert.IsTrue(shapes.Contains(shape1)); Assert.IsTrue(shapes.Contains(shape2)); Assert.IsTrue(shapes.Contains(shape3)); Assert.IsTrue(shapes.Contains(group0)); Assert.IsTrue(shapes.Contains(group1)); page.Delete(0); }
public void EnumerateShapes() { var page1 = this.GetNewPage(); var app = page1.Application; // ------------------------------- var a1 = page1.Shapes.ToEnumerable().ToList(); Assert.AreEqual(0, a1.Count); var a2 = VA.Shapes.ShapeHelper.GetNestedShapes(page1.Shapes.ToEnumerable()); Assert.AreEqual(0, a2.Count); // ------------------------------- var s1 = page1.DrawRectangle(0, 0, 1, 1); var b1 = page1.Shapes.ToEnumerable().ToList(); Assert.AreEqual(1, b1.Count); var b2 = VA.Shapes.ShapeHelper.GetNestedShapes(page1.Shapes.ToEnumerable()); Assert.AreEqual(1, b2.Count); // ------------------------------- var s2 = page1.DrawRectangle(1, 0, 2, 1); var s3 = page1.DrawRectangle(2, 0, 3, 1); var c1 = page1.Shapes.ToEnumerable().ToList(); Assert.AreEqual(3, c1.Count); var c2 = VA.Shapes.ShapeHelper.GetNestedShapes(page1.Shapes.ToEnumerable()); Assert.AreEqual(3, c2.Count); // ------------------------------- var active_window = app.ActiveWindow; var selection = active_window.Selection; selection.DeselectAll(); var g1 = VisioAutomationTest.SelectAndGroup(active_window, new[] { s2, s3 }); var d1 = page1.Shapes.ToEnumerable().ToList(); Assert.AreEqual(2, d1.Count); var d2 = VA.Shapes.ShapeHelper.GetNestedShapes(page1.Shapes.ToEnumerable()); Assert.AreEqual(4, d2.Count); page1.Delete(0); }
public void ShapeHelper_Test_GetNestedShapes_GroupWithTwoSubShapes() { // group with two shapes var page = this.GetNewPage(); var shape0 = page.DrawRectangle(0, 0, 1, 1); var shape1 = page.DrawRectangle(2, 0, 3, 1); var active_window = page.Application.ActiveWindow; var group = VisioAutomationTest.SelectAndGroup(active_window, new[] { shape0, shape1 }); var shapes = VisioAutomation.Shapes.ShapeHelper.GetNestedShapes(group); Assert.AreEqual(3, shapes.Count); Assert.IsTrue(shapes.Contains(shape0)); Assert.IsTrue(shapes.Contains(shape1)); Assert.IsTrue(shapes.Contains(group)); page.Delete(0); }