Reputation: 1
I'm currently testing with NUnit v2.5.10 a communication class on serial port. Each test that uses the "Write" method fails in running mode but pass in debugging. The test fails because the method write on ComPort only a portion of buffer.
How can I fix this behaviour? Any help will be welcome. Thank you in advance.
Alex
Upvotes: 0
Views: 2478
Reputation: 1172
When unit-testing a communication class you should not rely on the real SerialPort class. You should MOCK the behavior of the SerialPort to test all the different logic flows in your communication class. Use for example the moq framework to simulate and verify the behavior of the SerialPort.
See following question for more information.
Upvotes: 3