public void SetXY_ForwardValue() { // Setup MockSerialDevice serialDevice = new MockSerialDevice("COM3", 9600); Wheelchair chair = Wheelchair.Instance(serialDevice); bool correctValues = true; int input = 100; int expectedOutput = 190; int actualOutput = -1; chair.Start(); // act chair.SetX(0); chair.SetY(input); System.Threading.Thread.Sleep(150); actualOutput = chair.VoltY; chair.End(); string message = "Expected: "; message += expectedOutput; message += ", Actual: "; message += actualOutput; chair.Dispose(); Assert.AreEqual(expectedOutput, actualOutput, message); }
public void SetXY_ValidVoltages() { // Setup MockSerialDevice serialDevice = new MockSerialDevice("COM3", 9600); Wheelchair chair = Wheelchair.Instance(serialDevice); bool correctValues = true; int[] inputValues = { 0, -100, 100 }; int[] expectedValues = { 128, 66, 190 }; chair.Start(); // act for (int i = 0; i < 3; i++) { chair.SetX(inputValues[i]); chair.SetY(inputValues[i]); Thread.Sleep(150); if (chair.VoltX != expectedValues[i]) { correctValues = false; } if (chair.VoltY != expectedValues[i]) { correctValues = false; } } //chair.End(); chair.Dispose(); Assert.IsTrue(correctValues, "Voltages are not correct."); }