public void testIfPresent() { { bool result = false; Maybe.of(3).ifPresent(i => result = true); Assert.IsTrue(result); } { bool result = false; Object o = null; Maybe.of(o).ifPresent(i => result = true); Assert.IsFalse(result); } { TestDisposable o = new TestDisposable(); Maybe <TestDisposable> m = Maybe.of(o); bool result = false; m.ifPresent(i => result = true); Assert.IsTrue(result); result = false; o.Dispose(); m.ifPresent(i => result = true); Assert.IsFalse(result); } }
public void testIsNotPresent() { Assert.IsFalse(Maybe.of(3).isNotPresent()); { Object o = null; Assert.IsTrue(Maybe.of(o).isNotPresent()); } { TestDisposable o = new TestDisposable(); Assert.IsFalse(Maybe.of(o).isNotPresent()); o.Dispose(); Assert.IsTrue(Maybe.of(o).isNotPresent()); } }