public void IfNull_WithTarget_DoNotCallFuncTR_ReturnOtherTypeNull()
        {
            var target = new MockClass1();

            MockClass2 rtn = target.IfNull(() => new MockClass2());

            Assert.IsNull(rtn);
        }
        public void IfNull_WithNullTarget_CallFuncTR_ReturnOtherType()
        {
            var target = default(MockClass1);

            MockClass2 rtn = target.IfNull(() => new MockClass2());

            Assert.IsNotNull(rtn);
        }
        public void IfNotNull_WithTarget_CallFuncTTR_ReturnOtherType()
        {
            var target = new MockClass1();

            MockClass2 otherRtn = target.IfNotNull(x => new MockClass2());

            Assert.IsNotNull(otherRtn);
        }
        public void IfNotNull_WithTarget_CallFuncTR_ReturnOtherType()
        {
            var target = new MockClass1();

            // Do not call Func<TR>(), return default(TR)
            MockClass2 otherRtn = target.IfNotNull(() => new MockClass2());

            Assert.IsNotNull(otherRtn);
        }
        public void IfNotNull_WithNullTarget_DoNotCallFuncTTR_ReturnOtherTypeNull()
        {
            var target = default(MockClass1);

            // Do not call Func<T,TR>(), return default(TR)
            MockClass2 otherRtn = target.IfNotNull(x => new MockClass2());

            Assert.IsNull(otherRtn);
        }
        public void IfNull_WithNullTarget_CallAction_ReturnSameType()
        {
            var target      = default(MockClass1);
            var targetOther = new MockClass2();

            var rtn = target.IfNull(() => targetOther.OtherMethodReturnVoid());

            Assert.AreSame(rtn, target);
            Assert.IsTrue(targetOther.SomeMethodCalled);
        }