public void GenerateClassFieldsGeneratesProperlyOptionalPropertyDeclaration() { PropertyTS property = Models.Property("property", new PrimaryTypeTS(KnownPrimaryType.String)); CodeModelTS codeModel = new CodeModelTS(); codeModel.Add(property); string fieldsDeclaration = codeModel.GenerateClassProperties(""); Assert.AreEqual("Property?: string;", fieldsDeclaration); }
public void GenerateClassFieldsSkipBaseClassProperties() { PropertyTS stringProperty = Models.Property("property-name", new PrimaryTypeTS(KnownPrimaryType.String)); PropertyTS baseClassProperty = Models.Property("user-agent-info", new PrimaryTypeTS(KnownPrimaryType.String)); CodeModelTS codeModel = new CodeModelTS(); codeModel.Add(stringProperty); codeModel.Add(baseClassProperty); string fieldsDeclaration = codeModel.GenerateClassProperties(""); Assert.AreEqual("PropertyName?: string;", fieldsDeclaration); }
public void GenerateClassFieldsGeneratesProperlyRequiredPropertyDeclaration() { PropertyTS property = Models.Property("property-name", new PrimaryTypeTS(KnownPrimaryType.String)); property.IsRequired = true; CodeModelTS codeModel = new CodeModelTS(); codeModel.Add(property); string fieldsDeclaration = codeModel.GenerateClassProperties(""); Assert.AreEqual("PropertyName: string;", fieldsDeclaration); }
public void GenerateClassFieldsGeneratesMultiplePropertiesDeclaration() { PropertyTS stringProperty = Models.Property("property-name", new PrimaryTypeTS(KnownPrimaryType.String)); PropertyTS boolProperty = Models.Property("is-property", new PrimaryTypeTS(KnownPrimaryType.Boolean)); PropertyTS intProperty = Models.Property("numProperty", new PrimaryTypeTS(KnownPrimaryType.Int)); boolProperty.IsRequired = true; CodeModelTS codeModel = new CodeModelTS(); codeModel.Add(stringProperty); codeModel.Add(boolProperty); codeModel.Add(intProperty); string fieldsDeclaration = codeModel.GenerateClassProperties(""); Assert.AreEqual("PropertyName?: string;\nIsProperty: boolean;\nNumProperty?: number;", fieldsDeclaration); }