예제 #1
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;"
            );
        }
예제 #2
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;"
            );
        }
예제 #3
0
        public void CreatesUsingStatementForJsonReference()
        {
            NamespaceSet namespaces = new NamespaceSet(Symbols, SF.ParseName("MyCurrentNamespace"));

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

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

            AssertUsings
            (
                usings,
                "using Amazon.JSII.Runtime.Deputy;",
                "using Newtonsoft.Json.Linq;"
            );
        }
예제 #4
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;"
            );
        }
예제 #5
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;"
            );
        }
예제 #6
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;"
            );
        }
예제 #7
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;"
            );
        }
예제 #8
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;"
            );
        }