public void TryDispose_ValidParam_ReturnsTrueAndCallsDispose()
        {
            var fake = new FakeDisposable();

            Assert.IsTrue(DisposableExtensions.TryDispose(fake));
            Assert.IsTrue(fake.WasCalled);
        }
Beispiel #2
0
                public void CallsOnDispose()
                {
                    var disposable = new FakeDisposable();

                    disposable.Dispose();

                    Assert.Equal(1, disposable.OnDispose_CallCount);
                }
Beispiel #3
0
        public void tryuseDisposableMap_MockDisposable_DisposeCalled()
        {
            var d = new FakeDisposable();
            Func <IDisposable, Unit> f = _ => unit;

            tryuse(d, f)();

            Assert.True(d.DisposedCalled);
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
        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);
        }
Beispiel #6
0
        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);
        }
Beispiel #7
0
        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);
        }
Beispiel #8
0
        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 void TryDispose_ValidParam_ReturnsTrueAndCallsDispose()
 {
     var fake = new FakeDisposable();
     Assert.IsTrue(DisposableExtensions.TryDispose(fake));
     Assert.IsTrue(fake.WasCalled);
 }
Beispiel #11
0
 public override void SetupTest()
 {
     base.SetupTest();
     TestObject = new FakeDisposable();
 }