Esempio n. 1
0
        public static void Run()
        {
            UClass unrealClass = UClass.GetClass <Test_CollectionsFuncs>();

            Tests.Assert(unrealClass != null, "Test_CollectionsFuncs");

            Test_CollectionsFuncs obj = UObject.NewObject <Test_CollectionsFuncs>();

            RunArrayTests(obj, unrealClass);
            RunSetTests(obj, unrealClass);
            RunMapTest(obj, unrealClass);
        }
Esempio n. 2
0
        private static void RunSetTests(Test_CollectionsFuncs obj, UClass unrealClass)
        {
            var p1 = new HashSet <long>();
            var p2 = new HashSet <UObject>();
            var p3 = new HashSet <Test_SimpleEnum>();
            var p4 = new HashSet <Test_SimpleBlittableStruct>();
            var p5 = new HashSet <TSoftClass <UObject> >();
            var p6 = new HashSet <string>();
            var p7 = new HashSet <FName>();

            Test_CollectionsFuncs.MakeSetTest(p1, p2, p3, p4, p5, p6, p7);

            // Normal
            {
                object[] parameters = { p1, p2, p3, p4, p5, p6, p7 };
                UObject.DynamicInvoke(obj, "SetFunc1", parameters);
            }

            // Ref
            {
                object[] parameters = { p1, p2, p3, p4, p5, p6, p7 };
                UObject.DynamicInvoke(obj, "SetFunc2", parameters);
            }

            // Ref (starting empty)
            {
                p1.Clear();
                p2.Clear();
                p3.Clear();
                p4.Clear();
                p5.Clear();
                p6.Clear();
                p7.Clear();
                object[] parameters = { p1, p2, p3, p4, p5, p6, p7 };
                UObject.DynamicInvoke(obj, "SetFunc3", parameters);
                p1 = (HashSet <long>)parameters[0];
                p2 = (HashSet <UObject>)parameters[1];
                p3 = (HashSet <Test_SimpleEnum>)parameters[2];
                p4 = (HashSet <Test_SimpleBlittableStruct>)parameters[3];
                p5 = (HashSet <TSoftClass <UObject> >)parameters[4];
                p6 = (HashSet <string>)parameters[5];
                p7 = (HashSet <FName>)parameters[6];
                Test_CollectionsFuncs.AssertSetTest(obj, p1, p2, p3, p4, p5, p6, p7);
            }

            // Out
            {
                object[] parameters = { null, null, null, null, null, null, null };
                UObject.DynamicInvoke(obj, "SetFunc4", parameters);
                p1 = (HashSet <long>)parameters[0];
                p2 = (HashSet <UObject>)parameters[1];
                p3 = (HashSet <Test_SimpleEnum>)parameters[2];
                p4 = (HashSet <Test_SimpleBlittableStruct>)parameters[3];
                p5 = (HashSet <TSoftClass <UObject> >)parameters[4];
                p6 = (HashSet <string>)parameters[5];
                p7 = (HashSet <FName>)parameters[6];
                Test_CollectionsFuncs.AssertSetTest(obj, p1, p2, p3, p4, p5, p6, p7);
            }

            // Result
            {
                object[] parameters = { "inStr" };
                var      setResult  = (HashSet <TSoftClass <UObject> >)UObject.DynamicInvoke(obj, "SetFunc5", parameters);
                Tests.Assert(setResult.Contains(TSoftClass <UObject> .Null), unrealClass, "SetFunc5");
                Tests.Assert(setResult.Contains(new TSoftClass <UObject>(Tests.ActorClass)), unrealClass, "SetFunc5");
                Tests.AssertEqual((string)parameters[0], "outStr", unrealClass, "SetFunc5.param1");
            }
        }
Esempio n. 3
0
        private static void RunMapTest(Test_CollectionsFuncs obj, UClass unrealClass)
        {
            var p1 = new Dictionary <long, string>();
            var p2 = new Dictionary <UObject, string>();
            var p3 = new Dictionary <Test_SimpleEnum, string>();
            var p4 = new Dictionary <Test_SimpleBlittableStruct, UObject>();
            var p5 = new Dictionary <TSoftClass <UObject>, TSoftClass <UObject> >();
            var p6 = new Dictionary <string, string>();
            var p7 = new Dictionary <FName, string>();

            Test_CollectionsFuncs.MakeMapTest(p1, p2, p3, p4, p5, p6, p7);

            // Normal
            {
                object[] parameters = { p1, p2, p3, p4, p5, p6, p7 };
                UObject.DynamicInvoke(obj, "MapFunc1", parameters);
            }

            // Ref
            {
                object[] parameters = { p1, p2, p3, p4, p5, p6, p7 };
                UObject.DynamicInvoke(obj, "MapFunc2", parameters);
            }

            // Ref (starting empty)
            {
                p1.Clear();
                p2.Clear();
                p3.Clear();
                p4.Clear();
                p5.Clear();
                p6.Clear();
                p7.Clear();
                object[] parameters = { p1, p2, p3, p4, p5, p6, p7 };
                UObject.DynamicInvoke(obj, "MapFunc3", parameters);
                p1 = (Dictionary <long, string>)parameters[0];
                p2 = (Dictionary <UObject, string>)parameters[1];
                p3 = (Dictionary <Test_SimpleEnum, string>)parameters[2];
                p4 = (Dictionary <Test_SimpleBlittableStruct, UObject>)parameters[3];
                p5 = (Dictionary <TSoftClass <UObject>, TSoftClass <UObject> >)parameters[4];
                p6 = (Dictionary <string, string>)parameters[5];
                p7 = (Dictionary <FName, string>)parameters[6];
                Test_CollectionsFuncs.AssertMapTest(obj, p1, p2, p3, p4, p5, p6, p7);
            }

            // Out
            {
                object[] parameters = { null, null, null, null, null, null, null };
                UObject.DynamicInvoke(obj, "MapFunc4", parameters);
                p1 = (Dictionary <long, string>)parameters[0];
                p2 = (Dictionary <UObject, string>)parameters[1];
                p3 = (Dictionary <Test_SimpleEnum, string>)parameters[2];
                p4 = (Dictionary <Test_SimpleBlittableStruct, UObject>)parameters[3];
                p5 = (Dictionary <TSoftClass <UObject>, TSoftClass <UObject> >)parameters[4];
                p6 = (Dictionary <string, string>)parameters[5];
                p7 = (Dictionary <FName, string>)parameters[6];
                Test_CollectionsFuncs.AssertMapTest(obj, p1, p2, p3, p4, p5, p6, p7);
            }

            // Result
            {
                object[] parameters = { "inStr" };
                var      mapResult  = (Dictionary <TSoftClass <UObject>, TSoftClass <UObject> >)UObject.DynamicInvoke(obj, "MapFunc5", parameters);
                Tests.AssertEqual(mapResult[TSoftClass <UObject> .Null], new TSoftClass <UObject>(Tests.ActorClass), unrealClass, "MapFunc5");
                Tests.AssertEqual(mapResult[new TSoftClass <UObject>(Tests.ActorClass)], TSoftClass <UObject> .Null, unrealClass, "MapFunc5");
                Tests.AssertEqual((string)parameters[0], "outStr", unrealClass, "MapFunc5.param1");
            }
        }