public void Test_it_gets_disposed_at_most_once() { foreach (var round in Enumerable.Range(0, 1000)) { var d = new BooleanDisposable(); BooleanDisposableTestHelper.TestTryDisposeExecuteAtMostOnce(d); } }
public void Test_TryDisposable_executes_at_most_once() { foreach (var round in Enumerable.Range(0, 1000)) { var ds = Enumerable.Range(0, 5).Select(_ => new SensitiveDisposable()).ToArray(); BooleanDisposableTestHelper.TestTryDisposeExecuteAtMostOnce( ImmutableCompositeDisposable.FromEnumerable(ds) ); ds.All(d => d.IsDisposed).Is(true); } }
public void Test_TryDispose_concurrency() { foreach (var round in Enumerable.Range(0, 1000)) { var d1 = new SensitiveDisposable(); var d2 = new SensitiveDisposable(); var d = ImmutableCompositeDisposable.Create(d1, d2); BooleanDisposableTestHelper.TestTryDisposeExecuteAtMostOnce(d); d1.IsDisposed.Is(true); d2.IsDisposed.Is(true); } }