public void ToString_Test(object[] input, string expectedValue)
        {
            //Arrange
            var directive = new Directive();

            directive.Name    = "Test";
            directive.Type    = (DirectiveType)input[0];
            directive.Mediums = GetDirectiveMediums();

            if (directive.Type == DirectiveType.Other)
            {
                directive.Expression = GetExpression();
            }

            if (input.Length > 1)
            {
                if ((bool)input[1])
                {
                    SetDirectiveDeclarations_RuleSets_Directives(directive);
                }
            }

            InitializeFakeMethods();

            string result = "";

            //Act
            if (input.Count() > 1)
            {
                if ((bool)input[1])
                {
                    result = directive.ToString(0);
                }
                else
                {
                    result = directive.ToString();
                }
            }
            else
            {
                result = directive.ToString(0);
            }

            //Assert
            Assert.AreEqual(expectedValue, result);
        }
Exemplo n.º 2
0
 public override string ToString(int space)
 {
     if (Label != null)
     {
         return($"{Label}{new string(' ', Math.Max(1, space - Label.Length + 2))}{Directive.ToString()} {Value} {Comment}");
     }
     return($"{new string(' ', space + 2)}{Directive.ToString()} {Value} {Comment}");
 }
Exemplo n.º 3
0
 public override string ToString()
 {
     if (Label != null)
     {
         return($"{Label}\t{Directive.ToString()} {Value} {Comment}");
     }
     return($"{Directive.ToString()} {Value} {Comment}");
 }
Exemplo n.º 4
0
        public void TestDirective(Directive directive)
        {
            var clone = Helpers.ParseDirectives(directive.ToString(), invertNonNull: true).Single();

            Assert.Equal(directive.ToString(), clone.ToString());
        }
Exemplo n.º 5
0
 /// <summary>
 /// Returns the string representation of the underlying syntax, not including its leading and trailing trivia.
 /// </summary>
 /// <returns></returns>
 public override string ToString()
 {
     return(Directive?.ToString() ?? "");
 }
Exemplo n.º 6
0
        public override string ToString()
        {
            string returnString = "";

            returnString += "<Expression " + id.ToString() + ": ";
            returnString += "DIR = " + DIR.ToString() + "; ";
            returnString += "DATA = " + data.ToString() + "; ";
            if (Arguments.Count > 0)
            {
                returnString += "<Arguments: ";
                for (int x = 0; x < Arguments.Count; x++)
                {
                    returnString += "<Argument " + x.ToString() + ": ";
                    for (int y = 0; y < Arguments[x].Count; y++)
                    {
                        returnString += Arguments[x][y].ToString();
                        if (y < Arguments[x].Count - 1)
                        {
                            returnString += ",";
                        }
                    }
                    returnString += ">";
                    if (x < Arguments.Count - 1)
                    {
                        returnString += ",";
                    }
                }
                returnString += ">";
            }
            if (Indices.Count > 0)
            {
                returnString += "<Indices: ";
                for (int x = 0; x < Indices.Count; x++)
                {
                    returnString += "<Index " + x.ToString() + ": ";
                    for (int y = 0; y < Indices[x].Count; y++)
                    {
                        returnString += Indices[x][y].ToString();
                        if (y < Indices[x].Count - 1)
                        {
                            returnString += ",";
                        }
                    }
                    returnString += ">";
                    if (x < Indices.Count - 1)
                    {
                        returnString += ",";
                    }
                }
            }
            if (Nested.Count > 0)
            {
                returnString += "<Nested: ";
                for (int x = 0; x < Nested.Count; x++)
                {
                    returnString += Nested[x].ToString();
                    if (x < Nested.Count - 1)
                    {
                        returnString += ",";
                    }
                }
                returnString += ">";
            }
            return(returnString);
        }