public void AddingSecondCallbackSucceeds()
        {
            UnmanagedCallbackManager manager = new UnmanagedCallbackManager();

            manager.AddDelegate(() => {}, manager.NewCookie());
            manager.AddDelegate(() => {}, manager.NewCookie());
        }
        public void AddingCallbackIncreasesPendingCount()
        {
            UnmanagedCallbackManager manager = new UnmanagedCallbackManager();

            int oldCallbackCount = manager.PendingCallbackCount;

            manager.AddDelegate(() => {}, manager.NewCookie());
            Assert.Greater(manager.PendingCallbackCount, oldCallbackCount);
        }
        public void AddingTwoCallbacksWithTheSameCookieIsAnError()
        {
            UnmanagedCallbackManager manager = new UnmanagedCallbackManager();

            int cookie = manager.NewCookie();

            manager.AddDelegate(() => {}, cookie);
            manager.AddDelegate(() => {}, cookie);
        }
        public void RemovingCallbackTwiceIsAnError()
        {
            UnmanagedCallbackManager manager = new UnmanagedCallbackManager();

            int cookie = manager.NewCookie();

            manager.AddDelegate(() => {}, cookie);
            manager.RemoveDelegate(cookie);
            manager.RemoveDelegate(cookie);
        }
        public void RemovingCallbackDecreasesPendingCount()
        {
            UnmanagedCallbackManager manager = new UnmanagedCallbackManager();

            int cookie = manager.NewCookie();

            manager.AddDelegate(() => {}, cookie);
            int oldCallbackCount = manager.PendingCallbackCount;

            manager.RemoveDelegate(cookie);
            Assert.Less(manager.PendingCallbackCount, oldCallbackCount);
        }
Beispiel #6
0
        public Operation EnumerateSinkInputs(SinkInputCallback cb)
        {
            int cookie = cbManager.NewCookie();
            Action <IntPtr, NativeSinkInputInfo, int, IntPtr> wrapped_cb = (IntPtr c, NativeSinkInputInfo info, int eol, IntPtr userdata) =>
            {
                if (eol == 0)
                {
                    cb(new SinkInput(info, this), eol);
                }
                else
                {
                    cbManager.RemoveDelegate(cookie);
                }
            };

            cbManager.AddDelegate(wrapped_cb, cookie);
            return(new Operation(pa_context_get_sink_input_info_list(context, wrapped_cb, IntPtr.Zero)));
        }
        public void CanAddMethodDelegate()
        {
            UnmanagedCallbackManager manager = new UnmanagedCallbackManager();

            manager.AddDelegate(CanAddMethodDelegate, manager.NewCookie());
        }
        public void SuccessiveCookieCallsReturnDifferentCookies()
        {
            UnmanagedCallbackManager manager = new UnmanagedCallbackManager();

            Assert.AreNotEqual(manager.NewCookie(), manager.NewCookie());
        }
        public void CanAddFourParameterCallback()
        {
            UnmanagedCallbackManager manager = new UnmanagedCallbackManager();

            manager.AddDelegate((int a, IntPtr b, Context c, Sink d) => {}, manager.NewCookie());
        }