public void ContextTest01()
        {
            var viewContext = new ViewContext {
                Writer = new StringWriter()
            };
            var context = new KnockoutContext <TestModel>(viewContext);

            using (var subContext = context.With(m => m.SubModel))
            {
                using (var subSubContext = subContext.Foreach(m => m.List))
                {
                    string bind = subSubContext.Bind.Text(m => context.Model.A + subContext.Model.B + m.ToString()).BindingAttributeContent();
                    AssertStringEquivalent("text:$parents[1].A()+$parent.B()+$data", bind);
                }
            }
        }
Exemple #2
0
        public void ContextTest01()
        {
            var viewContext = new ViewContext {
                Writer = new StringWriter()
            };
            var context = new KnockoutContext <TestAttributesModel2>(viewContext);

            using (var subContext = context.With(m => m.SubModel))
            {
                string bind = subContext.Bind.Method("test", m => context.Model.Method).BindingAttributeContent();
                AssertStringEquivalent("test: $parent.method", bind);

                using (var subSubContext = subContext.Foreach(m => m.List))
                {
                    string subBind = subSubContext.Bind.Method("subTest", m => context.Model.Method).BindingAttributeContent();
                    AssertStringEquivalent("subTest:$parents[1].method", subBind);

                    string subBind2 = subSubContext.Bind.Method("subContextTest", m => subContext.Model.Method).BindingAttributeContent();
                    AssertStringEquivalent("subContextTest:$parent.method", subBind2);
                }
            }
        }
        public void ContextTest01()
        {
            var viewContext = new ViewContext { Writer = new StringWriter() };
              var context = new KnockoutContext<TestModel>(viewContext);
              using (var subContext = context.With(m => m.SubModel))
              {
            string bind = subContext.Bind.Text(m => context.Model.A + m.ToString()).BindingAttributeContent();
            AssertStringEquivalent("text:($parent.A()+$data)", bind);

            using (var subSubContext = subContext.Foreach(m => m.List))
            {
              string subBind = subSubContext.Bind.Text(m => context.Model.A + subContext.Model.B + m.ToString()).BindingAttributeContent();
              AssertStringEquivalent("text:(($parents[1].A()+$parent.B())+$data)", subBind);
            }
              }
        }