2009 Advent Calendar December 22nd
And today we refactor yet another test that is potentially slow when failing (because of the timeout):
1: public class Given_an_unlocked_MutexLock
2: {
3: private class MutexWrapperAlwaysUnlocked : MutexWrapper
4: {
5: public static int NumberOfLocks { get; set; }
6:
7: public override void WaitOne()
8: {
9: ++NumberOfLocks;
10: }
11:
12: public override void ReleaseMutex()
13: {
14:
15: }
16: }
17:
18: private MutexLock<MutexWrapperAlwaysUnlocked> _lock = new MutexLock<MutexWrapperAlwaysUnlocked>();
19:
20: public Given_an_unlocked_MutexLock()
21: {
22: MutexWrapperAlwaysUnlocked.NumberOfLocks = 0;
23: }
24:
25: [Fact]
26: void It_should_be_possible_to_lock()
27: {
28: _lock.Lock();
29: Assert.Equal(1, MutexWrapperAlwaysUnlocked.NumberOfLocks);
30: }
31: }