Exemplo n.º 1
0
 public static bool IsProperType(this Spec spec, string target, string resolvedType) =>
 (
     (target == Constants.CSharpTarget && CSharpFacts.IsNativeType(resolvedType)) ||
     (target == Constants.TypeScriptTarget && TypeScriptFacts.IsNativeType(resolvedType))
 ) ||
 spec.IsEntity(resolvedType) ||
 spec.IsEnum(resolvedType);
        public static TypeScriptClassMember GenerateEntityMember(Spec spec, KeyValuePair <string, IEntityMemberInfo> member)
        {
            var resolvedType         = spec.GetResolvedType(Constants.TypeScriptTarget, member.Value.Type);
            var normalizedType       = TypeScriptFacts.IsNativeType(resolvedType) ? resolvedType : SpecFunctions.ToPascalCase(resolvedType);
            var normalizedMemberName = SpecFunctions.ToCamelCase(member.Key);

            if (member.Value.IsCollection)
            {
                normalizedType += "[]";
            }

            return(new TypeScriptClassMember {
                Name = normalizedMemberName, Type = normalizedType
            });
        }
Exemplo n.º 3
0
        public void TestAmmendmentFillAllNativeTypes()
        {
            // arrange
            // nothing to do

            // act
            var nativeTypes = TypeScriptFacts.GetNativeTypes().ToList();

            // assert
            Assert.True(nativeTypes.Remove("boolean"));
            Assert.True(nativeTypes.Remove("number"));
            Assert.True(nativeTypes.Remove("string"));
            Assert.True(nativeTypes.Remove("Date"));
            Assert.True(nativeTypes.Remove("any"));
            Assert.True(nativeTypes.Count == 0, "Additional Native types present than those that were tested. Adjust your unit test.");
        }