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); }
/* The managed call is free to own the returned string */ public static void return_own_string() { { test.Testing obj = new test.TestingConcrete(); Test.AssertEquals("own_string", obj.ReturnOwnString()); } System.GC.Collect(); }
public static void name_getset() { test.Testing obj = new test.TestingConcrete(); string name = "Dummy"; obj.SetName(name); Test.AssertEquals(name, obj.GetName()); }
/* The managed call is the owner of the string in the out parameter */ public static void out_own_string() { { String str = String.Empty; test.Testing obj = new test.TestingConcrete(); obj.OutOwnString(out str); Test.AssertEquals(str.ToString(), "out_own_string"); } System.GC.Collect(); }
public static void out_stringshare() { { String str = String.Empty; test.Testing obj = new test.TestingConcrete(); obj.OutStringshare(out str); Test.AssertEquals("out_stringshare", str); } System.GC.Collect(); }
// // Test cases: // public static void return_same_object() { test.Testing testing = new test.TestingConcrete(); test.Testing o1 = testing.ReturnObject(); Test.Assert(o1.raw_handle != IntPtr.Zero); Test.Assert(o1.raw_handle == testing.raw_handle); test.Testing o2 = o1.ReturnObject(); Test.Assert(o2.raw_handle != IntPtr.Zero); Test.Assert(o2.raw_handle == o1.raw_handle); }
public static void basic_parent() { test.Testing parent = new test.TestingConcrete(null); test.Testing child = new test.TestingConcrete(parent); Test.AssertEquals(parent, child.GetParent()); test.Testing parent_retrieved = test.TestingConcrete.static_cast(child.GetParent()); Test.AssertEquals(parent, parent_retrieved); }
public static void parent_inherited_class() { test.Numberwrapper parent = new test.NumberwrapperConcrete(null); test.Testing child = new test.TestingConcrete(parent); Test.AssertEquals(parent, child.GetParent()); test.Numberwrapper parent_retrieved = test.NumberwrapperConcrete.static_cast(child.GetParent()); Test.AssertEquals(parent, parent_retrieved); }
/* The managed call is still owner of the sent string */ public static void in_string() { { test.Testing obj = new test.TestingConcrete(); String sent = "in_string"; String returned = obj.InString(sent); Test.AssertEquals(sent, returned); } System.GC.Collect(); }
/* Commented out as adding the event listener seems to prevent it from being GC'd. * public static void destructor_really_frees() * { * bool delEventCalled = false; * { * test.Testing obj = new test.TestingConcrete(); * obj.DEL += (object sender, EventArgs e) => { delEventCalled = true; }; * } * * System.GC.WaitForPendingFinalizers(); * System.GC.Collect(); * System.GC.WaitForPendingFinalizers(); * System.GC.Collect(); * System.GC.WaitForPendingFinalizers(); * * Test.Assert(delEventCalled, "DEL event not called"); * } */ public static void dispose_really_frees() { bool delEventCalled = false; { test.Testing obj = new test.TestingConcrete(); obj.DEL += (object sender, EventArgs e) => { delEventCalled = true; }; ((IDisposable)obj).Dispose(); } Test.Assert(delEventCalled, "DEL event not called"); }
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 constructing_method() { bool called = false; string name = "Test object"; test.Testing obj = new test.TestingConcrete(null, (test.Testing a) => { called = true; Console.WriteLine("callback: obj raw_handle: {0:x}", a.raw_handle); a.SetName(name); }); Test.Assert(called); Test.AssertEquals(name, obj.GetName()); }
public static void TestEolianEinaValueInReturn() { test.Testing obj = new test.TestingConcrete(); using (eina.Value v = new eina.Value(eina.ValueType.Int32)) { v.Set(42); obj.SetValuePtr(v); Test.AssertEquals(eina.ValueOwnership.Managed, v.Ownership); eina.Value v_received = obj.GetValuePtrOwn(); Test.AssertEquals(eina.ValueOwnership.Managed, v_received.Ownership); Test.AssertEquals(v, v_received); v_received.Dispose(); } }
public static void TestEolianEinaValueOutByValue() { test.Testing obj = new test.TestingConcrete(); using (eina.Value v = new eina.Value(eina.ValueType.String)) { eina.Value v_out = null; v.Set("hello!"); obj.SetValue(v); obj.OutValue(out v_out); Test.AssertEquals(v, v_out); Test.AssertEquals(eina.ValueOwnership.Managed, v_out.Ownership); } }
// return eina_error public static void eina_error_return() { test.Testing obj = new test.TestingConcrete(); eina.Error expected = 42; obj.SetErrorRet(expected); eina.Error error = obj.ReturnsError(); Test.AssertEquals(expected, error); expected = 0; obj.SetErrorRet(expected); error = obj.ReturnsError(); Test.AssertEquals(expected, error); }
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); }
public static void global_eina_error() { test.Testing obj = new test.TestingConcrete(); Test.AssertRaises <efl.EflException>(() => obj.RaisesEinaError()); }