/// <summary>
        /// Configures a column.
        /// </summary>
        /// <typeparam name="TVal"></typeparam>
        /// <param name="expression">Column property expression.</param>
        /// <returns>Column builder.</returns>
        public MvcCoreBootstrapTableColumnBuilder Column <TVal>(Expression <Func <T, TVal> > expression)
        {
            string       columnProperty = ((MemberExpression)expression.Body).Member.Name;
            ColumnConfig columnConfig   = new ColumnConfig();

            _columnConfigs.Add(columnProperty, columnConfig);

            return(_builderFactory.ColumnBuilder(columnConfig));
        }
예제 #2
0
        public void Column()
        {
            ColumnBuilder configBuilder = new ColumnBuilder(null, null);
            ColumnConfig  config        = null;

            _builderFactory.ColumnBuilder(Arg.Do <ColumnConfig>(c => config = c)).Returns(configBuilder);
            ColumnBuilder builder = _builder.Column(entity => entity.Property);

            _builderFactory.Received(1).ColumnBuilder(Arg.Any <ColumnConfig>());
            _columnConfigs.Should().HaveCount(1);
            _columnConfigs.Should().ContainKey("Property");
            ColumnConfig columnConfig = _columnConfigs["Property"];

            columnConfig.Should().BeSameAs(config);
            columnConfig.Visible.Should().BeTrue();
            columnConfig.SortState.Should().BeNull();
            columnConfig.CssClasses.Should().BeEmpty();
            columnConfig.Header.Should().BeNull();
            columnConfig.Filtering.Should().NotBeNull();
            columnConfig.Filtering.Threshold.Should().Be(0);
            columnConfig.Filtering.CssClasses.Should().BeEmpty();
            builder.Should().BeSameAs(configBuilder);
        }