public void Member_FuncGiven_MemberAddedToSpec() { const string member = "member"; var spec = new TypeSpec(new ExportTsClassAttribute()); var builder = new TypeGen.Core.SpecGeneration.Generic.ClassSpecBuilder <ExportedClass>(spec); builder.Member(x => nameof(x.member)); Assert.True(spec.MemberAttributes.ContainsKey(member)); }
public void Undefined_Invoked_SpecUpdated() { const string member = "member"; var spec = new TypeSpec(new ExportTsClassAttribute()); var builder = new TypeGen.Core.SpecGeneration.Generic.ClassSpecBuilder <ExportedClass>(spec); builder.Member(member).Undefined(); Attribute attribute = spec.MemberAttributes[member].FirstOrDefault(); Assert.IsType <TsUndefinedAttribute>(attribute); }
public void DefaultTypeOutput_Invoked_SpecUpdated() { const string member = "member"; const string outputDir = "outputDir"; var spec = new TypeSpec(new ExportTsClassAttribute()); var builder = new TypeGen.Core.SpecGeneration.Generic.ClassSpecBuilder <ExportedClass>(spec); builder.Member(member).DefaultTypeOutput(outputDir); Attribute attribute = spec.MemberAttributes[member].FirstOrDefault(); Assert.IsType <TsDefaultTypeOutputAttribute>(attribute); Assert.Equal(outputDir, ((TsDefaultTypeOutputAttribute)attribute).OutputDir); }
public void MemberName_Invoked_SpecUpdated() { const string member = "member"; const string name = "name"; var spec = new TypeSpec(new ExportTsClassAttribute()); var builder = new TypeGen.Core.SpecGeneration.Generic.ClassSpecBuilder <ExportedClass>(spec); builder.Member(member).MemberName(name); Attribute attribute = spec.MemberAttributes[member].FirstOrDefault(); Assert.IsType <TsMemberNameAttribute>(attribute); Assert.Equal(name, ((TsMemberNameAttribute)attribute).Name); }
public void Member_AttributesSpecifiedForMember_AttributesAddedToCorrectMember() { const string member1 = "member1"; const string member2 = "member2"; var spec = new TypeSpec(new ExportTsClassAttribute()); var builder = new TypeGen.Core.SpecGeneration.Generic.ClassSpecBuilder <ExportedClass>(spec); builder.Member(member1).Ignore().Member(member2).Null(); Attribute attribute1 = spec.MemberAttributes[member1].FirstOrDefault(); Attribute attribute2 = spec.MemberAttributes[member2].FirstOrDefault(); Assert.IsType <TsIgnoreAttribute>(attribute1); Assert.IsType <TsNullAttribute>(attribute2); }
public void TypeUnions_Invoked_SpecUpdated() { const string member = "member"; string[] typeUnions = { "null", "undefined" }; var spec = new TypeSpec(new ExportTsClassAttribute()); var builder = new TypeGen.Core.SpecGeneration.Generic.ClassSpecBuilder <ExportedClass>(spec); builder.Member(member).TypeUnions(typeUnions); Attribute attribute = spec.MemberAttributes[member].FirstOrDefault(); Assert.IsType <TsTypeUnionsAttribute>(attribute); Assert.Same(typeUnions, ((TsTypeUnionsAttribute)attribute).TypeUnions); }
public void Type_Invoked_SpecUpdated() { const string member = "member"; const string typeName = "typeName"; const string importPath = "importPath"; const string originalTypeName = "originalTypeName"; var spec = new TypeSpec(new ExportTsClassAttribute()); var builder = new TypeGen.Core.SpecGeneration.Generic.ClassSpecBuilder <ExportedClass>(spec); builder.Member(member).Type(typeName, importPath, originalTypeName); Attribute attribute = spec.MemberAttributes[member].FirstOrDefault(); Assert.IsType <TsTypeAttribute>(attribute); Assert.Equal(typeName, ((TsTypeAttribute)attribute).TypeName); Assert.Equal(importPath, ((TsTypeAttribute)attribute).ImportPath); Assert.Equal(originalTypeName, ((TsTypeAttribute)attribute).OriginalTypeName); }