public void Neighbours_OnACube_ShouldHaveEachIndexAppearFourTimesTotal (IPolyhedron polyhedron) { // Fixture setup var expected = Enumerable.Repeat(Enumerable.Range(0, 6), 4).SelectMany(list => list).ToList(); // Exercise system var neighbours = FaceIndexedTableFactory.Neighbours(polyhedron); var actual = neighbours.SelectMany(list => list).ToList(); // Verify outcome TestUtilities.WriteExpectedAndActual(expected, actual); Assert.True(TestUtilities.UnorderedEquals(expected, actual)); // Teardown }
public void Neighbours_OnACube_ShouldCreateSixListsOfFourElements (IPolyhedron polyhedron) { // Fixture setup var expected = Enumerable.Repeat(4, 6).ToList(); // Exercise system var neighbours = FaceIndexedTableFactory.Neighbours(polyhedron); var actual = neighbours.Select(list => list.Count()).ToList(); // Verify outcome TestUtilities.WriteExpectedAndActual(expected, actual); Assert.True(TestUtilities.UnorderedEquals(expected, actual)); // Teardown }
public void Neighbours_OnACube_ShouldBeCommutative (IPolyhedron polyhedron) { // Fixture setup // Exercise system var neighbourTable = FaceIndexedTableFactory.Neighbours(polyhedron); // Verify outcome for (int face = 0; face < neighbourTable.Length; face++) { foreach (var neighbour in neighbourTable[face]) { Assert.Contains(face, neighbourTable[neighbour]); } } // Teardown }
public void Neighbours_OnACube_ShouldListNeighboursInAnticlockwiseOrder (IPolyhedron polyhedron) { // Fixture setup // Exercise system var neighbourTable = FaceIndexedTableFactory.Neighbours(polyhedron); // Verify outcome for (int i = 0; i < neighbourTable.Length; i++) { var centerOfFace = polyhedron.Faces[i].SphericalCenter(); var viewVector = -centerOfFace.Normalize(); var neighbours = neighbourTable[i].Select(index => polyhedron.Faces[index]); var centersOfNeighbours = neighbours.Select(neighbour => neighbour.SphericalCenter()).ToList(); Assert.True(TestUtilities.AreInAntiClockwiseOrder(centersOfNeighbours, centerOfFace, viewVector)); } // Teardown }