File tree Expand file tree Collapse file tree 4 files changed +45
-2
lines changed
Rubberduck.Main/ComClientLibrary/UnitTesting Expand file tree Collapse file tree 4 files changed +45
-2
lines changed Original file line number Diff line number Diff line change @@ -18,14 +18,16 @@ public Date()
1818 public void DateCallback ( IntPtr retVal )
1919 {
2020 OnCallBack ( true ) ;
21- if ( ! TrySetReturnValue ( ) ) // specific invocation
21+ if ( ! TrySetReturnValue ( ) )
2222 {
23- TrySetReturnValue ( true ) ; // any invocation
23+ TrySetReturnValue ( true ) ;
2424 }
2525 if ( PassThrough )
2626 {
27+ FakesProvider . SuspendFake ( "Now" ) ;
2728 var nativeCall = Marshal . GetDelegateForFunctionPointer < DateDelegate > ( NativeFunctionAddress ) ;
2829 nativeCall ( retVal ) ;
30+ FakesProvider . ResumeFake ( "Now" ) ;
2931 return ;
3032 }
3133 Marshal . GetNativeVariantForObject ( ReturnValue ?? 0 , retVal ) ;
Original file line number Diff line number Diff line change @@ -24,8 +24,10 @@ public void TimeCallback(IntPtr retVal)
2424 }
2525 if ( PassThrough )
2626 {
27+ FakesProvider . SuspendFake ( "Now" ) ;
2728 var nativeCall = Marshal . GetDelegateForFunctionPointer < TimeDelegate > ( NativeFunctionAddress ) ;
2829 nativeCall ( retVal ) ;
30+ FakesProvider . ResumeFake ( "Now" ) ;
2931 return ;
3032 }
3133 Marshal . GetNativeVariantForObject ( ReturnValue ?? 0 , retVal ) ;
Original file line number Diff line number Diff line change @@ -37,6 +37,30 @@ public void StartTest()
3737 CodeIsUnderTest = true ;
3838 }
3939
40+ public static void SuspendFake ( String typename )
41+ {
42+ foreach ( var fake in ActiveFakes . Values )
43+ {
44+ if ( fake . GetType ( ) . Name == typename )
45+ {
46+ fake . DisableHook ( ) ;
47+ return ;
48+ }
49+ }
50+ }
51+
52+ public static void ResumeFake ( String typename )
53+ {
54+ foreach ( var fake in ActiveFakes . Values )
55+ {
56+ if ( fake . GetType ( ) . Name == typename )
57+ {
58+ fake . DisableHook ( ) ;
59+ return ;
60+ }
61+ }
62+ }
63+
4064 public void StopTest ( )
4165 {
4266 foreach ( var fake in ActiveFakes . Values )
Original file line number Diff line number Diff line change @@ -53,6 +53,21 @@ protected void OnCallBack(bool trackNoParams = false)
5353 }
5454 }
5555
56+ public void DisableHook ( )
57+ {
58+ foreach ( var hook in _hooks )
59+ {
60+ hook . ThreadACL . SetExclusiveACL ( new [ ] { 0 } ) ;
61+ }
62+ }
63+ public void EnableHook ( )
64+ {
65+ foreach ( var hook in _hooks )
66+ {
67+ hook . ThreadACL . SetInclusiveACL ( new [ ] { 0 } ) ;
68+ }
69+ }
70+
5671 public virtual void Dispose ( )
5772 {
5873 foreach ( var hook in _hooks )
You can’t perform that action at this time.
0 commit comments