Esempio n. 1
0
        public void dispatcher_register_and_unregister_test()
        {
            var serverName = "100";

            var dispatcher = new DispatcherFake();

            /************************************************************************/

            /* 订阅
             * 1,输入名字服务serverName=100, 分发器dispatcher存在一个100的项
             *                                                                      */
            /************************************************************************/
            dispatcher.Subscrible(serverName, handle);

            bool isHasServer;

            isHasServer = dispatcher.TryGet(serverName, handle);

            Assert.IsTrue(isHasServer);

            /************************************************************************/

            /* 取消订阅
             * 3,注册名字服务serverName=100, 解除服务100, 分发器的dispatcher内没有刚才注册的服务
             *                                                                      */
            /************************************************************************/
            dispatcher.UnSubscrible(serverName, handle);

            isHasServer = dispatcher.TryGet(serverName, handle);

            Assert.IsTrue(!isHasServer);
        }
Esempio n. 2
0
        public void dispatcher_register_and_unregister_mul_test()
        {
            var _serverName = "100";

            var _dispatcher = new DispatcherFake();

            /************************************************************************/

            /* 订阅
             * 2,输入一个已存在名字服务的serverName=100, 分发器dispatcher的项数量>=2
             *                                                                      */
            /************************************************************************/
            _dispatcher.Subscrible(_serverName, handle);
            _dispatcher.Subscrible(_serverName, handle2);

            bool isHasServer, isHasServer2;

            isHasServer  = _dispatcher.TryGet(_serverName, handle);
            isHasServer2 = _dispatcher.TryGet(_serverName, handle2);

            Assert.IsTrue(isHasServer);
            Assert.IsTrue(isHasServer2);

            Assert.AreEqual(_dispatcher.HandleCount(_serverName), 2);


            /************************************************************************/

            /* 取消订阅
             * 4,解除一个已有多个处理函数的名字服务,不会影响其他的订阅服务。
             *      注册名字服务serverName=100, notification=handle
             *      注册名字服务serverName = 100, notification = handle2
             *      取消名字服务serverName = 100, notification = handle, 名字服务serverName = 100剩余notification=handle2
             *                                                                      */
            /************************************************************************/
            _dispatcher.UnSubscrible(_serverName, handle);

            isHasServer  = _dispatcher.TryGet(_serverName, handle);
            isHasServer2 = _dispatcher.TryGet(_serverName, handle2);

            Assert.IsTrue(!isHasServer);
            Assert.IsTrue(isHasServer2);
        }