コード例 #1
0
        public void AddChildTest()
        {
            var values = new JsonAttribute("chart");
            values.Set(new JsonAttribute("enabled", true));
            string actual = values.ToString();
            string expected = "chart: { enabled: true }";

            HtmlAssert.AreEqual(expected, actual);
        }
コード例 #2
0
        public void AddChildShouldOverrideValue()
        {
            var values = new JsonAttribute("options", false);
            values.Set(new JsonAttribute("enabled", true));
            string actual = values.ToString();
            string expected = "options: { enabled: true }";

            HtmlAssert.AreEqual(expected, actual);
        }
コード例 #3
0
        public void ShouldUseLastChildWhenDuplicated()
        {
            var values = new JsonAttribute("options", false);
            values.Set(new JsonAttribute("enabled", true));
            values.Set(new JsonAttribute("enabled", false));
            string actual = values.ToString();
            string expected = "options: { enabled: false }";

            HtmlAssert.AreEqual(expected, actual);
        }
コード例 #4
0
        public void EmptyKeyWithDuplicatedChild()
        {
            var chart = new JsonAttribute();
            chart.Set(new JsonAttribute("renderTo", "container"));
            chart.Set(new JsonAttribute("renderTo", "new-container"));
            string actual = chart.ToString();
            string expected = "renderTo: 'new-container'";

            HtmlAssert.AreEqual(expected, actual);
        }
コード例 #5
0
        public void EmptyAttributesShouldBeIgnored()
        {
            var values = new JsonAttribute("chart");
            values.Set(new EmptyJsonAttribute());
            string actual = values.ToString();
            string expected = "chart: { }";

            HtmlAssert.AreEqual(expected, actual);
        }
コード例 #6
0
        public void ComplexJsonObjectGraph_WithTwoMainObjects()
        {
            var chart = new JsonAttribute();

            var title = new JsonAttribute("title");
            chart.Set(title);
            title.Set(new JsonAttribute("color", "red"));
            title.Set(new JsonAttribute("size", "16px"));

            var subtitle = new JsonAttribute("subtitle");
            chart.Set(subtitle);
            subtitle.Set(new JsonAttribute("size", "12px"));

            string actual = chart.ToString();
            string expected = @"title: {
                                    color: 'red',
                                    size: '16px'
                                },
                                subtitle: {
                                    size: '12px'
                                }";

            HtmlAssert.AreEqual(expected, actual);
        }