Exemple #1
0
        public void MainThreadDeallocationTest()
        {
            ObjCBlockTester.CallAssertMainThreadBlockRelease((callback) => {
                callback(42);
            });

            using (var main_thread_tester = new MainThreadTest()) {
                main_thread_tester.CallAssertMainThreadBlockReleaseCallback();
            }
        }
Exemple #2
0
 public static int Int(int min, int max)
 {
     if (MainThreadTest.OnMainThread())
     {
         return(UnityEngine.Random.Range(min, max));
     }
     else
     {
         return(random.Next(min, max));
     }
 }
Exemple #3
0
 public static bool Bool()
 {
     if (MainThreadTest.OnMainThread())
     {
         return(UnityEngine.Random.Range(0, 2) == 0);
     }
     else
     {
         return(random.Next(0, 2) == 0);
     }
 }
Exemple #4
0
 public static float Float(float min, float max)
 {
     if (MainThreadTest.OnMainThread())
     {
         return(UnityEngine.Random.Range(min, max));
     }
     else
     {
         return((float)((random.NextDouble() * (max - min)) + min));
     }
 }
Exemple #5
0
        public void MainThreadDeallocationTestQOS()
        {
#if OPTIMIZEALL
            if (!TestRuntime.IsLinkAll)
            {
                Assert.Ignore("This test must be processed by the linker if all optimizations are turned on.");
            }
#endif

            ObjCBlockTester.CallAssertMainThreadBlockReleaseQOS((callback) => {
                callback(42);
            });

            using (var main_thread_tester = new MainThreadTest()) {
                main_thread_tester.CallAssertMainThreadBlockReleaseCallbackQOS();
            }
        }
Exemple #6
0
    public static T EnumValue <T>() where T : struct, IConvertible
    {
        if (!typeof(T).IsEnum)
        {
            throw new ArgumentException("T must be an enumerated type.");
        }
        var values = Enum.GetValues(typeof(T));

        if (MainThreadTest.OnMainThread())
        {
            return((T)values.GetValue(UnityEngine.Random.Range(0, values.Length)));
        }
        else
        {
            return((T)values.GetValue(random.Next(values.Length)));
        }
    }