Exemple #1
0
        private void DoTrim(IEnumerable <Entity> existingEntities,
                            Entity entityToTrim,
                            Point selectionPoint,
                            bool expectTrim,
                            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(entityToTrim);

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

            EditUtilities.Trim(
                new SelectedEntity(entityToTrim, selectionPoint),
                boundary,
                out removed,
                out added);

            // verify deleted
            Assert.Equal(expectTrim, removed.Any());
            if (expectTrim)
            {
                Assert.Single(removed);
                Assert.True(removed.Single().EquivalentTo(entityToTrim));
            }

            // verify added
            Assert.Equal(expectedAdded.Count(), added.Count());
            var expectedText = string.Join("\n  ", expectedAdded.Select(e => e.ToString()));
            var actualText   = string.Join("\n  ", added.Select(e => e.ToString()));

            Assert.True(expectedAdded.Zip(added, (a, b) => a.EquivalentTo(b)).All(b => b), $"Expected:\n  {expectedText}\nActual:\n  {actualText}");
        }
Exemple #2
0
 protected override void DoTrimExtend(SelectedEntity selectedEntity, IEnumerable <Primitives.IPrimitive> boundaryPrimitives, out IEnumerable <Entity> removed, out IEnumerable <Entity> added)
 {
     EditUtilities.Trim(selectedEntity, boundaryPrimitives, out removed, out added);
 }