2009 Advent Calendar December 21st


The change we did yesterday makes it possible to remove the use of helper threads and timeouts for the MutexLock tests. Here is a first refactoring:

1: public class Given_an_abandoned_lock
2: {
3: private class MutexWrapperAlwaysAbandoned : MutexWrapper
4: {
5: public new void WaitOne()
6: {
7: throw new AbandonedMutexException();
8: }
9: }
10:  
11: private MutexLock<MutexWrapperAlwaysAbandoned> _lock;
12:
13: public Given_an_abandoned_lock()
14: {
15: _lock = new MutexLock<MutexWrapperAlwaysAbandoned>();
16: }
17:  
18: [Fact]
19: void It_should_be_possible_to_take_lock_when_thread_dies()
20: {
21: Assert.DoesNotThrow(() => { _lock.Lock(); });
22: }
23: }

Comments (0)