Ejemplo n.º 1
0
        void DualParse(AttributeParser parser, string line)
        {
            Assert.That(parser, Is.Not.Null, "Parser available");

            AttributeDefinition def = parser.ParseLine(line);

            Assert.That(def, Is.Not.Null, "Can parse attribute");

            Assert.That(def.Name, Is.EqualTo("TestDescriptionAttribute"));

            if (parser.SupportsNamespaces)
            {
                Assert.That(def.NamespacePrefix, Is.EqualTo("System.Reflection"));
            }

            Assert.That(def.Arguments.Count, Is.GreaterThanOrEqualTo(4));
            Assert.That(def.NamedArguments.Count, Is.GreaterThanOrEqualTo(2));

            Assert.That(def.Arguments[0], Is.EqualTo("1"));
            Assert.That(def.Arguments[1].Contains("text"));
            Assert.That(def.Arguments[2].Contains("12") && def.Arguments[2].Contains("3"));
            Assert.That(def.Arguments[3].Contains("FileMode") && def.Arguments[3].Contains("Read"));
            Assert.That(def.NamedArguments[0].Name, Is.EqualTo("Number"));
            Assert.That(def.NamedArguments[0].Value, Is.EqualTo("2"));
            Assert.That(def.NamedArguments[1].Name, Is.EqualTo("Value"));
            Assert.That(def.NamedArguments[1].Value.Contains("true"));

            Assert.That(def, Is.Not.Null, "Can parse attribute with parser {0}", parser.GetType().Name);

            string newLine = parser.GenerateAttributeLine(def);

            Assert.That(newLine, Is.Not.Null, "Can regenerate attribute line with parser {0}", parser.GetType().Name);

            AttributeDefinition def2 = parser.ParseLine(newLine);

            Assert.That(def2, Is.Not.Null, "Can parse second time");

            AssertEquals(def, def2);

            def2.Comment = newLine;

            string lineWithComment = parser.GenerateAttributeLine(def2);

            AttributeDefinition def3 = parser.ParseLine(lineWithComment);

            Assert.That(def3, Is.Not.Null, "Can parse with comment");

            string commentItem = def3.Comment;

            Assert.That(commentItem, Is.Not.Null, "Retrieved comment");

            Assert.That(commentItem, Is.EqualTo(newLine));


            //AttributeDefinition def3 = parser.Ge
        }