コード例 #1
0
        public void Member_Invoked_MemberAddedToSpec()
        {
            const string member  = "member";
            var          spec    = new TypeSpec(new ExportTsInterfaceAttribute());
            var          builder = new TypeGen.Core.SpecGeneration.Generic.InterfaceSpecBuilder <ExportedClass>(spec);

            builder.Member(member);

            Assert.True(spec.MemberAttributes.ContainsKey(member));
        }
コード例 #2
0
        public void IgnoreBase_Invoked_SpecUpdated()
        {
            var spec    = new TypeSpec(new ExportTsInterfaceAttribute());
            var builder = new TypeGen.Core.SpecGeneration.Generic.InterfaceSpecBuilder <ExportedClass>(spec);

            builder.IgnoreBase();

            Attribute attribute = spec.AdditionalAttributes.FirstOrDefault();

            Assert.IsType <TsIgnoreBaseAttribute>(attribute);
        }
コード例 #3
0
        public void DefaultExport_Invoked_SpecUpdated(bool enabled)
        {
            var spec    = new TypeSpec(new ExportTsInterfaceAttribute());
            var builder = new TypeGen.Core.SpecGeneration.Generic.InterfaceSpecBuilder <ExportedClass>(spec);

            builder.DefaultExport(enabled);

            Attribute attribute = spec.AdditionalAttributes.FirstOrDefault();

            Assert.IsType <TsDefaultExportAttribute>(attribute);
            Assert.Equal(enabled, ((TsDefaultExportAttribute)attribute).Enabled);
        }
コード例 #4
0
        public void Undefined_Invoked_SpecUpdated()
        {
            const string member  = "member";
            var          spec    = new TypeSpec(new ExportTsInterfaceAttribute());
            var          builder = new TypeGen.Core.SpecGeneration.Generic.InterfaceSpecBuilder <ExportedClass>(spec);

            builder.Member(member).Undefined();

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

            Assert.IsType <TsUndefinedAttribute>(attribute);
        }
コード例 #5
0
        public void MemberName_Invoked_SpecUpdated()
        {
            const string member  = "member";
            const string name    = "name";
            var          spec    = new TypeSpec(new ExportTsInterfaceAttribute());
            var          builder = new TypeGen.Core.SpecGeneration.Generic.InterfaceSpecBuilder <ExportedClass>(spec);

            builder.Member(member).MemberName(name);

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

            Assert.IsType <TsMemberNameAttribute>(attribute);
            Assert.Equal(name, ((TsMemberNameAttribute)attribute).Name);
        }
コード例 #6
0
        public void DefaultTypeOutput_Invoked_SpecUpdated()
        {
            const string member    = "member";
            const string outputDir = "outputDir";
            var          spec      = new TypeSpec(new ExportTsInterfaceAttribute());
            var          builder   = new TypeGen.Core.SpecGeneration.Generic.InterfaceSpecBuilder <ExportedClass>(spec);

            builder.Member(member).DefaultTypeOutput(outputDir);

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

            Assert.IsType <TsDefaultTypeOutputAttribute>(attribute);
            Assert.Equal(outputDir, ((TsDefaultTypeOutputAttribute)attribute).OutputDir);
        }
コード例 #7
0
        public void Member_AttributesSpecifiedForMember_AttributesAddedToCorrectMember()
        {
            const string member1 = "member1";
            const string member2 = "member2";
            var          spec    = new TypeSpec(new ExportTsInterfaceAttribute());
            var          builder = new TypeGen.Core.SpecGeneration.Generic.InterfaceSpecBuilder <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);
        }
コード例 #8
0
        public void TypeUnions_Invoked_SpecUpdated()
        {
            const string member = "member";

            string[] typeUnions = { "null", "undefined" };
            var      spec       = new TypeSpec(new ExportTsInterfaceAttribute());
            var      builder    = new TypeGen.Core.SpecGeneration.Generic.InterfaceSpecBuilder <ExportedClass>(spec);

            builder.Member(member).TypeUnions(typeUnions);

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

            Assert.IsType <TsTypeUnionsAttribute>(attribute);
            Assert.Same(typeUnions, ((TsTypeUnionsAttribute)attribute).TypeUnions);
        }
コード例 #9
0
        public void CustomBase_Invoked_SpecUpdated()
        {
            const string @base            = "base";
            const string importPath       = "importPath";
            const string originalTypeName = "originalTypeName";
            var          spec             = new TypeSpec(new ExportTsInterfaceAttribute());
            var          builder          = new TypeGen.Core.SpecGeneration.Generic.InterfaceSpecBuilder <ExportedClass>(spec);

            builder.CustomBase(@base, importPath, originalTypeName);

            Attribute attribute = spec.AdditionalAttributes.FirstOrDefault();

            Assert.IsType <TsCustomBaseAttribute>(attribute);
            Assert.Equal(@base, ((TsCustomBaseAttribute)attribute).Base);
            Assert.Equal(importPath, ((TsCustomBaseAttribute)attribute).ImportPath);
            Assert.Equal(originalTypeName, ((TsCustomBaseAttribute)attribute).OriginalTypeName);
        }
コード例 #10
0
        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 ExportTsInterfaceAttribute());
            var          builder          = new TypeGen.Core.SpecGeneration.Generic.InterfaceSpecBuilder <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);
        }