i'm doing a mocked test that waits until something finishes. the problem is ,that i can't run the 2nd method as it waits for the first one somehow.
public interface ITest
{
void T1();
void T2();
}
the problem is in calling T2() - it waits for T1 to end. i don't understand why
[Test]
public void TestThread()
{
ITest t = MockRepository.GenerateMock<ITest>();
t.Stub(t1 => t1.T1()).WhenCalled((mi) =>
{
Thread.Sleep(10000);
});
t.Stub(t1 => t1.T2()).WhenCalled((mi) =>
{
// something
});
Task<string> task = Task.Factory.StartNew<string>(() =>
{
t.T1();
return "";
});
Thread.Sleep(1000);
t.T2(); // This hangs until T1 is finished!
}
Anyone encountered this?