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);
        }
Пример #5
0
 private void Init(string clientName)
 {
     cbManager = new UnmanagedCallbackManager();
     loop      = new GLibMainLoop();
     GC.SuppressFinalize(loop);
     context  = new HandleRef(this, pa_context_new(loop.GetAPI(), clientName));
     notifyCB = ContextNotifyHandler;
     pa_context_set_state_callback(context, notifyCB, new IntPtr(0));
     eventCB = SubscriptionEventHandler;
     pa_context_set_subscribe_callback(context, eventCB, IntPtr.Zero);
 }
        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);
        }
        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());
        }