public void SteerTheShip_Steer_NiceAngles() { // q1 Assert.IsTrue(SteerTheShip.Steer(0, 1) == "R: 0" || SteerTheShip.Steer(0, 1) == "L: 0"); Assert.AreEqual("R: 30", SteerTheShip.Steer(1, Math.Sqrt(3))); Assert.AreEqual("R: 45", SteerTheShip.Steer(1, 1)); Assert.AreEqual("R: 60", SteerTheShip.Steer(Math.Sqrt(3), 1)); // q2 Assert.AreEqual("R: 90", SteerTheShip.Steer(1, 0)); Assert.AreEqual("R: 120", SteerTheShip.Steer(Math.Sqrt(3), -1)); Assert.AreEqual("R: 135", SteerTheShip.Steer(1, -1)); Assert.AreEqual("R: 150", SteerTheShip.Steer(1, -Math.Sqrt(3))); // q3 Assert.IsTrue(SteerTheShip.Steer(0, -1) == "R: 180" || SteerTheShip.Steer(0, -1) == "L: 180"); Assert.AreEqual("L: 150", SteerTheShip.Steer(-1, -Math.Sqrt(3))); Assert.AreEqual("L: 135", SteerTheShip.Steer(-1, -1)); Assert.AreEqual("L: 120", SteerTheShip.Steer(-Math.Sqrt(3), -1)); // q4 Assert.AreEqual("L: 90", SteerTheShip.Steer(-1, 0)); Assert.AreEqual("L: 60", SteerTheShip.Steer(-Math.Sqrt(3), 1)); Assert.AreEqual("L: 45", SteerTheShip.Steer(-1, 1)); Assert.AreEqual("L: 30", SteerTheShip.Steer(-1, Math.Sqrt(3))); }
public void SteerTheShip_Steer_ExampleTestCases() { Assert.AreEqual("R: 45", SteerTheShip.Steer(1, 1)); Assert.AreEqual("R: 90", SteerTheShip.Steer(1, 0)); Assert.AreEqual("L: 30", SteerTheShip.Steer(-1, Math.Sqrt(3))); Assert.IsTrue(SteerTheShip.Steer(0, 1) == "R: 0" || SteerTheShip.Steer(0, 1) == "L: 0"); Assert.IsTrue(SteerTheShip.Steer(0, -1) == "R: 180" || SteerTheShip.Steer(0, -1) == "L: 180"); }
public void SteerTheShip_Steer_LotsOfCoords() { for (var y = -100; y <= 100; y++) { for (var x = -100; x <= 100; x++) { if (x == 0) { continue; } Assert.AreEqual(MySteer(x, y), SteerTheShip.Steer(x, y)); } } }
public void SteerTheShip_Steer_RandomCoords() { var random = new Random(); for (var i = 0; i < 100; i++) { var x = GetRandomDouble(random); var y = GetRandomDouble(random); while (x == 0) { x = GetRandomDouble(random); } Assert.AreEqual(MySteer(x, y), SteerTheShip.Steer(x, y)); } }