public void TestSafeCallWithNullInstance() { SomeDemoObject obj = null; Action act = () => obj.SafeCall(sdo => { sdo.Integer = 100; sdo.String = "Hello world"; sdo.Type = "Demo"; }); act.ShouldNotThrow(); }
public void TestSafeCallReturnWithNullInstance() { SomeDemoObject obj = null; string retval = "vrk"; // just initializing to something, we are expecting this to be null after the safecall // implementation returns default(T) when called instance is null, so retval should be null retval = obj.SafeCall(sdo => { return(sdo.ToString()); }); retval.Should().BeNull(); }
public void TestSafeCallReturnCalculation() { SomeDemoObject obj = new SomeDemoObject() { Integer = 9, String = "vrk", Type = "demo" }; int calcResult = obj.SafeCall(sdo => { return(sdo.Integer + 1); }); calcResult.Should().Be(10); }
public void TestSafeCall() { SomeDemoObject obj = new SomeDemoObject() { Integer = 9, String = "vrk", Type = "demo" }; obj.SafeCall(sdo => { sdo.Integer = 100; }); obj.Integer.Should().Be(100); }
public void TestSafeCallReturn() { SomeDemoObject obj = new SomeDemoObject() { Integer = 9, String = "vrk", Type = "demo" }; string str = obj.ToString(); string strB = obj.SafeCall(sdo => { return(sdo.ToString()); }); strB.Should().Be(str); }