public void Execute_WhenMarkedForDeletion_DoesNotInvokeAction <TIn>(TIn inputParameter) { var callCounter = Substitute.For <ICallCounter>(); using (StaticWeakDelegatesCallCounter.WithCallCounter(callCounter)) { var weakAction = StaticWeakDelegatesCallCounter.GetWeakStaticAction <TIn>(); weakAction.MarkForDeletion(); weakAction.Execute(inputParameter); callCounter.DidNotReceive().OnActionCalled(Arg.Any <TIn>()); } }
public void Execute_AfterGarbageCollection_InvokesAction <TIn>(TIn inputParameter) { var callCounter = Substitute.For <ICallCounter>(); using (StaticWeakDelegatesCallCounter.WithCallCounter(callCounter)) { var weakAction = StaticWeakDelegatesCallCounter.GetWeakStaticAction <TIn>(); GC.Collect(); weakAction.Execute(inputParameter); callCounter.Received(1).OnActionCalled(inputParameter); } }
public void Execute_WhenMarkedForDeletion_DoesNotInvokeAction <TOut>(TOut outputParameter) { var callCounter = Substitute.For <ICallCounter>(); using (StaticWeakDelegatesCallCounter.WithCallCounter(callCounter)) { var weakFunc = StaticWeakDelegatesCallCounter.GetWeakStaticFunc <TOut>(); weakFunc.MarkForDeletion(); weakFunc.Execute(); callCounter.DidNotReceive().OnActionCalled(); } }
public void Execute_AfterGarbageCollection_InvokesFunc <TOut>(TOut outputParameter) { var callCounter = Substitute.For <ICallCounter>(); using (StaticWeakDelegatesCallCounter.WithCallCounter(callCounter)) { var weakFunc = StaticWeakDelegatesCallCounter.GetWeakStaticFunc <TOut>(); GC.Collect(); weakFunc.Execute(); callCounter.Received(1).OnFuncCalled <TOut>(); } }
public void Execute_AfterGarbageCollection_InvokesFunc <TIn, TOut>( TIn inputParameter, TOut outputParameter) { var callCounter = Substitute.For <ICallCounter>(); using (StaticWeakDelegatesCallCounter.WithCallCounter(callCounter)) { var weakFunc = StaticWeakDelegatesCallCounter.GetWeakAnonymousFuncWithStaticReference <TIn, TOut>(); weakFunc.Execute(inputParameter); callCounter.Received(1).OnFuncCalled <TIn, TOut>(inputParameter); } }
public void Execute_AfterGarbageCollection_InvokesAction() { var callCounter = Substitute.For <ICallCounter>(); using (StaticWeakDelegatesCallCounter.WithCallCounter(callCounter)) { var weakAction = StaticWeakDelegatesCallCounter .GetWeakAnonymousActionWithStaticReference(); GC.Collect(); weakAction.Execute(); callCounter.Received(1).OnActionCalled(); } }
public void Execute_WithCustomTargetAlive_WithAfterGarbageCollection_InvokesAction() { var callCounter = Substitute.For <ICallCounter>(); using (StaticWeakDelegatesCallCounter.WithCallCounter(callCounter)) { var(_, weakAction) = WeakDelegateCreator .CreateWeakDelegateWithCustomTarget(StaticWeakDelegatesCallCounter.GetWeakStaticAction); GC.Collect(); weakAction.Execute(); callCounter.Received(1).OnActionCalled(); } }
public void Execute_WithCustomTargetDead_AfterGarbageCollection_DoesNotInvokeAction() { var callCounter = Substitute.For <ICallCounter>(); using (StaticWeakDelegatesCallCounter.WithCallCounter(callCounter)) { var(customTarget, weakAction) = WeakDelegateCreator .CreateWeakDelegateWithCustomTarget(StaticWeakDelegatesCallCounter.GetWeakStaticAction); customTarget.Dispose(); GC.Collect(); weakAction.Execute(); callCounter.DidNotReceive().OnActionCalled(); } }
public void Execute_WithCustomTargetDead_AfterGarbageCollection_DoesNotInvokeFunc <TOut>(TOut outputParameter) { var callCounter = Substitute.For <ICallCounter>(); using (StaticWeakDelegatesCallCounter.WithCallCounter(callCounter)) { var(customTarget, weakFunc) = WeakDelegateCreator .CreateWeakDelegateWithCustomTarget(StaticWeakDelegatesCallCounter.GetWeakStaticFunc <TOut>); customTarget.Dispose(); GC.Collect(); weakFunc.Execute(); callCounter.DidNotReceive().OnFuncCalled <TOut>(); } }
public void Execute_WithCustomTargetAlive_AfterGarbageCollection_InvokesFunc <TIn, TOut>( TIn inputParameter, TOut outputParameter) { var callCounter = Substitute.For <ICallCounter>(); using (StaticWeakDelegatesCallCounter.WithCallCounter(callCounter)) { var(_, weakFunc) = WeakDelegateCreator .CreateWeakDelegateWithCustomTarget(StaticWeakDelegatesCallCounter.GetWeakStaticFunc <TIn, TOut>); GC.Collect(); weakFunc.Execute(inputParameter); callCounter.Received(1).OnFuncCalled <TIn, TOut>(inputParameter); } }