Exemple #1
0
        public void CreatesUsingStatementForType()
        {
            EnumType type = new EnumType
                            (
                "myEnumFqn",
                "myModule",
                "myEnum",
                "myNamespace",
                new EnumMember[] { }
                            );

            Symbols.MapNamespace("myNamespace", "MyNamespace");

            NamespaceSet namespaces = new NamespaceSet(Symbols, SF.ParseName("MyCurrentNamespace"));

            namespaces.Add(type);

            SyntaxList <UsingDirectiveSyntax> usings = namespaces.GetUsings();

            AssertUsings
            (
                usings,
                "using Amazon.JSII.Runtime.Deputy;",
                "using MyNamespace;"
            );
        }
Exemple #2
0
        public void DoesNotCreateDuplicateUsingStatements()
        {
            NamespaceSet namespaces = new NamespaceSet(Symbols, SF.ParseName("MyCurrentNamespace"));

            namespaces.Add(new TypeReference(primitive: PrimitiveType.Json));
            namespaces.Add(new TypeReference(primitive: PrimitiveType.Json));

            SyntaxList <UsingDirectiveSyntax> usings = namespaces.GetUsings();

            AssertUsings
            (
                usings,
                "using Amazon.JSII.Runtime.Deputy;",
                "using Newtonsoft.Json.Linq;"
            );
        }
Exemple #3
0
        public void RecursivelyCreatesUsingStatementForEachTypeInUnionReference()
        {
            NamespaceSet namespaces = new NamespaceSet(Symbols, SF.ParseName("MyCurrentNamespace"));

            namespaces.Add(new TypeReference(union: new UnionTypeReference(new TypeReference[] {
                new TypeReference(collection: new CollectionTypeReference(
                                      CollectionKind.Array,
                                      new TypeReference(collection: new CollectionTypeReference(
                                                            CollectionKind.Array,
                                                            new TypeReference(primitive: PrimitiveType.Json)
                                                            ))
                                      )),
                new TypeReference(primitive: PrimitiveType.Date),
            })));

            SyntaxList <UsingDirectiveSyntax> usings = namespaces.GetUsings();

            AssertUsings
            (
                usings,
                "using Amazon.JSII.Runtime.Deputy;",
                "using Newtonsoft.Json.Linq;",
                "using System;"
            );
        }
Exemple #4
0
        public void DoesNotCreateUsingStatementForSystemPrimitive()
        {
            NamespaceSet namespaces = new NamespaceSet(Symbols, SF.ParseName("MyCurrentNamespace"));

            namespaces.Add(new TypeReference(primitive: PrimitiveType.Any));
            namespaces.Add(new TypeReference(primitive: PrimitiveType.Boolean));
            namespaces.Add(new TypeReference(primitive: PrimitiveType.Number));
            namespaces.Add(new TypeReference(primitive: PrimitiveType.String));

            SyntaxList <UsingDirectiveSyntax> usings = namespaces.GetUsings();

            AssertUsings
            (
                usings,
                "using Amazon.JSII.Runtime.Deputy;"
            );
        }
Exemple #5
0
        public void CreatesUsingStatementForDateReference()
        {
            NamespaceSet namespaces = new NamespaceSet(Symbols, SF.ParseName("MyCurrentNamespace"));

            namespaces.Add(new TypeReference(primitive: PrimitiveType.Date));

            SyntaxList <UsingDirectiveSyntax> usings = namespaces.GetUsings();

            AssertUsings
            (
                usings,
                "using Amazon.JSII.Runtime.Deputy;",
                "using System;"
            );
        }
Exemple #6
0
        public void DoesNotCreateUsingStatementForCurrentNamespace()
        {
            Symbols.MapTypeToNamespace("myFqn", "MyCurrentNamespace");

            NamespaceSet namespaces = new NamespaceSet(Symbols, SF.ParseName("MyCurrentNamespace"));

            namespaces.Add(new TypeReference("myFqn"));

            SyntaxList <UsingDirectiveSyntax> usings = namespaces.GetUsings();

            AssertUsings
            (
                usings,
                "using Amazon.JSII.Runtime.Deputy;"
            );
        }
Exemple #7
0
        public void SortsUsingStatementsAlphaNumerically()
        {
            Symbols.MapTypeToNamespace("myFqn", "AAA");

            NamespaceSet namespaces = new NamespaceSet(Symbols, SF.ParseName("MyCurrentNamespace"));

            namespaces.Add(new TypeReference("myFqn"));

            SyntaxList <UsingDirectiveSyntax> usings = namespaces.GetUsings();

            AssertUsings
            (
                usings,
                "using AAA;",
                "using Amazon.JSII.Runtime.Deputy;"
            );
        }
Exemple #8
0
        public void DoesNotCreateUsingStatementForArrayReference()
        {
            NamespaceSet namespaces = new NamespaceSet(Symbols, SF.ParseName("MyCurrentNamespace"));

            namespaces.Add(new TypeReference(collection: new CollectionTypeReference(
                                                 CollectionKind.Array,
                                                 new TypeReference(primitive: PrimitiveType.String)
                                                 )));

            SyntaxList <UsingDirectiveSyntax> usings = namespaces.GetUsings();

            AssertUsings
            (
                usings,
                "using Amazon.JSII.Runtime.Deputy;"
            );
        }
Exemple #9
0
        public void CreatesUsingStatementForMapReference()
        {
            NamespaceSet namespaces = new NamespaceSet(Symbols, SF.ParseName("MyCurrentNamespace"));

            namespaces.Add(new TypeReference(collection: new CollectionTypeReference(
                                                 kind: CollectionKind.Map,
                                                 elementType: new TypeReference(primitive: PrimitiveType.String)
                                                 )));

            SyntaxList <UsingDirectiveSyntax> usings = namespaces.GetUsings();

            AssertUsings
            (
                usings,
                "using Amazon.JSII.Runtime.Deputy;",
                "using System.Collections.Generic;"
            );
        }