public void When_generate_classes_is_called_then_tag_class_should_be_generated_correctly() { // Arrange var expected = "export class Tag\r\n{\r\n constructor(init?: Partial<Tag>) {\r\n Object.assign(this, init);\r\n }\r\n id: number = 0;\r\n name: string | null = '';\r\n}\r\n\r\n"; var systemUnderTest = new TypeScript() .AddType <Tag>(); // Act string result = systemUnderTest.GenerateClasses(); // Assert Assert.AreEqual(expected, result); }
public void When_generate_classes_is_called_then_type_converter_should_take_null_value_into_account() { // Arrange var expected = "export class Person\r\n{\r\n constructor(init?: Partial<Person>) {\r\n Object.assign(this, init);\r\n }\r\n birthDate: Date | null = null;\r\n fullName: string | null = '';\r\n}\r\n\r\n"; var systemUnderTest = new TypeScript() .AddTypeConverter <DateTime>("Date", "null", true) .AddType <Person>(); // Act string result = systemUnderTest.GenerateClasses(); // Assert Assert.AreEqual(expected, result); }
public void When_generate_classes_is_called_then_simple_product_class_should_be_generated_correctly() { // Arrange var expected = "export class SimpleProduct\r\n{\r\n constructor(init?: Partial<SimpleProduct>) {\r\n Object.assign(this, init);\r\n }\r\n id: number = 0;\r\n name: string | null = '';\r\n status: ProductStatus = ProductStatus.InStock;\r\n}\r\n\r\n"; var systemUnderTest = new TypeScript() .IncludeEnums(false) .AddType <SimpleProduct>(); // Act string result = systemUnderTest.GenerateClasses(); // Assert Assert.AreEqual(expected, result); }
public void When_generate_classes_is_called_then_sort_should_be_correct() { // Arrange var systemUnderTest = new TypeScript() .PreserveInheritance(true) .AddType <TeamAddModel>() .AddType <TeamDeleteModel>() .AddType <TeamDetailModel>() .AddType <TeamIdModel>() .AddType <TeamModelBase>() .AddType <TeamReadModel>() .AddType <TeamsAddModel>() .AddType <TeamUpdateModel>(); // Act string result = systemUnderTest.GenerateClasses(); // Assert Assert.IsNotNull(result); }