public void CurrentLayerStillSetAfterDrawingTest() { Workspace.AddLayer("Other"); Workspace.SetCurrentLayer("Other"); Workspace.AddToCurrentLayer(Line()); Assert.Equal(1, Workspace.GetLayer("Other").EntityCount); Assert.Equal(Workspace.GetLayer("Other"), Workspace.Drawing.CurrentLayer); }
public async Task ScaleWithDistance() { var line = new Line(new Point(0, 0, 0), new Point(1, 0, 0)); Workspace.AddToCurrentLayer(line); var result = await Execute("SCALE", new PushEntitiesOperation(new[] { line }), // select the line new PushNoneOperation(), // done selecting entities new PushPointOperation(new Point(0.0, 0.0, 0.0)), // base point new PushDistanceOperation(2.0) // scale factor ); Assert.True(result); var actual = (Line)Workspace.Drawing.GetEntities().Single(); Assert.True(actual.EquivalentTo(new Line(new Point(0.0, 0.0, 0.0), new Point(2.0, 0.0, 0.0)))); }
public async Task RotateWithAngle() { var line = new Line(new Point(0, 0, 0), new Point(1, 0, 0)); Workspace.AddToCurrentLayer(line); var result = await Execute("ROTATE", new PushEntitiesOperation(new[] { line }), // select the line new PushNoneOperation(), // done selecting entities new PushPointOperation(new Point(0.0, 0.0, 0.0)), // base point new PushTextOperation("90") // rotation angle ); Assert.True(result); var actual = (Line)Workspace.Drawing.GetEntities().Single(); Assert.True(actual.EquivalentTo(new Line(new Point(0.0, 0.0, 0.0), new Point(0.0, 1.0, 0.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}"); }
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)); }