public void Should_Hold_Debounce_References_Weakly() { WeakReference?sampleRef = null; WeakReference?sampleRef2 = null; new Action(() => { var sample = new DebouncingSample(); var sample2 = new DebouncingSample(); sampleRef = new WeakReference(sample); sampleRef2 = new WeakReference(sample2); sample.DebounceHere(); sample2.DebounceHere(); }).Invoke(); GC.Collect(); Assert.False(sampleRef !.IsAlive); Assert.False(sampleRef2 !.IsAlive); }
static bool LocalDebounce(DebouncingSample sample) => sample.DebounceHere();