Exemple #1
0
        public void TaskDoesEndOnResolveAndReject()
        {
            bool value       = false;
            bool targetValue = true;

            UnityTask t = new UnityTask();

            t.Then(onEnd: () => value = targetValue);

            t.Resolve(null);

            Assert.AreEqual(value, targetValue);

            value = false;

            t = new UnityTask();
            t.Then(onEnd: () => value = targetValue);

            t.Reject(null);

            Assert.AreEqual(value, targetValue);

            value = false;

            t = new UnityTask();
            t.Then(onEnd: () => value = targetValue);

            t.Notify(0f);

            Assert.AreNotEqual(value, targetValue);
        }
Exemple #2
0
        public void TaskCanOnlyResolveOnce()
        {
            UnityTask t = new UnityTask();

            t.Then((o) => Console.WriteLine("Task Fulfilled"));

            t.Resolve();
            t.Resolve();
        }
Exemple #3
0
        public void TaskCanOnlyRejectOnce()
        {
            UnityTask t = new UnityTask();

            t.Then(null, (o) => Console.WriteLine("Task Failed"));

            t.Reject(new Exception());
            t.Reject(new Exception());
        }
Exemple #4
0
    // Use this for initialization
    void Start()
    {
        var testEngine = new NUnitBasicTestEngine("UnityTools");

        var testTask = new UnityTask((task) => {
            testEngine.RunTests(new TestRunnerCallback(LogString, task));
        });

        testTask.Then(
            onFulfilled: (o) => LogString("All tests succeeded. UnityTools works on this device!"),
            onFailure: (ex) => LogString("Some tests failed. UnityTools does not work on this device.")
            );
    }
Exemple #5
0
        public void TaskDoesResolve()
        {
            object value       = null;
            object targetValue = new object();

            UnityTask t = new UnityTask();

            t.Then((o) => value = o);

            t.Resolve(targetValue);

            Assert.That(value == targetValue);
        }
Exemple #6
0
        public void TaskDoesNotify()
        {
            float value       = 0f;
            float targetValue = 1f;

            UnityTask t = new UnityTask();

            t.Then(null, null, (p) => value = p);

            t.Notify(1f);

            Assert.That(Utils.Math.NearlyEqual(value, targetValue));
        }
Exemple #7
0
        public void TaskDoesFail()
        {
            Exception value       = null;
            Exception targetValue = new Exception();

            UnityTask t = new UnityTask();

            t.Then(null, (ex) => value = ex);

            t.Reject(targetValue);

            Assert.That(value == targetValue);
        }