Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Since we already have an implementation for the MutexLock I want to add another passing test:
1: public class Given_a_locked_MutexLock : IDisposable
2: {
3: private MutexLock _lock = new MutexLock();
4: private Thread _thread;
5: private bool _gotLock = false;
6:
7: public Given_a_locked_MutexLock()
8: {
9: _lock.Lock();
10: _thread = new Thread(() =>
11: {
12: _lock.Lock();
13: _gotLock = true;
14: _lock.Unlock();
15: });
16: _thread.Start();
17:
18: }
19:
20: public void Dispose()
21: {
22: if (_thread != null)
23: {
24: _thread.Abort();
25: }
26: }
27:
28: [Fact(Timeout = 1000)]
29: void It_should_not_take_the_lock()
30: {
31: Assert.False(_thread.Join(250));
32: Assert.False(_gotLock);
33: }
34: }
It's starting to get tricky using helper threads but let's continue tomorrow...