Example #1
0
        public void MulipleMessageBind()
        {
            var res = 0;
            MessageBindDelegate <string> bindAction  = s => { res |= 1; };
            MessageBindDelegate <string> bindAction2 = s => { res |= 2; };

            var binder = new MessageBinder();

            Is.False.ApplyTo(binder.AnyBind("message"));

            binder.Bind <string>("message", bindAction);
            binder.Bind <string>("message1", bindAction2);

            Is.True.ApplyTo(binder.AnyBind("message"));
            Is.Not.Null.ApplyTo(binder.GetBinds("message"));

            Is.True.ApplyTo(binder.AnyBind("message1"));
            Is.Not.Null.ApplyTo(binder.GetBinds("message1"));

            Assert.AreEqual(1, binder.GetBinds("message").Count);
            Assert.AreEqual(1, binder.GetBinds("message1").Count);

            binder.GetBinds("message").First().BindAction(null);
            binder.GetBinds("message1").First().BindAction(null);

            Assert.AreEqual(3, res);
        }
Example #2
0
        static void Main(string[] args)
        {
            MessageBinder.Bind(typeof(SayHiAdapter).Assembly);
            new NettyNetwork(6666).ListenAsync().Wait();

            Console.ReadKey();
        }
Example #3
0
        static void Main(string[] args)
        {
            MessageBinder.Bind(typeof(PingPongAdapter).Assembly);

            Server.ListenAsync().Wait();
            Client.ConnectAsync().Wait();

            PingPong();

            Console.ReadKey();
        }
Example #4
0
        public void MulipleHandlerBind()
        {
            var res = 0;
            MessageBindDelegate <string> bindAction  = s => { res |= 1; };
            MessageBindDelegate <string> bindAction2 = s => { res |= 2; };
            var binder = new MessageBinder();

            Is.False.ApplyTo(binder.AnyBind("message"));

            binder.Bind <string>("message", bindAction);
            binder.Bind <string>("message", bindAction2);

            Is.True.ApplyTo(binder.AnyBind("message"));
            Is.Not.Null.ApplyTo(binder.GetBinds("message"));

            Assert.AreEqual(2, binder.GetBinds("message").Count);

            foreach (var messageBindDelegate in binder.GetBinds("message"))
            {
                messageBindDelegate.BindAction(null);
            }

            Assert.AreEqual(3, res);
        }
Example #5
0
        public void ClassNamedAttributeBind()
        {
            var isCall = false;
            MessageBindDelegate <Foo> bindAction = s => isCall = true;;

            var binder = new MessageBinder();

            Is.False.ApplyTo(binder.AnyBind("foo"));

            binder.Bind(bindAction);

            Is.True.ApplyTo(binder.AnyBind("foo"));
            Is.Not.Null.ApplyTo(binder.GetBinds("foo"));

            Assert.AreEqual(1, binder.GetBinds("foo").Count);

            binder.GetBinds("foo")[0].BindAction(null);

            Assert.True(isCall);
        }
Example #6
0
        public void ClassNamedBind()
        {
            var isCall = false;
            MessageBindDelegate <string> bindAction = s => isCall = true;;

            var binder = new MessageBinder();

            Is.False.ApplyTo(binder.AnyBind(typeof(string).FullName));

            binder.Bind <string>(bindAction);

            Is.True.ApplyTo(binder.AnyBind(typeof(string).FullName));
            Is.Not.Null.ApplyTo(binder.GetBinds(typeof(string).FullName));

            Assert.AreEqual(1, binder.GetBinds(typeof(string).FullName).Count);

            binder.GetBinds(typeof(string).FullName)[0].BindAction(null);

            Assert.True(isCall);
        }
        public void MessageBinder_Throws_On_Null_Message()
        {
            Action a = () => MessageBinder.Bind(Saml2Binding.Get(Saml2BindingType.HttpPost), null);

            a.ShouldThrow <ArgumentNullException>().And.ParamName.Should().Be("message");
        }
        public void MessageBinder_Throws_On_Null_Binder()
        {
            Action a = () => MessageBinder.Bind(null, new Saml2AuthenticationRequest());

            a.ShouldThrow <ArgumentNullException>().And.ParamName.Should().Be("binding");
        }