Arduino.cs Unit Tests
This is the main class of the application and as such, it has the most extensive list of unit tests.
A line through the test indicates that it has been written and checked in to the source repository.Arduino.FirmataMajorVersion - Property showing Firmata version info.
- Verify that the property is null after object (Arduino) creation (before the connection is opened).
- Verify that the property shows a value after sending the Arduino a FirmataVersionRequest message.
- Verify that the property is immutable.
Arduino.FirmataMinorVersion - Property showing Firmata version info.
- Verify that the property is null after object (Arduino) creation (before the connection is opened).
- Verify that the property shows a value after sending the Arduino a FirmataVersionRequest message.
- Verify that the property is immutable.
Arduino.FirmataName - Property showing Firmata version text description (should be the Arduino sketch name).
- Verify that the property is null after object (Arduino) creation (before the connection is opened).
- Verify that the property shows a value after sending the Arduino a FirmataVersionRequest message.
- Verify that the property is immutable.
Arduino.PortName - The name of the serial port that the Arduino class instance is configured to use.
- Verify that this is never empty. If we have a class instance, this needs to have a value.
- Verify that the property is immutable.
Arduino.BaudRate - The baud rate that the Arduino class instance is configured to use for serial communication.
- Verify that this is never 0. If we have a class instance, this needs to have a value. Test with different constructor values (some valid, and some not).
- Verify that the property is immutable.
Arduino.DigitalPinState - The state of the digital pins, high (1) or low (0) for each bit representing a pin.
- Verify that the values cannot be changed by external code.
- Verify that the property cannot be replaced by a new instance of it.
Arduino() - The default constructor.
No unit tests to perform, only functional tests.
Arduino(string portName) - Constructs using only the port name.
- Verify that the port name is stored in the Arduino.PortName property. Combine with Arduino.PortName unit tests.
- Verify that if portName is null or empty that we see an exception.
Arduino(string portName, int baudRate) - Constructs using port name and baud rate.
- Verify object is constructed properly when valid data is passed for baudRate. Combine with Arduino.BaudRate unit tests.
Arduino(string portName, int baudRate, true) - Constructs the object and automatically opens the connection.
No unit tests to perform, only functional tests.
Arduino.Events - The events that the Arduino object raises.
- Verify that the MessagePosted event can have an event handler attached and detached.
- Verify that the AnalogPinReportReceived event can have an event handler attached and detached.
- Verify that the DigitalPortReportReceived event can have an event handler attached and detached.
- Verify that the FirmataVersionReportReceived event can have an event handler attached and detached.
- Verify that the UnknownMessageReceived event can have an event handler attached and detached.
Arduino.GetAnalogValue(int pinNumber) - Gets the value of an analog pin.
- Verify that each pin returns a value of 0 for a disconnected Arduino.
- Verify that only pins 0-5 can be used and that the exception returned when we go out of bounds is meaningful.
Arduino.Connect() - This method is used to attach to a connected Arduino.
- Verify that this fails correctly without a connected Arduino.
Arduino.Disconnect() - This method is used to disconnect a connected Arduino.
- Verify that a call to it generates an InvalidOperationException.
Arduino.Post(byte[] message) - This method is used to post a message to a connected Arduino.
- Verify that the ArgumentNullException is thrown when we pass it a null array.
- Verify that the InvalidOperationException is thrown when we pass it an empty array.
- Verify that the InvalidOperationException is thrown when we don't have an open serial port.
Arduino.Dispose() - This method disposes of the object.
- Verify that calling this method doesn't generate an exceptions.
- Verify that the object cannot be used after the method is called.