Exemplo n.º 1
0
        public void TestSimpleProperty()
        {
            var expected =
                @"public TestProperty: TestClass;
";
            var property = new TypescriptProperty
            {
                Name = "TestProperty",
                Type = new TypescriptType(TestData.simpleClass)
            };

            AssertThatWritingPropertyGivesTheExpectedResult(expected, property);
        }
Exemplo n.º 2
0
 /// <summary>
 /// writes a typescript property.
 /// </summary>
 /// <param name="tsProperty">the property to write.</param>
 /// <param name="WriteAccesibilityModifier">whether to write the accesability modifier.</param>
 public void WriteProperty(TypescriptProperty tsProperty, bool WriteAccesibilityModifier = true)
 {
     if (WriteAccesibilityModifier)
     {
         syntaxWriter.Write(tsProperty.Accesability.ToString());
         syntaxWriter.WriteSpace();
     }
     syntaxWriter.Write(tsProperty.Name);
     WriteTypeAnnotation(tsProperty.Type);
     WriteDefaultValue(tsProperty.DefaultValue);
     syntaxWriter.Write(";");
     syntaxWriter.WriteLine();
 }
Exemplo n.º 3
0
        private string FormatProperty(TypescriptProperty property)
        {
            var optionalModifier = property.IsOptional ? "?" : "";

            return($"{property.Name}{optionalModifier}: {property.FormattedType};");
        }
Exemplo n.º 4
0
        private static void AssertThatWritingPropertyGivesTheExpectedResult(string expectedresult, TypescriptProperty tsProperty)
        {
            var writer = new TypescriptWriter();

            writer.WriteProperty(tsProperty);
            var result = writer.ToString();

            result.ShouldBeEquivalentTo(expectedresult);
        }
Exemplo n.º 5
0
 /// <summary>
 /// writes a typescript property with the accesability modifier.
 /// </summary>
 /// <param name="tsProperty">the property to write.</param>
 public void WriteProperty(TypescriptProperty tsProperty)
 {
     WriteProperty(tsProperty, true);
 }