public static void replace_callback() { setup(); test.Testing obj = new test.TestingConcrete(); obj.SetCallback(twice); Test.Assert(called == false, "set_callback should not call the callback"); int x = obj.CallCallback(42); Test.Assert(called, "call_callback must call a callback"); Test.AssertEquals(42 * 2, x); bool new_called = false; obj.SetCallback(y => { new_called = true; return(y * y); }); Test.Assert(new_called == false, "set_callback should not call the callback"); x = obj.CallCallback(42); Test.Assert(new_called, "call_callback must call a callback"); Test.AssertEquals(42 * 42, x); }
public static void set_callback_basic() { setup(); test.Testing obj = new test.TestingConcrete(); obj.SetCallback(twice); Test.Assert(called == false, "set_callback should not call the callback"); int x = obj.CallCallback(42); Test.Assert(called, "call_callback must call a callback"); Test.AssertEquals(42 * 2, x); }
public static void set_callback_with_lambda() { setup(); test.Testing obj = new test.TestingConcrete(); obj.SetCallback(y => { called = true; return(y + 4); }); Test.Assert(called == false, "set_callback should not call the callback"); int x = obj.CallCallback(37); Test.Assert(called, "call_callback must call a callback"); Test.AssertEquals(37 + 4, x); }