Exemplo n.º 1
0
        public void CreateXmlMarkupObjectWithCustomIndent()
        {
            var sb = new StringBuilder();

            dynamic xmlMarkup = new XmlMarkup(ref sb, 5);

            Assert.AreEqual(5, xmlMarkup.Indent);
        }
Exemplo n.º 2
0
        public void CanAssignValueToAnyXmlTagWithWords()
        {
            var sb = new StringBuilder();

            dynamic xmlMarkup = new XmlMarkup(ref sb);
            xmlMarkup.TestTag("TestValue");

            Assert.AreEqual("<TestTag>TestValue</TestTag>", sb.ToString());
        }
Exemplo n.º 3
0
        public void CanAssignAttrubtesToTagByAnonymousObjectWithValue()
        {
            var sb = new StringBuilder();

            dynamic xmlMarkup = new XmlMarkup(ref sb);
            xmlMarkup.TestTag("TestValue", new {firstAttribute = "AttributeValue"});

            Assert.AreEqual("<TestTag firstAttribute=\"AttributeValue\">TestValue</TestTag>", sb.ToString());
        }
Exemplo n.º 4
0
        public void AssigningNoValueToAnyXmlTagCreatesEmptyTag()
        {
            var sb = new StringBuilder();

            dynamic xmlMarkup = new XmlMarkup(ref sb);
            xmlMarkup.TestTag();

            Assert.AreEqual("<TestTag></TestTag>", sb.ToString());
        }
Exemplo n.º 5
0
        public void CallToCommentShouldEncloseGivenTextInComment()
        {
            var sb = new StringBuilder();

            dynamic xmlMarkup = new XmlMarkup(ref sb);
            xmlMarkup.Comment_("This is a comment");

            Assert.AreEqual("<!--This is a comment-->", sb.ToString());
        }
Exemplo n.º 6
0
        public void CreateXmlMarkupObjectWithStringBuilderChangesApplyToBoth()
        {
            var sb = new StringBuilder();

            dynamic xmlMarkup = new XmlMarkup(ref sb);

            sb.Append("Test string");

            Assert.AreEqual(sb, xmlMarkup.Target);
        }
Exemplo n.º 7
0
        public void CanAddNestedTagsWithUsingClause()
        {
            var sb = new StringBuilder();

            dynamic xmlMarkup = new XmlMarkup(ref sb);
            using (xmlMarkup.Family())
            {
                xmlMarkup.Child("Bob");
                xmlMarkup.Child("Tom");
                xmlMarkup.Child("Jerry");
            }

            var lines = sb.ToString().Split(Environment.NewLine.ToCharArray());

            Assert.AreEqual("<Family>", lines[0]);
            Assert.AreEqual("  <Child>Bob</Child>", lines[1]);
            Assert.AreEqual("  <Child>Tom</Child>", lines[2]);
            Assert.AreEqual("  <Child>Jerry</Child>", lines[3]);
            Assert.AreEqual("</Family>", lines[4]);
        }