Пример #1
0
        public void RenderTests()
        {
            var atRule = new PatternAtRule(new StringValue("name"), new StringValue("selector"));
            var dc = new YateDataContext(new { foo = "bar" });
            atRule.Render(CQ.Create(Helpers.EmptyHtmlString), dc);

            Assert.AreEqual(1, dc.PatternContainer.Count);
        }
Пример #2
0
        public void WholeObjectTest()
        {
            var model = new { foo = "bar" };
            var dc = new YateDataContext(model);

            Assert.AreSame(model, dc.GetValue("."));
            Assert.AreEqual(model, dc.GetValue("."));
        }
Пример #3
0
        public void CanPushValuesAndGetBothObjectsValues()
        {
            var dc = new YateDataContext(new { foo = "bar" });

            dc.PushValue(new { hello = "world" });

            Assert.AreEqual("bar", dc.GetValue("foo"));
            Assert.AreEqual("world", dc.GetValue("hello"));
        }
Пример #4
0
        public void PopingRemovesModels()
        {
            var dc = new YateDataContext(new { foo = "bar" });

            dc.PushValue(new { hello = "world" });

            Assert.AreEqual("bar", dc.GetValue("foo"));
            Assert.AreEqual("world", dc.GetValue("hello"));

            dc.PopValue();

            Assert.AreEqual("bar", dc.GetValue("foo"));
            Assert.AreEqual(null, dc.GetValue("hello"));
        }
        public void RendersWhenModelIsNotCollection()
        {
            var property = new ApplyPatternProperty(new StringValue("name"), new StringValue("model"));

            var html = CQ.Create(Helpers.EmptyHtmlString);
            var context = new YateDataContext(new { not = "used" });
            context.PatternContainer.Add("name", new YatePattern(CQ.CreateFragment(@"<p></p>"),
                                                                 new List<IAtRule> { new IfAtRule(new FalseFunctionValue()) },
                                                                 new List<RuleSet>{
                                                                     new RuleSet(new List<string>{"p"},
                                                                                 new List<IProperty>
                                                                                     {
                                                                                         new TextProperty(new List<IValue>{new ModelFunctionValue(new StringValue("."))})
                                                                                     })}));
            property.Render(html, "body", context);

            Assert.AreEqual(@"<html><head></head><body><p>model</p></body></html>", html.Render());
        }
Пример #6
0
        public void DoesNotExistGivesNull()
        {
            var dc = new YateDataContext(new { foo = "bar" });

            Assert.AreEqual(null, dc.GetValue("yeahBUddy"));
        }
Пример #7
0
        public void DoesItWork()
        {
            var dc = new YateDataContext(new { foo = "bar" });

            Assert.AreEqual("bar", dc.GetValue("foo"));
        }