public void Device_Should_WriteCorrectData_WhenClientCycles() { MockIncrementingClientsHandler clients = new MockIncrementingClientsHandler(lights); rs232Device = CreateRS232Device(clients); rs232Device.Run(255); rs232Device.StopThread(); MockSerialPort mockSerialPort = MockSerialPort.Instance; string[] expectedResults = File.ReadAllLines(Path.Combine(_resultsFolderPath, "RS232CycleResults.txt")); Assert.AreEqual(expectedResults.Length, mockSerialPort.Writes.Count); for (int i = 0; i < expectedResults.Length; i++) { string[] resultPieces = expectedResults[i].Split(" "); Assert.AreEqual(resultPieces.Length, mockSerialPort.Writes[i].Length); for (int j = 0; j < resultPieces.Length; j++) { Assert.AreEqual(int.Parse(resultPieces[j], System.Globalization.NumberStyles.HexNumber), mockSerialPort.Writes[i][j]); } } }
public void SolidColorTest() { IChannelDataProvider solidColorCycler = new CycleSolidColorChannelProvider(); rs232Device = CreateRS232Device(solidColorCycler); rs232Device.Run(255); }
public void WalkingTest() { WalkingChannelProvider solidColorCycler = new WalkingChannelProvider(); rs232Device = CreateRS232Device(solidColorCycler); solidColorCycler.NumberOfLights = lights.Count; rs232Device.Run(255); }
public void Device_Should_WriteCorrectData_WhenNoClientsAreConnected() { CClientsHandler clients = new CClientsHandler(lights); rs232Device = CreateRS232Device(clients); rs232Device.Run(2); MockSerialPort mockSerialPort = MockSerialPort.Instance; Assert.AreEqual(START_WRITES + 2 + CLOSE_WRITES, mockSerialPort.Writes.Count); byte[] expectedBytes = { 0x41, 0x64, 0x61, 0x00, 0x18, 0x4D, 0, 0, 0, 0xF, 0xE, 0xD, 0xC, 0xB, 0xA }; Assert.AreEqual(expectedBytes, mockSerialPort.Writes[3]); Assert.AreEqual(expectedBytes, mockSerialPort.Writes[4]); }
public void Device_Should_WriteCorrectData_WhenClientIsConnected() { MockEmptyClientsHandler clients = new MockEmptyClientsHandler(lights, new Dictionary <int, float> { { 1, 0xFF0000 }, { 2, 0x00FF00 }, { 3, 0x0000FF } }); rs232Device = CreateRS232Device(clients); rs232Device.Run(2); MockSerialPort mockSerialPort = MockSerialPort.Instance; Assert.AreEqual(START_WRITES + 2 + CLOSE_WRITES, mockSerialPort.Writes.Count); byte[] expectedBytes = { 0x41, 0x64, 0x61, 0x00, 0x18, 0x4D, 0xFF, 0xFF, 0xFF, 0xF, 0xE, 0xD, 0xC, 0xB, 0xA }; int targetDataRow = START_WRITES + 2; Assert.AreEqual(expectedBytes, mockSerialPort.Writes[targetDataRow - 1]); }