Exemplo n.º 1
0
        private void DoExtend(IEnumerable <Entity> existingEntities,
                              Entity entityToExtend,
                              Point selectionPoint,
                              bool expectExtend,
                              IEnumerable <Entity> expectedAdded)
        {
            expectedAdded = expectedAdded ?? new Entity[0];

            // prepare the drawing
            foreach (var ent in existingEntities)
            {
                Workspace.AddToCurrentLayer(ent);
            }
            var boundary = Workspace.Drawing.GetEntities().SelectMany(e => e.GetPrimitives());

            Workspace.AddToCurrentLayer(entityToExtend);

            // extend
            IEnumerable <Entity> removed;
            IEnumerable <Entity> added;

            EditUtilities.Extend(
                new SelectedEntity(entityToExtend, selectionPoint),
                boundary,
                out removed,
                out added);

            // verify deleted
            Assert.Equal(expectExtend, removed.Any());
            if (expectExtend)
            {
                Assert.Equal(1, removed.Count());
                Assert.True(removed.Single().EquivalentTo(entityToExtend));
            }

            // verify added
            Assert.Equal(expectedAdded.Count(), added.Count());
            Assert.True(expectedAdded.Zip(added, (a, b) => a.EquivalentTo(b)).All(b => b));
        }
Exemplo n.º 2
0
 protected override void DoTrimExtend(SelectedEntity selectedEntity, IEnumerable <Primitives.IPrimitive> boundaryPrimitives, out IEnumerable <Entity> removed, out IEnumerable <Entity> added)
 {
     EditUtilities.Extend(selectedEntity, boundaryPrimitives, out removed, out added);
 }