public void NearestNHardpoints_N1NearOrigin_ReturnsOriginHardpoint(float x, float y) { var uc = new UserCoordinates() { HardpointCoordinates = new PointF(x, y) }; Assert.AreEqual(new Hardpoint(0, 0, 0), uc.NearestNHardpoints(1).First()); }
public void NearestNHardpoints_N5_Returns5Hardpoints() { var uc = new UserCoordinates() { HardpointCoordinates = new PointF(0, 0) }; Assert.AreEqual(5, uc.NearestNHardpoints(5).Count); }
public void NearestNHardpoints_N4AtUnambiguousPoint_ReturnsHardpointsInDistanceOrder() { var uc = new UserCoordinates() { HardpointCoordinates = new PointF(.6f, .7f) }; var actual = uc.NearestNHardpoints(4); Assert.AreEqual(new Hardpoint(1, 1, 0), actual[0]); Assert.AreEqual(new Hardpoint(0, 1, 0), actual[1]); Assert.AreEqual(new Hardpoint(1, 0, 0), actual[2]); Assert.AreEqual(new Hardpoint(0, 0, 0), actual[3]); }
public void NearestNHardpoints_N4NearCenterOfGridSquare_ReturnsGridCorners(float x, float y) { var uc = new UserCoordinates() { HardpointCoordinates = new PointF(x, y) }; var actual = uc.NearestNHardpoints(4).ToList(); foreach (var expectedHardpoint in new[] { new Hardpoint(0, 0, 0), new Hardpoint(0, 1, 0), new Hardpoint(1, 0, 0), new Hardpoint(1, 1, 0) }) { Assert.Contains(expectedHardpoint, actual); } }
public void NearestNHardpoints_N9AtLocationNearOrigin_ReturnsHardpointsAroundOrigin(float x, float y) { var uc = new UserCoordinates() { HardpointCoordinates = new PointF(x, y) }; var actual = uc.NearestNHardpoints(9).ToList(); foreach (var expectedHardpoint in new[] { new Hardpoint(-1, -1, 0), new Hardpoint(-1, 0, 0), new Hardpoint(-1, 1, 0), new Hardpoint(0, -1, 0), new Hardpoint(0, 0, 0), new Hardpoint(0, 1, 0), new Hardpoint(1, -1, 0), new Hardpoint(1, 0, 0), new Hardpoint(1, 1, 0) }) { Assert.Contains(expectedHardpoint, actual); } }