/// <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(); }
public void TestWritingSimpleEnum() { var expectedResult = @"enum Test { value1, value2 } "; var enumerable = new TypescriptEnumerable { Name = "Test", Options = new List <string> { "value1", "value2" } }; AssertThatWritingEnumGivesTheExpectedResult(expectedResult, enumerable); }
private static void AssertThatWritingEnumGivesTheExpectedResult(string expectedresult, TypescriptEnumerable enumerable) { var writer = new TypescriptWriter(); writer.WriteEnum(enumerable); var result = writer.ToString(); result.ShouldBeEquivalentTo(expectedresult); }
private void WriteTypeAnnotation(TypescriptEnumerable tsEnum) { syntaxWriter.WriteTypeAnnotation(tsEnum.Name); }