Beispiel #1
0
        public void NonPublicClassTest()
        {
            GeneratorHelper.AssertEqual(@"
class Foo {}
", @"
");
        }
Beispiel #2
0
        public void EmptyEnumeTest()
        {
            GeneratorHelper.AssertEqual(@"
public enum Foo {}
", @"
export enum Foo {}
");
        }
Beispiel #3
0
        public void SimpleClassTest()
        {
            GeneratorHelper.AssertEqual(@"
public class Foo {}
", @"
export class Foo {}
");
        }
Beispiel #4
0
        public void ClassToInterfaceTest()
        {
            GeneratorHelper.AssertEqual(@"
public class Foo {}
", @"
export interface Foo {}
", options => options.ConvertClassesToInterfaces = true);
        }
Beispiel #5
0
        public void EmptyEnumeTest()
        {
            GeneratorHelper.AssertEqual(@"
public enum Foo {}
", @"
export const enum Foo {}
", options => options.MakeEnumConst = true);
        }
Beispiel #6
0
        public void ClassWithNamespaceTest()
        {
            GeneratorHelper.AssertEqual(@"
namespace Baz {
	public class Foo {}
}
", @"
export class Foo {}
");
        }
Beispiel #7
0
        public void ClassAttributeTest()
        {
            GeneratorHelper.AssertEqual(@"
[MyAttribute()]
public class Foo {}
", @"
// MyAttribute()
export class Foo {}
");
        }
Beispiel #8
0
        public void PropertyWithSetterTest()
        {
            GeneratorHelper.AssertEqual(@"
public class Foo {
	public MyType MyProperty { set { } }
}
", @"
export class Foo {
}
");
        }
Beispiel #9
0
        public void StaticPropertyTest()
        {
            GeneratorHelper.AssertEqual(@"
public class Foo {
	public static MyType MyProperty { get; }
}
", @"
export class Foo {
}
");
        }
Beispiel #10
0
        public void PropertyWithPrivateGetterTest()
        {
            GeneratorHelper.AssertEqual(@"
public class Foo {
	public MyType MyProperty { private get; }
}
", @"
export class Foo {
}
");
        }
Beispiel #11
0
        public void PropertyToCamelCaseTest()
        {
            GeneratorHelper.AssertEqual(@"
public class Foo {
	public MyType MyProperty { get; set; }
}
", @"
export class Foo {
	public myProperty: MyType;
}
", options => options.ConvertFieldsToCamelCase = true);
        }
Beispiel #12
0
        public void EnumWithMembersWithImplicitValuesTest()
        {
            GeneratorHelper.AssertEqual(@"
public enum Foo {
	Value1, Value2
}
", @"
export enum Foo {
	Value1, Value2,
}
");
        }
Beispiel #13
0
        public void PropertyWithGetterTest()
        {
            GeneratorHelper.AssertEqual(@"
public class Foo {
	public MyType MyProperty { get; }
}
", @"
export class Foo {
	public MyProperty: MyType;
}
");
        }
Beispiel #14
0
        private static void AssertType(string csharpType, string typescriptType)
        {
            GeneratorHelper.AssertEqual(@"
public class Foo {
	public "     + csharpType + @" Bar { get; }
}
", @"
export class Foo
		{
			public Bar: "             + typescriptType + @";
}
");
        }
Beispiel #15
0
        public void CustomTypePrefixTest()
        {
            GeneratorHelper.AssertEqual(@"
public class Foo {
	public Foo Property1 { get; }
	public Bar Property2 { get; }
}
", @"
export class IFoo {
	public Property1: IFoo;
	public Property2: Bar;
}
", options => options.CustomTypePrefix = "I");
        }
Beispiel #16
0
        public void PropertyAttributeTest()
        {
            GeneratorHelper.AssertEqual(@"
public class Foo {
	[MyAttribute()]
	public int Bar { get; }
}
", @"
export class Foo {
	// MyAttribute()
	public Bar: number;
}
");
        }
Beispiel #17
0
        public void ClassCommentTest()
        {
            GeneratorHelper.AssertEqual(@"
/// <summary>
/// This a XML documentation comment.
/// </summary>
public class Foo {}
", @"
/**
* <summary>
* This a XML documentation comment.
* </summary>
*/
export class Foo {}
");
        }
Beispiel #18
0
        public void CustomTypePrefixWithPartialClassTest()
        {
            GeneratorHelper.AssertEqual(@"
public partial class Foo {
	public Foo Property1 { get; }
}

public partial class Foo {
	public Foo Property2 { get; }
}
", @"
export class IFoo {
	public Property1: IFoo;
	public Property2: IFoo;
}
", options => options.CustomTypePrefix = "I");
        }
Beispiel #19
0
        public void PartialClassTest()
        {
            GeneratorHelper.AssertEqual(@"
public partial class Foo {
	public string Prop1 { get; }
}

public partial class Foo {
	public string Prop2 { get; }
}
", @"
export class Foo {
	public Prop1: string;
	public Prop2: string;
}
");
        }
Beispiel #20
0
        public void PropertyCommentTest()
        {
            GeneratorHelper.AssertEqual(@"
public class Foo {
	/// <summary>
	/// This a XML documentation comment.
	/// </summary>
	public int Bar { get; }
}
", @"
export class Foo {
	/**
	* <summary>
	* This a XML documentation comment.
	* </summary>
	*/
	public Bar: number;
}
");
        }
 public void SyntaxErrorTest()
 {
     GeneratorHelper.AssertEqual("class Foo {", "");
 }