public void Interpolation_NegativeYRotationWithWideCube() { var cube = new Cube(10, 30, 15).Rotate(0, -90, 0); //Rotating on Y axis by -90 should shift the center of the cube on the negative X quadrant Assert.AreEqual(new Vector3(-7.5, 15, 5), cube.Position()); }
public void Interpolation_ZRotationWithLongCube() { var cube = new Cube(10, 5, 2).Rotate(0, 0, 115); //Rotating on Z axis by 90 should shift the center of the cube on the negative X quadrant Assert.AreEqual(new Vector3(-4.37886077629512, 3.4749932808315, 1), cube.Position()); }
public void Interpolation_NegativeRotationOnXAxis() { var cube = new Cube(11, 11, 11).Rotate(-90, 0, 0); //Rotating on X axis by -90 should shift the center of the cube on the negative Z quadrant Assert.AreEqual(new Vector3(5.5, 5.5, -5.5), cube.Position()); }
public void Scale_TranslateRotateScaleStillYieldsCorrectPosition() { var obj = new Cube(5, 5, 20) .Translate(30, 0, 0).Rotate(0, 90, 0).Scale(2, 2, 2); Assert.AreEqual(new Vector3(20, 5, -65), obj.Position()); }
public void Union_FirstStatementInOutputScriptIsUnionMethodCall() { var union = new Cube().Union(new Cylinder()); string script = union.ToString(); Assert.IsTrue(script.StartsWith("union()")); }
public void Interpolation_RotateOnXAxis() { var cube = new Cube(9, 9, 9).Rotate(90, 0, 0); //Rotating on X axis by 90 should shift the center of the cube on the negative Y quadrant Assert.AreEqual(new Vector3(4.5, -4.5, 4.5), cube.Position()); }
public void Resize_BoundaryBasedPositionAfterResizeIsInExpectedLocation() { var pos = new Cube(5, 5, 20) .Translate(30, 0, 0).Rotate(0, 90, 0).Resize(2, 2, 2).Position(); Assert.AreEqual(new Vector3(1, 1, -13), pos); }
public void Difference_MinusOperatorCreatesDifferenceObject() { var obj = new Cube() - new Sphere(); var diff = new Sphere().Difference(new Cube()); Assert.IsTrue(obj.GetType() == diff.GetType()); }
public void Union_FirstElementAppearsFirstInOutputScript() { var union = new Cube().Union(new Cylinder()); string script = union.ToString(); Assert.IsTrue(script.IndexOf("cube(") < script.IndexOf("cylinder(")); }
public void Union_AddingObjectsCreatesUnion() { var obj = new Cube() + new Cylinder(); var union = new Cube().Union(new Cylinder()); Assert.IsTrue(obj.GetType() == union.GetType()); }
public void Interpolation_NegativeZRotation() { var cube = new Cube(10, 5, 2).Rotate(0, 0, -95); //Rotating on Z axis by 90 should shift the center of the cube on the negative Y quadrant Assert.AreEqual(new Vector3(2.05470803149107, -5.19886284732787, 1), cube.Position()); }
public void Interpolation_PositiveYRotationWithTallCube() { var cube = new Cube(10, 12, 23).Rotate(0, 90, 0); //Rotating on Y axis by 90 should shift the center of the cube on the negative Z quadrant Assert.AreEqual(new Vector3(11.5, 6, -5), cube.Position()); }
public void Resize_ResizeScalesBoundariesToFit() { var obj = new Cube(20, 20, 10).Resize(5, 5, 5); var bounds = obj.Bounds(); Assert.AreEqual(new Vector3(5, 5, 5), bounds.TopRight); Assert.AreEqual(new Vector3(0, 0, 0), bounds.BottomLeft); }
public void Union_AffectedObjectsAreChildren() { var union = new Cube().Union(new Cylinder()); var children = union.Children(); Assert.IsTrue(children.ElementAt(0).GetType() == typeof(Cube)); Assert.IsTrue(children.ElementAt(1).GetType() == typeof(Cylinder)); }
public void Union_AffectedObjectsAreInOutputScript() { var union = new Cube().Union(new Cylinder()); string script = union.ToString(); Assert.IsTrue(script.Contains("cube(")); Assert.IsTrue(script.Contains("cylinder(")); }
public void Mirror_SingleAxisMirrorInvertsBounds() { OSCADObject cube = new Cube(5, 10, 20); var boundsBefore = cube.Bounds(); cube = cube.Mirror(0, 1, 0); Assert.AreEqual(cube.Bounds().YMax, boundsBefore.YMin); }
public void Cube_CloneYieldsSameScript() { var cube = new Cube(new Vector3(1.5, 5.5, 8.7)); var clone = cube.Clone(); Assert.IsTrue(clone.IsSameAs(cube)); }
public void Cube_SizeAppearsInOutput() { var cube = new Cube(new Vector3(1.5, 5.5, 8.7)); string script = cube.ToString(); Assert.IsTrue(script.Contains(String.Format("size = [{0}, {1}, {2}]", 1.5, 5.5, 8.7))); }
public void Cube_ParameterlessCubeHasMethodCallInIt() { var cube = new Cube(); string script = cube.ToString(); Assert.IsTrue(script.StartsWith("cube(")); Assert.IsTrue(script.TrimEnd().EndsWith(");")); }
public void Translate_BoundsMoveWhenObjectIsTranslated() { var cube = new Cube(); var boundsBefore = cube.Bounds(); var boundsAfter = cube.Translate(5, 2, 3).Bounds(); Assert.AreEqual(boundsAfter.TopRight, boundsBefore.TopRight + new Vector3(5, 2, 3)); Assert.AreEqual(boundsAfter.BottomLeft, boundsBefore.BottomLeft + new Vector3(5, 2, 3)); }
public void Difference_ChainingMinusOperationAddsToTheSameDifferenceObject() { var obj = new Cube() - new Sphere() - new Text3D("WOW!") - new Cylinder().Translate(1, 2, 5); var diff = new Sphere().Difference(new Cube()); var childrenThatAreDiffs = obj.Children().Where(child => child.GetType() == diff.GetType()).Count(); Assert.AreEqual(0, childrenThatAreDiffs); }
public void Union_ChainingAdditionAddsToTheSameUnion() { var obj = new Cube() + new Sphere() + new Text3D("WOW!") + new Cylinder().Translate(1, 2, 5); var union = new Sphere().Union(new Cube()); var unionChildrenCount = obj.Children().Where(child => child.GetType() == union.GetType()).Count(); Assert.AreEqual(0, unionChildrenCount); }
private static OSCADObject getEndCover(OSCADObject outer) { var bounds = outer.Bounds(); var endCover = new Cube(Inches.Sixteenth, bounds.Width, bounds.Height, true); var choppedOut = endCover.Clone().Scale(2, (bounds.Width-Inches.Quarter)/ bounds.Width, (bounds.Height - Inches.Half) / bounds.Height); choppedOut = choppedOut.Translate(0, Inches.Quarter, 0); return endCover - choppedOut; }
public void OSCADObject_EachOscadObjectChildHasDistinctId() { var obj = new Cube(5, 5, 10, true) .Translate(0, 5, 10).Rotate(0, 90, 0) .Translate(0, 0, 10).Scale(1, 1, 2); List<int> ids = obj.Children().Select(child => child.Id).ToList(); ids.Add(obj.Id); Assert.AreEqual(ids.Count, ids.Distinct().Count()); }
public void Hull_BasisObjectAppearsInHullChildren() { var cube = new Cube(); var sphere = new Sphere().Translate(0, 0, 2); var hull = cube.Hull(sphere); var children = hull.Children(); Assert.IsTrue(children.Contains(cube)); Assert.IsTrue(children.Contains(sphere)); }
internal void SetHeight(Color color, Cube cube) { if (this.heightMode != "None") { cube.Size.Z = heightMappings[color]; } else { cube.Size.Z = 1.0; } }
public void Cube_LengthWidthHeightAffectSizeVector() { const double length = 10; const double width = 7; const double height = 9; var cube = new Cube(length, width, height); Assert.AreEqual(length, cube.Size.X); Assert.AreEqual(width, cube.Size.Y); Assert.AreEqual(height, cube.Size.Z); }
public void OSCADObject_IdsAreSequentialAndDistinct() { var obj1 = new Sphere(); var obj2 = new Cube(); var obj3 = new Sphere(); Assert.IsTrue(obj1.Id < obj2.Id && obj2.Id < obj3.Id); Assert.IsTrue(obj1.Id + 1 == obj2.Id); Assert.IsTrue(obj2.Id + 1 == obj3.Id); }
public void Settings_NullOpenSCADPathThrowsError() { OutputSettings.OpenSCADPath = null; var cube = new Cube(); var mock = new Mock<IFileWriter>(); mock.Setup(_wrtr => _wrtr.WriteAllLines(It.IsAny<string>(), It.IsAny<string[]>())) .Callback<string, string[]>((path, contents) => { }); Dependencies.SetFileWriter(mock.Object); cube.ToFile("test").Open(); }
public void Scale_BoundsScaleWithObject() { var obj = new Cube(5, 5, 5).Scale(2, 2, 3); var bounds = obj.Bounds(); Assert.AreEqual(bounds.XMax, 10); Assert.AreEqual(bounds.YMax, 10); Assert.AreEqual(bounds.ZMax, 15); Assert.AreEqual(bounds.XMin, 0); Assert.AreEqual(bounds.YMin, 0); Assert.AreEqual(bounds.ZMin, 0); }