public void TryDispose_ValidParam_ReturnsTrueAndCallsDispose() { var fake = new FakeDisposable(); Assert.IsTrue(DisposableExtensions.TryDispose(fake)); Assert.IsTrue(fake.WasCalled); }
public void CallsOnDispose() { var disposable = new FakeDisposable(); disposable.Dispose(); Assert.Equal(1, disposable.OnDispose_CallCount); }
public void tryuseDisposableMap_MockDisposable_DisposeCalled() { var d = new FakeDisposable(); Func <IDisposable, Unit> f = _ => unit; tryuse(d, f)(); Assert.True(d.DisposedCalled); }
public void UseTryBind_MockDisposable_DisposeCalled() { var d = new FakeDisposable(); var m = Try(d); Func <IDisposable, Try <Unit> > f = _ => Try(unit); m.Use(f)(); Assert.True(d.DisposedCalled); }
public void UseTryMap_MockDisposable_DisposeCalled() { var d = new FakeDisposable(); var m = Try(d); Func <IDisposable, Unit> f = _ => unit; m.Use(f)(); Assert.True(d.DisposedCalled); }
public void useFuncMap_MockDisposable_DisposeCalled() { var d = new FakeDisposable(); Func <IDisposable> m = () => d; Func <IDisposable, Unit> f = _ => unit; use(m, f); Assert.True(d.DisposedCalled); }
public async Task useTaskBind_MockDisposable_DisposeCalled() { var d = new FakeDisposable(); var m = identity <IDisposable>(d).AsTask(); Func <IDisposable, Task <Unit> > f = _ => unit.AsTask(); await use(m, f); Assert.True(d.DisposedCalled); }
public async Task useDisposableMapToTask_CheckForEarlyDisposeCall_DisposeNotCalled() { var d = new FakeDisposable(); Func <FakeDisposable, Task <bool> > f = async fd => { await Task.Yield(); return(fd.DisposedCalled); }; var disposeAlreadyCalled = await use(d, f); Assert.False(disposeAlreadyCalled); }
public virtual void IsDisposedTest() { // Arrange var disposable = new FakeDisposable(); Assert.IsNotNull(disposable); // Act TestManager.SetValue(disposable); TestManager.SetValue(disposable, LifetimeContainer); Assert.AreEqual(1, LifetimeContainer.Count); }
public override void SetupTest() { base.SetupTest(); TestObject = new FakeDisposable(); }