Hello,
I'm having some problems executing the tests of the application I'm developing. All the tests execute normally with ReSharper and in NCover. However, the execution of one of these tests in TeamCity is generating an error.
This test initializes two objects, the object under test and a simulator of a real object. Both objects will communicate throug a serial link in a representation of the real scenario.
ObjectSimulator r_simulator = new ObjectSimulator(...);
ObjectDriver r_driver = new ObjectDriver(...);
Assert.IsTrue(r_driver.Connect() == ErrorCode.Success);
The simulator just do the following in the constructor
public class ObjectSimulator
{
...
public ObjectSimulator()
{
// serial port configuration
m_port = new SerialPort();
m_port.DataReceived += DataReceivedEvent;
}
...
}
The main object has two threads. The main thread of the application and a timer to refresh a watchdog timer in the real object.
public ErrorCode Connect()
{
...
StartSynchroTimer();
Thread.Sleep(4); // to check if the timer is working properly
...
}
The problem is comming from the Thread.Sleep() call, as when I remove it everything works. It seems like the ObjectSimulator also sleeps and doesn't receive the DataReceived event. How can I resolve this issue?