Exemplo n.º 1
0
        public static void TestEolianEinaValueImplicitOperators()
        {
            var obj     = new Dummy.TestObject();
            int payload = 1999;

            obj.SetValue(payload);

            var expected = new Eina.Value(1999);
            var received = new Eina.Value(Eina.ValueType.String);

            received.Dispose();
            obj.OutValue(out received);
            Test.AssertEquals(expected, received);
            Test.AssertEquals(Eina.ValueType.Int32, received.GetValueType());

            int i = received;

            Test.AssertEquals(i, 1999);

            expected.Dispose();
            expected = new Eina.Value("Hallo");
            obj.SetValue("Hallo");

            obj.OutValue(out received);
            Test.AssertEquals(expected, received);
            Test.AssertEquals(Eina.ValueType.String, received.GetValueType());

            string s = received;

            Test.AssertEquals(s, "Hallo");

            // Casting
            expected.Dispose();
            expected = new Eina.Value((double)15);
            obj.SetValue((double)15);

            received.Dispose();
            obj.OutValue(out received);
            Test.AssertEquals(expected, received);
            Test.AssertEquals(Eina.ValueType.Double, received.GetValueType());

            // Check for 0
            // This is a special value, since C# can silently convert it to an enum
            // leading to collisions with Eina.ValueType
            expected.Dispose();
            expected = new Eina.Value(0);
            obj.SetValue(0);
            received.Dispose();
            obj.OutValue(out received);
            Test.AssertEquals(expected, received);
            Test.AssertEquals(Eina.ValueType.Int32, received.GetValueType());
            expected.Dispose();
            received.Dispose();
            obj.Dispose();
        }
Exemplo n.º 2
0
        public static void TestEolianEinaValueOutByValue()
        {
            var obj = new Dummy.TestObject();

            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.Ownership.Managed, v_out.Ownership);
            }
        }