+ 2 more mimic tests

+ Fix for an issue with Children() where duplicate children were being added on structures with 3+ OSCADObjects
This commit is contained in:
Mike Smith 2016-02-14 10:31:47 -08:00
parent becb6af003
commit 3d31d10912
2 changed files with 27 additions and 1 deletions

View File

@ -53,5 +53,31 @@ namespace OSCADSharp.UnitTests
Assert.IsTrue(cube.ToString().StartsWith("translate("));
Assert.IsTrue(sphere.ToString().StartsWith("translate("));
}
[TestMethod]
public void OSCADObject_MimicTakesMultipleTransformsFromObject()
{
var cube = new Cube(null, true)
.Translate(10, 0, 5).Rotate(0, 30, 0).Scale(1, 1.5, 1);
var sphere = new Sphere().Mimic(cube);
Assert.IsTrue(sphere.GetType() == cube.GetType());
var mimicedChildren = sphere.Children();
Assert.IsTrue(mimicedChildren.ElementAt(0).ToString().StartsWith("rotate("));
Assert.IsTrue(mimicedChildren.ElementAt(1).ToString().StartsWith("translate("));
Assert.IsTrue(mimicedChildren.ElementAt(2).ToString().StartsWith("sphere("));
}
[TestMethod]
public void OSCADObject_MimicDoesNothingOnObjectWithNoTransforms()
{
var cube = new Cube(null, true);
var sphere = new Sphere().Mimic(cube);
Assert.IsFalse(sphere.GetType() == cube.GetType());
Assert.AreEqual(0, sphere.Children().Count());
}
}
}

View File

@ -221,7 +221,7 @@ namespace OSCADSharp
child = toTraverse.Pop();
allChildren.Add(child);
foreach (var subChild in child.Children())
foreach (var subChild in child.children)
{
toTraverse.Push(subChild);
}