public void Member_Invoked_MemberAddedToSpec()
        {
            const string member  = "member";
            var          spec    = new TypeSpec(new ExportTsClassAttribute());
            var          builder = new ClassSpecBuilder(spec);

            builder.Member(member);

            Assert.True(spec.MemberAttributes.ContainsKey(member));
        }
        public void Ignore_Invoked_SpecUpdated()
        {
            const string member  = "member";
            var          spec    = new TypeSpec(new ExportTsClassAttribute());
            var          builder = new ClassSpecBuilder(spec);

            builder.Member(member).Ignore();

            Attribute attribute = spec.MemberAttributes[member].FirstOrDefault();

            Assert.IsType <TsIgnoreAttribute>(attribute);
        }
        public void DefaultValue_Invoked_SpecUpdated()
        {
            const string member       = "member";
            const string defaultValue = "defaultValue";
            var          spec         = new TypeSpec(new ExportTsClassAttribute());
            var          builder      = new ClassSpecBuilder(spec);

            builder.Member(member).DefaultValue(defaultValue);

            Attribute attribute = spec.MemberAttributes[member].FirstOrDefault();

            Assert.IsType <TsDefaultValueAttribute>(attribute);
            Assert.Equal(defaultValue, ((TsDefaultValueAttribute)attribute).DefaultValue);
        }
        public void DefaultTypeOutput_Invoked_SpecUpdated()
        {
            const string member    = "member";
            const string outputDir = "outputDir";
            var          spec      = new TypeSpec(new ExportTsClassAttribute());
            var          builder   = new ClassSpecBuilder(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 ClassSpecBuilder(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 ClassSpecBuilder(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);
        }
Exemple #7
0
        public void TypeUnions_Invoked_SpecUpdated()
        {
            const string member = "member";

            string[] typeUnions = { "null", "undefined" };
            var      spec       = new TypeSpec(new ExportTsClassAttribute());
            var      builder    = new ClassSpecBuilder(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 ClassSpecBuilder(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);
        }