Ejemplo n.º 1
0
        public void t11_Parse_Class_With_Multiple_Fields()
        {
            var tokens = TokenStreamBuilder.Class("className",
                                                  TokenStreamBuilder.CombineTokenStreams(
                                                      TokenStreamBuilder.Field("fieldName", "fieldType"),
                                                      new ClassDiagramTokenStream {
                TokenType.Comma.Token()
            },                                                                                                 // TODO single-token streams.
                                                      TokenStreamBuilder.Field("fieldName2", "fieldType2")
                                                      )
                                                  );

            var classDiagram = new ClassDiagramParser(tokens).ParseClassDiagram();
            var c            = classDiagram.Classes.ToList()[0];

            Assert.IsNotNull(classDiagram, "failed to parse the class");
            Assert.AreEqual("className", c.Name, "name wrong");
            Assert.IsNotNull(c.Fields, "fields MUST NOT be null");
            var l = c.Fields.ToList();

            Assert.AreEqual(2, l.Count, "There should be exactly one field");
            var f = l[0];

            Assert.AreEqual("fieldName", f.Name, "field name wrong");
            Assert.AreEqual("fieldType", f.Type, "field type wrong");
            f = l[1];
            Assert.AreEqual("fieldName2", f.Name, "2nd field name wrong");
            Assert.AreEqual("fieldType2", f.Type, "2nd field type wrong");
        }
Ejemplo n.º 2
0
        public void t11_Parse_Class_With_Field()
        {
            var tokens = TokenStreamBuilder.Class("className", TokenStreamBuilder.Field("fieldName", "fieldType"));

            var classDiagram = new ClassDiagramParser(tokens).ParseClassDiagram();
            var c            = classDiagram.Classes.ToList()[0];

            Assert.IsNotNull(classDiagram, "failed to parse the class");
            Assert.AreEqual("className", c.Name, "name wrong");
            Assert.IsNotNull(c.Fields, "fields MUST NOT be null");
            var l = c.Fields.ToList();

            Assert.AreEqual(1, l.Count, "There should be exactly one field");
            var f = l[0];

            Assert.AreEqual("fieldName", f.Name, "field name wrong");
            Assert.AreEqual("fieldType", f.Type, "field type wrong");
        }