Exemplo n.º 1
0
        public void XmlStatement_Nested()
        {
            // Arrange
            ExpectedStatement expInnerStmt = new ExpectedStatement();

            expInnerStmt.Keyword       = ReservedWords.Keywords.DataTypes.Int;
            expInnerStmt.Type          = StatementType.FileObjectDefinition;
            expInnerStmt.HasParameters = false;
            expInnerStmt.HasNested     = false;

            ExpectedStatement expOuterStmt = new ExpectedStatement();

            expOuterStmt.Keyword       = ReservedWords.Keywords.DataTypes.Struct;
            expOuterStmt.Type          = StatementType.FileObjectDefinition;
            expOuterStmt.HasParameters = false;
            expOuterStmt.HasNested     = true;
            expOuterStmt.Nested.Add(expInnerStmt);

            // <struct><int/></struct>
            string testInnerXml = BuildXmlElement(expInnerStmt.Keyword);
            string testOuterXml = BuildXmlElement(expOuterStmt.Keyword, testInnerXml);

            // Act
            XmlStatement testStmt = XmlStatement.Parse(XElement.Parse(testOuterXml));

            // Assert
            StatementAssertEqual(expOuterStmt, testStmt);
        }
Exemplo n.º 2
0
 private void StatementAssertEqual(ExpectedStatement expected, Statement actual)
 {
     Assert.Equal(expected.Keyword, actual.Keyword);
     Assert.Equal(expected.Type, actual.StatementType);
     Assert.Equal(expected.HasParameters, actual.HasParameters);
     Assert.Equal(expected.HasNested, actual.HasNestedStatements);
     Assert.Equal(expected.Parameters, actual.Parameters);
     Assert.Equal(expected.Nested.Count(), actual.NestedStatements.Count());
     for (int i = 0; i < expected.Nested.Count(); i++)
     {
         StatementAssertEqual(expected.Nested.ElementAt(i), actual.NestedStatements.ElementAt(i));
     }
 }
Exemplo n.º 3
0
        public void XmlStatement_Directive()
        {
            // Arrange
            ExpectedStatement expStmt = new ExpectedStatement();

            expStmt.Keyword       = ReservedWords.Keywords.Directives.Typedef;
            expStmt.Type          = StatementType.Directive;
            expStmt.HasParameters = false;
            expStmt.HasNested     = false;

            string testXml = BuildXmlElement(expStmt.Keyword);

            // Act
            XmlStatement testStmt = XmlStatement.Parse(XElement.Parse(testXml));

            // Assert
            StatementAssertEqual(expStmt, testStmt);
        }
Exemplo n.º 4
0
        public void XmlStatement_FileObject()
        {
            // Arrange
            ExpectedStatement expStmt = new ExpectedStatement();

            expStmt.Keyword       = ReservedWords.Keywords.DataTypes.Int;
            expStmt.Type          = StatementType.FileObjectDefinition;
            expStmt.HasParameters = false;
            expStmt.HasNested     = false;

            string testXml = BuildXmlElement(expStmt.Keyword);

            // Act
            XmlStatement testStmt = XmlStatement.Parse(XElement.Parse(testXml));

            // Assert
            StatementAssertEqual(expStmt, testStmt);
        }
Exemplo n.º 5
0
        public void XmlStatement_WithParameters()
        {
            // Arrange
            Tuple <string, string>[] expParams = new Tuple <string, string>[]
            {
                new Tuple <string, string>("name", "Foo"),
                new Tuple <string, string>("count", "4")
            };
            ExpectedStatement expStmt = new ExpectedStatement(expParams);

            expStmt.Keyword       = ReservedWords.Keywords.DataTypes.Int;
            expStmt.Type          = StatementType.FileObjectDefinition;
            expStmt.HasParameters = true;
            expStmt.HasNested     = false;

            string testXml = BuildXmlElement(expStmt.Keyword, expParams);

            // Act
            XmlStatement testStmt = XmlStatement.Parse(XElement.Parse(testXml));

            // Assert
            StatementAssertEqual(expStmt, testStmt);
        }