public void IfNotNull_WithTarget_CallAction_ReturnSameType() { var target = new SomeTestClass(); var rtn = target.IfNotNull(() => target.MethodReturnVoid()); Assert.IsNotNull(rtn); Assert.AreSame(rtn, target); Assert.IsTrue(target.SomeMethodCalled); }
public void IfNotNull_WithTarget_CallActionT_ReturnSameType() { var target = new SomeTestClass(); // Do not call Action<T>, always return source var rtn = target.IfNotNull(x => x.MethodReturnVoid()); Assert.IsNotNull(rtn); Assert.AreSame(rtn, target); Assert.IsTrue(target.SomeMethodCalled); }
public void IfNotNull_WithTarget_CallFuncTTR_ReturnOtherType() { var target = new SomeTestClass(); SomeOtherTestClass otherRtn = target.IfNotNull(x => new SomeOtherTestClass()); Assert.IsNotNull(otherRtn); }
public void IfNotNull_WithTarget_CallFuncTR_ReturnOtherType() { var target = new SomeTestClass(); // Do not call Func<TR>(), return default(TR) SomeOtherTestClass otherRtn = target.IfNotNull(() => new SomeOtherTestClass()); Assert.IsNotNull(otherRtn); }