Esempio n. 1
0
        public Task <bool> Start(ILua lua, GetILuaFromLuaStatePointer lua_extructor, ModuleAssemblyLoadContext _)
        {
            TaskCompletionSource <bool> taskCompletion = new TaskCompletionSource <bool>();

            try
            {
                Random rand = new Random();

                int first  = rand.Next(1, 10000000);
                int second = rand.Next(1, 10000000);
                int third  = rand.Next(1, 10000000);

                lua.PushNumber(first);
                lua.PushNumber(second);
                lua.PushNumber(third);

                lua.Remove(-2);

                int first_received  = (int)lua.GetNumber(-2);
                int second_received = (int)lua.GetNumber(-1);

                lua.Pop(2);

                if (first_received != first || second_received != third)
                {
                    throw new RemoveTestException("Received numbers are invalid");
                }

                taskCompletion.TrySetResult(true);
            }
            catch (Exception e)
            {
                taskCompletion.TrySetException(new Exception[] { e });
            }

            return(taskCompletion.Task);
        }