Пример #1
0
        public static void TestObjectContainerFromToObject()
        {
            var initialBag = new Eina.Array <Efl.Object>();
            var tmp1       = new Dummy.TestObject();
            var tmp2       = new Dummy.TestObject();
            var tmp3       = new Dummy.TestObject();

            initialBag.Push(tmp1);
            initialBag.Push(tmp2);
            initialBag.Push(tmp3);

            var source = new ComplexHolder {
                BagOfObjects = initialBag
            };
            var prop = source.GetType().GetProperty("BagOfObjects");
            var v    = new Eina.Value(prop.GetValue(source));

            Test.AssertEquals(prop.GetValue(source), initialBag);

            Test.AssertEquals(v.GetValueType(), Eina.ValueType.Array);
            Test.AssertEquals(v.GetValueSubType(), Eina.ValueType.Object);

            Test.AssertEquals(v[0], initialBag[0]);
            Test.AssertEquals(v[1], initialBag[1]);
            Test.AssertEquals(v[2], initialBag[2]);

            var first  = new Dummy.TestObject();
            var second = new Dummy.TestObject();
            var third  = new Dummy.TestObject();

            v[0] = first;
            v[1] = second;
            v[2] = third;

            prop.SetValue(source, v.Unwrap());

            IEnumerable <Efl.Object> newVal = prop.GetValue(source) as IEnumerable <Efl.Object>;
            var toCheck = newVal.ToList();

            Test.AssertEquals(toCheck[0], first);
            Test.AssertEquals(toCheck[1], second);
            Test.AssertEquals(toCheck[2], third);
            tmp3.Dispose();
            tmp2.Dispose();
            tmp1.Dispose();
            v.Dispose();
        }
Пример #2
0
        public static void TestContainerFromToObject()
        {
            var initialBag = new Eina.Array <int>();

            initialBag.Push(2);
            initialBag.Push(4);
            initialBag.Push(6);

            var source = new ComplexHolder {
                Bag = initialBag
            };
            var prop = source.GetType().GetProperty("Bag");
            var v    = new Eina.Value(prop.GetValue(source));

            Test.AssertEquals(prop.GetValue(source), initialBag);

            Test.AssertEquals(v.GetValueType(), Eina.ValueType.Array);
            Test.AssertEquals(v.GetValueSubType(), Eina.ValueType.Int32);

            Test.AssertEquals(v[0], initialBag[0]);
            Test.AssertEquals(v[1], initialBag[1]);
            Test.AssertEquals(v[2], initialBag[2]);

            v[0] = 100;
            v[1] = 200;
            v[2] = 300;

            prop.SetValue(source, v.Unwrap());

            IEnumerable <int> newVal = prop.GetValue(source) as IEnumerable <int>;
            var toCheck = newVal.ToList();

            Test.AssertEquals(toCheck[0], 100);
            Test.AssertEquals(toCheck[1], 200);
            Test.AssertEquals(toCheck[2], 300);
            v.Dispose();
        }
Пример #3
0
        public static void TestIsReadOnly()
        {
            var array = new Eina.Array <int>();

            int[] tmp = { 1, 3, 2, 6, 5 };
            array.Append(tmp);
            Test.AssertEquals(array.Count, 5);
            array.SetOwnership(false);
            Test.AssertRaises <NotSupportedException>(() => array.Add(4));
            Test.AssertRaises <NotSupportedException>(() => array.Push(6));
            Test.AssertRaises <NotSupportedException>(() => array.Append(tmp));
            Test.AssertEquals(array.Count, 5);
            Test.AssertRaises <NotSupportedException>(() => array.DataSet(2, 4));
            Test.Assert(array.ToArray().SequenceEqual(tmp));
        }