Exemple #1
0
 /// <summary>
 /// Writes a typescript enum.
 /// </summary>
 /// <param name="tsEnum"></param>
 public void WriteEnum(TypescriptEnumerable tsEnum)
 {
     syntaxWriter.Write([email protected]() + " " + tsEnum.Name + " ");
     syntaxWriter.WriteOpeningBracket();
     tsEnum.Options.AllButLast().ForEach(value => syntaxWriter.WriteLine(value + ","));
     if (tsEnum.Options.Any())
     {
         syntaxWriter.WriteLine(tsEnum.Options.Last());
     }
     WriteClosingBracket();
 }
Exemple #2
0
        public void TestWritingSimpleEnum()
        {
            var expectedResult =
                @"enum Test {
    value1,
    value2
}
";
            var enumerable = new TypescriptEnumerable
            {
                Name    = "Test",
                Options = new List <string> {
                    "value1", "value2"
                }
            };

            AssertThatWritingEnumGivesTheExpectedResult(expectedResult, enumerable);
        }
Exemple #3
0
        private static void AssertThatWritingEnumGivesTheExpectedResult(string expectedresult, TypescriptEnumerable enumerable)
        {
            var writer = new TypescriptWriter();

            writer.WriteEnum(enumerable);
            var result = writer.ToString();

            result.ShouldBeEquivalentTo(expectedresult);
        }
Exemple #4
0
 private void WriteTypeAnnotation(TypescriptEnumerable tsEnum)
 {
     syntaxWriter.WriteTypeAnnotation(tsEnum.Name);
 }