public void TopLevelList_ReturnsNull()
        {
            // Arrange
            var field = Substitute.For <ISymbol>();
            var type  = new ListTypeBuilder()
                        .SetParent(field)
                        .Build();

            // Act
            var nestingDepth = type.NestingDepth;

            // Assert
            Assert.Null(nestingDepth);
        }
        public void ListIsNested_ReturnsOne()
        {
            // Arrange
            var parent = Substitute.For <IListType>();
            var type   = new ListTypeBuilder()
                         .SetParent(parent)
                         .Build();

            // Act
            var nestingDepth = type.NestingDepth;

            // Assert
            Assert.Equal(1, nestingDepth);
        }
        protected override (IParseTree elementNode, ICollectionType collectionType) ParseInput(string input)
        {
            var node = ParserInput
                       .FromString(input)
                       .ParseInput(parser => parser.listType());

            var listType = new ListTypeBuilder()
                           .SetNode(node)
                           .SetParent(this.Field)
                           .SetBinderProvider(this.BinderProvider)
                           .Build();

            return(node.fieldType(), listType);
        }
        public void MixtureOfNestedTypes_ReturnsNestingLevel()
        {
            // Arrange
            // Simulate list<set<list<T>>>
            var field = Substitute.For <IField>();
            var type  = new ListTypeBuilder()                       // list<>
                        .SetParent(new SetTypeBuilder()             // set<list<>>
                                   .SetParent(new ListTypeBuilder() // list<set<list<>>>
                                              .SetParent(field)
                                              .Build())
                                   .Build())
                        .Build();

            // Act
            var nestingDepth = type.NestingDepth;

            // Assert
            Assert.Equal(2, nestingDepth);
        }
        public void ListIsNestedMultipleLevelsDeep_ReturnsNestingLevel()
        {
            // Arrange
            // Simulate List<List<List<T>>>
            var field = Substitute.For <IField>();
            var type  = new ListTypeBuilder()                       // List<>
                        .SetParent(new ListTypeBuilder()            // List<List<>>
                                   .SetParent(new ListTypeBuilder() // List<List<List<>>>
                                              .SetParent(field)
                                              .Build())
                                   .Build())
                        .Build();

            // Act
            var nestingDepth = type.NestingDepth;

            // Assert
            Assert.Equal(2, nestingDepth);
        }