Пример #1
0
        public void CanBindEnums()
        {
            var mvccontext = new MvcContext("http://comdiv/my?theenum=Val1");
            var action     = new ActionWithEnum();
            var binder     = new DefaultActionBinder();

            binder.Bind(new ActionDescriptor(action), mvccontext);
            Assert.AreEqual(MyEnum.Val1, action.MyArgs.TheEnum);
        }
Пример #2
0
        public void CanBindStructureSpecial()
        {
            var mvccontext = new MvcContext("http://comdiv/my?val.a=1&val.b=hello");
            var action     = new ComdivAction();
            var binder     = new DefaultActionBinder();

            binder.Bind(new ActionDescriptor(action), mvccontext);
            Assert.AreEqual(1, action.Param2.A);
            Assert.AreEqual("hello", action.Param2.B);
        }
Пример #3
0
        public void CanBindDictionaryFromJson(string def)
        {
            var mvccontext = new MvcContext(@"http://comdiv/my?Extensions2=" + def);
            var action     = new ComdivAction();
            var binder     = new DefaultActionBinder();

            binder.Bind(new ActionDescriptor(action), mvccontext);
            Assert.AreEqual("1", action.Param.Extensions2["a"]);
            Assert.AreEqual("2", action.Param.Extensions2["b"]);

            mvccontext = new MvcContext(@"http://comdiv/my?Extensions=" + def);
            action     = new ComdivAction();
            binder     = new DefaultActionBinder();
            binder.Bind(new ActionDescriptor(action), mvccontext);
            Assert.AreEqual("1", action.Param.Extensions["a"].ToString());
            Assert.AreEqual("2", action.Param.Extensions["b"].ToString());
        }