Exemple #1
0
        /// <summary>
        /// 获取标签生成器
        /// </summary>
        protected override TagBuilder GetTagBuilder()
        {
            var builder = new ColumnBuilder();

            Config(builder);
            return(builder);
        }
        public void TestAddShouldAddColumn()
        {
            var column = new ColumnBuilder().Build();

            _repository.Add(column);
            Assert.That(_columns.Single(), Is.EqualTo(column));
        }
Exemple #3
0
        public void TestCreateRootShouldCreateStringFilterTreeRoot()
        {
            var column = new ColumnBuilder().WithDataType(typeof(String)).Build();
            var result = _factory.CreateRoot(column);

            Assert.That(result is StringFilterTreeRoot);
        }
Exemple #4
0
        public void TestSetDragDropLayoutShouldExecuteAutoAssignLayoutCommand()
        {
            var column = new ColumnBuilder().WithId(1).Build();

            _viewModel.HandleSetDragDropLayout(column);
            _mockCommands.Verify(p => p.Layout(1), Times.Once());
        }
Exemple #5
0
        public static FormViewModel CreateForm()
        {
            var htmlContent = new HtmlElementBuilder().SetName("HtmlContent").SetContent(
                "<h2 style=\"text-align: center;\"><strong>Demo Form<br /></strong></h2>\r\n<p>Test HTML Content embedded in the demo form</p>\r\n<ul>\r\n<li>FirstName / LastName</li>\r\n<li>Years of experiance</li>\r\n<li>Accept Terms and Conditions</li>\r\n<li>Submit</li>\r\n</ul>")
                              .Build();

            var firstNameText = new TextElementBuilder()
                                .SetName("First Name")
                                .SetLabel(ElementLabel.Left("First Name: "))
                                .SetDefaultValue("First Name")
                                .AddRules(
                ValidationRule <ITextElementViewModel> .Create(new TextElement_MaximumLength_Validator(10))
                .WithFailMessage("First Name must be less then 10 characters"),
                ValidationRule <ITextElementViewModel> .Create(new TextElement_MinimunLength_Validator(2))
                .WithFailMessage("First Name must be greater then 2 characters"))
                                .Build();

            var lastNameText = new TextElementBuilder()
                               .SetName("Last Name")
                               .SetLabel(ElementLabel.Left("Last Name: "))
                               .SetDefaultValue("Last Name")
                               .AddRules(
                ValidationRule <ITextElementViewModel> .Create(new TextElement_MaximumLength_Validator(10))
                .WithFailMessage("Last Name must be less then 10 characters"),
                ValidationRule <ITextElementViewModel> .Create(new TextElement_MinimunLength_Validator(2))
                .WithFailMessage("Last Name must be greater then 2 characters"))
                               .Build();

            var personalDetails = new ColumnBuilder().SetName("personalDetails")
                                  .AddChildren(firstNameText, lastNameText).Build();


            var experienceSelection = new SelectElementBuilder().SetName("experienceSelection")
                                      .SetLabel(ElementLabel.Left("How many years experience have you got?")).AddValues("0-1", "1-5", "5+")
                                      .SetDefaultValue("Select a value").Build();
            var termsAndConditions = new CheckElementBuilder().SetName("TermsAndConditions")
                                     .SetLabel(ElementLabel.Left("Do you accept the terms and conditions?")).SetContent("Yes / No").AddRules(
                ValidationRule <ICheckElementViewModel> .Create(new CheckElement_IsChecked_Validator())
                .WithFailMessage("You must accept the terms and conditions")).Build();

            var submitButton = new ButtonElementBuilder().SetName("Submit Button").SetContent("Submit")
                               .SetVerticalAlignment(VerticalAlignment.Bottom).Build();

            var submitEventListener = new EventListener("submit",
                                                        new ElementNameEventSpecification("submit").And(
                                                            new TypeNameEventSpecification(nameof(ButtonElementClickedEvent))),
                                                        new IdentitySpecification <FormViewModel>());

            var rowGroup1 = new RowBuilder().SetName("Data Entry Rows")
                            .AddChildren(htmlContent, personalDetails, experienceSelection, termsAndConditions).Build();

            var rootGroup = new GroupBuilder().SetName("Test Group 1").SetTitle("Demo Form Title")
                            .AddChildren(rowGroup1, submitButton).Build();

            var newForm = new FormBuilder().SetName("Demo Form").SetTitle("Demo Form Title").SetRoot(rootGroup)
                          .AddEventListeners(submitEventListener)
                          .Build();

            return(new FormViewModel(newForm));
        }
        public void TestConstructorShouldSetName()
        {
            var column = new ColumnBuilder().WithValue(0).Build();
            var root   = new StringFilterTreeRoot("Test", column);

            Assert.That(root.Name, Is.EqualTo("Test"));
        }
Exemple #7
0
        public void GivenAColumn()
        {
            var column = new ColumnBuilder().Build();

            _appContext.Column = column;
            _appContext.DataContext.Columns.Add(column);
        }
    /// <summary>
    /// Add a new column to the table. The column defaults to a
    /// nullable non-key column.
    /// </summary>
    /// <param name="name">The column name.</param>
    /// <param name="type">The column type.</param>
    /// <param name="configure">A delegate to further configure the column.</param>
    public AlterTableBuilder AddColumn(
        string name, KuduType type, Action <ColumnBuilder>?configure = null)
    {
        var columnBuilder = new ColumnBuilder(name, type);

        configure?.Invoke(columnBuilder);

        var schema = columnBuilder.Build();

        if (!schema.IsNullable && schema.DefaultValue is null)
        {
            ThrowNewColumnMustHaveDefaultException();
        }

        if (schema.IsKey)
        {
            ThrowAddKeyColumnException();
        }

        _request.AlterSchemaSteps.Add(new Step
        {
            Type      = StepType.AddColumn,
            AddColumn = new AddColumn
            {
                Schema = schema.ToColumnSchemaPb()
            }
        });

        return(this);
    }
        public void SetUp()
        {
            _column = new ColumnBuilder()
                      .WithId(1)
                      .Build();
            _layout = new ScatterPlotLayout();
            _view   = new ScatterPlotBuilder()
                      .WithLayout(_layout)
                      .Build();

            var blankColumn = new ColumnBuilder().Build();

            _layout.XAxisColumn = blankColumn;
            _layout.YAxisColumn = blankColumn;
            _layout.SizeColumn  = blankColumn;
            _layout.ColorColumn = blankColumn;
            _layout.ShapeColumn = blankColumn;
            _layout.LabelColumn = blankColumn;
            _layout.LinkColumn  = blankColumn;

            _mockColumnRepository = new Mock <IColumnRepository>();
            _mockColumnRepository.Setup(p => p.Get(_column.Id))
            .Returns(_column);

            _mockViewRepository = new Mock <IViewRepository>();
            _mockViewRepository.Setup(p => p.Get <ScatterPlot>())
            .Returns(_view);

            _mockEventBus = new Mock <IEventBus>();

            _handler = new AutoLayoutColumnCommandHandler(
                _mockColumnRepository.Object,
                _mockViewRepository.Object,
                _mockEventBus.Object);
        }
        public static ColumnBuilder <TColumnType> OfType <TColumnType>(this ColumnBuilder builder, ColumnType <TColumnType> columnType)
        {
            Check.IsNotNull(builder, nameof(builder));
            Check.IsNotNull(columnType, nameof(columnType));

            return(new ColumnBuilder <TColumnType>(builder.Properties, columnType));
        }
        public static NullableStructColumnBuilder <T> Nullable <T>(this ColumnBuilder <T> builder)
            where T : struct
        {
            Check.IsNotNull(builder, nameof(builder));

            return(new NullableStructColumnBuilder <T>(builder.Properties));
        }
Exemple #12
0
        public static IGridColumn <T> InlineEditControlsColumn <T>(this ColumnBuilder <T> builder, string saveButtonTitle = null) where T : class
        {
            saveButtonTitle = saveButtonTitle ?? @RootGlobalization.Button_Save;

            var stringBuilder = new StringBuilder();

            stringBuilder.AppendFormat("<div class=\"bcms-action-delete bcms-grid-item-delete-button\" data-id=\"{{0}}\" data-version=\"{{1}}\" title=\"{0}\">{0}</div>", RootGlobalization.Button_Delete).AppendLine();
            stringBuilder.AppendFormat("<div style=\"display:none\" class=\"bcms-btn-primary\">{0}</div>", saveButtonTitle).AppendLine();
            stringBuilder.AppendFormat("<div style=\"display:none\" class=\"bcms-btn-cancel\">{0}</div>", RootGlobalization.Button_Cancel).AppendLine();
            stringBuilder.AppendFormat("<div style=\"display:none\" class=\"bcms-grid-item-message\"></div>");

            return(builder
                   .For(f => string.Format(stringBuilder.ToString(),
                                           f is IEditableGridItem
                                ? ((IEditableGridItem)f).Id
                                : Guid.Empty,
                                           f is IEditableGridItem
                                ? ((IEditableGridItem)f).Version
                                : 0)
                        )
                   .Named("&nbsp;")
                   .Sortable(false)
                   .Encode(false)
                   .HeaderAttributes(@class => "bcms-tables-nohover")
                   .Attributes(@style => "width: 40px; padding: 10px 0;", @class => "bcms-tables-nohover"));
        }
 protected override void OnColumnsBuild(ColumnBuilder <Tour> columnBuilder)
 {
     columnBuilder.AddColumn(x => nameof(x.Name), "Название");
     columnBuilder.AddColumn(x => nameof(x.Cost), "Стоимость");
     columnBuilder.AddColumn(x => nameof(x.ChildCost), "Стоимость за ребенка");
     columnBuilder.AddColumn(x => nameof(x.DaysCount), "Длительность тура (д.)");
 }
    public IColumnBuilder <TModel> New()
    {
        var column = new ColumnBuilder(gridBuilderReference);

        Columns.Add(column);
        return(column);
    }
Exemple #15
0
 public static IGridColumn <T> EmptyColumn <T>(this ColumnBuilder <T> builder) where T : class
 {
     return(builder.For(f => "&nbsp;")
            .Named("&nbsp;")
            .Sortable(false)
            .Encode(false));
 }
Exemple #16
0
 public static IGridColumn <T> ColumnHeaderForSortableList <T>(this ColumnBuilder <T> builder, string title, string sortColumnName) where T : class
 {
     return(builder.For(f => string.Empty)
            .Named(title)
            .SortColumnName(sortColumnName)
            .Encode(false));
 }
        private void Column(int columnNumber, Action <IColumnBuilder> action)
        {
            var column        = Worksheet.Column(columnNumber);
            var columnBuilder = new ColumnBuilder(column);

            action(columnBuilder);
        }
Exemple #18
0
        public static string SQLGenerateAlterTable(this TableTemplate template, string tableName)
        {
            SqlServerMigrationSqlGenerator gen = new SqlServerMigrationSqlGenerator();
            ColumnBuilder columnBuilder        = new ColumnBuilder();
            //columnBuilder.Int(name:"sysid",identity:true);

            //System.Data.Entity.Migrations.DbMigration
            var operations = new List <MigrationOperation>();
            var dict       = new Dictionary <string, AnnotationValues>();

            dict.Add("dddddd", new AnnotationValues(1, 2));
            var alter = new AlterTableOperation("dddd", dict);


            //alter.Columns.Add(new ColumnModel(PrimitiveTypeKind.String) { Name="dd" });


            //operations.Add(alter);
            operations.Add(new AddColumnOperation(tableName, columnBuilder.String(name: "dd")));
            operations.Add(new AlterColumnOperation(tableName, new ColumnModel(PrimitiveTypeKind.String)
            {
                Name = "dd3", MaxLength = 20
            }, false));
            operations.Add(new AlterColumnOperation(tableName, new ColumnModel(PrimitiveTypeKind.String)
            {
                Name = "dd2", MaxLength = 50
            }, false));
            operations.Add(new RenameColumnOperation(tableName, "dd3", "ee3"));

            var sqls = gen.Generate(operations, "2008").Select <MigrationStatement, string>(ms => ms.Sql).ToArray();
            var sql  = string.Join("\r\n\r\n", sqls);

            return(sql);
        }
Exemple #19
0
        public GridTag Columns <T>(Action <ColumnBuilder <T> > configAction)
        {
            var builder = new ColumnBuilder <T>(this);

            configAction(builder);
            return(this);
        }
Exemple #20
0
        public void Sorted(bool ascending)
        {
            ColumnBuilder builder = _builder.Sorted(ascending);

            _columnConfig.SortState.Should().Be(ascending ? SortState.Ascending : SortState.Descending);
            builder.Should().BeSameAs(_builder);
        }
Exemple #21
0
        public void Visible(bool visible)
        {
            ColumnBuilder builder = _builder.Visible(visible);

            _columnConfig.Visible.Should().Be(visible);
            builder.Should().BeSameAs(_builder);
        }
Exemple #22
0
        public void Header()
        {
            ColumnBuilder builder = _builder.Header("Header");

            _columnConfig.Header.Should().Be("Header");
            builder.Should().BeSameAs(_builder);
        }
Exemple #23
0
        /// <summary>
        /// Loads the table data.
        /// </summary>
        private void LoadTableData()
        {
            if (!project.ConfigBase.Load(out string errMsg))
            {
                appData.ProcError(errMsg);
            }

            // reset the binding source
            bindingSource.DataSource = null;

            // create a data table
            dataTable = tableFilter == null?
                        baseTable.ToDataTable() :
                            baseTable.SelectItems(tableFilter).ToDataTable(baseTable.ItemType);

            dataTable.DefaultView.Sort = baseTable.PrimaryKey;
            maxRowID = dataTable.DefaultView.Count > 0 ?
                       (int)dataTable.DefaultView[dataTable.DefaultView.Count - 1][baseTable.PrimaryKey] : 0;

            // set the binding source before creating grid columns in case of work on Mono
            if (ScadaUtils.IsRunningOnMono)
            {
                bindingSource.DataSource = dataTable;
            }

            // bind table events
            dataTable.TableNewRow += dataTable_TableNewRow;
            dataTable.RowChanged  += dataTable_RowChanged;
            dataTable.RowDeleted  += dataTable_RowDeleted;

            // create grid columns
            ColumnBuilder columnBuilder = new ColumnBuilder(project.ConfigBase);

            dataGridView.Columns.Clear();
            dataGridView.Columns.AddRange(columnBuilder.CreateColumns(baseTable.ItemType));

            // set default values
            foreach (DataGridViewColumn column in dataGridView.Columns)
            {
                if (column.Tag is ColumnOptions options && options.DefaultValue != null)
                {
                    dataTable.Columns[column.Name].DefaultValue = options.DefaultValue;
                }
            }

            if (tableFilter != null)
            {
                dataTable.Columns[tableFilter.ColumnName].DefaultValue = tableFilter.Value;
            }

            // set the binding source
            if (!ScadaUtils.IsRunningOnMono)
            {
                bindingSource.DataSource = dataTable;
            }

            dataGridView.AutoSizeColumns();
            ChildFormTag.Modified = baseTable.Modified;
        }
Exemple #24
0
        public void TestCreateChildrenShouldReturnEmptyList()
        {
            var column = new ColumnBuilder().Build();
            var leaf   = new FloatFilterTreeLeaf(string.Empty, column, 0d);
            var result = leaf.CreateChildren();

            Assert.That(result, Is.Empty);
        }
        public void TestCreateChildrenShouldNotReturnLeafIfChildValueDoesNotStartWithParentValue()
        {
            var column = new ColumnBuilder().WithValue("Apple").Build();
            var node   = new StringFilterTreeNode(string.Empty, column, "B", 1);
            var result = node.CreateChildren();

            Assert.That(result.Count(), Is.EqualTo(0));
        }
        public void TestCreateChildrenShouldReturnLeafIfChildValueStartsWithParentValue()
        {
            var column = new ColumnBuilder().WithValue("Apple").Build();
            var node   = new StringFilterTreeNode(string.Empty, column, string.Empty, 1);
            var result = node.CreateChildren();

            Assert.That(result.First().Name, Is.EqualTo("Apple"));
        }
Exemple #27
0
 public ColumnBuilderTest()
 {
     _columnConfig = new ColumnConfig {
         Filtering = new FilteringConfig()
     };
     _builderFactory = Substitute.For <IBuilderFactory>();
     _builder        = new ColumnBuilder(_columnConfig, _builderFactory);
 }
        public void TestCreateChildrenShouldCreateNullLeafIfColumnHasNulls()
        {
            var column  = new ColumnBuilder().WithNulls().Build();
            var node    = new BooleanFilterTreeRoot("Test", column);
            var results = node.CreateChildren().ToList();

            Assert.That(results[0].Name, Is.EqualTo("Null"));
        }
Exemple #29
0
 public static IGridColumn <T> ColumnHeaderForSortableList <T>(this ColumnBuilder <T> builder, string title, string sortColumnName, IDictionary <string, object> attributes) where T : class
 {
     return(builder.For(f => string.Empty)
            .Named(title)
            .SortColumnName(sortColumnName)
            .HeaderAttributes(attributes)
            .Encode(false));
 }
Exemple #30
0
        public void TestCreateAxisMapForInvalidDataTypeShouldThrowArgumentException()
        {
            var column = new ColumnBuilder()
                         .WithDataType(typeof(Object))
                         .Build();

            Assert.That(() => _factory.Create(column, 0d, 1d, SortOrder.Ascending), Throws.ArgumentException);
        }
Exemple #31
0
        public void Build(string path, int _num_cols, BasicTokenizer tokenizer, SequenceBuilder seq_builder)
        {
            Console.WriteLine ("*** building Table: '{0}', with {1} columns", path, _num_cols);
            var input = new StreamReader (File.OpenRead (path));
            var C = new ColumnBuilder[ _num_cols ];
            int numcol = 0;
            int numrec = 0;
            var recsep = tokenizer.RecordSeparator.ToString();

            for (int i = 0; i < _num_cols; ++i) {
                C [i] = new ColumnBuilder ();
                C [i].Add(recsep);
            }
            foreach (var p in tokenizer.Parse(input, false)) {
                // Console.WriteLine("<{0}>", p.Data);
                if (p.DataType == TokenType.FieldSeparator) {
                    C[numcol].Add(recsep);
                    ++numcol;
                    continue;
                }
                if (p.DataType == TokenType.RecordSeparator) {
                    if (numrec % 10000 == 0) {
                        Console.WriteLine("-- record: {0}, date-time: {1}", numrec, DateTime.Now);
                    }
                    while (numcol < _num_cols) {
                        C[numcol].Add(recsep);
                        // C[numcol].Add("");
                        ++numcol;
                    }
                    ++numrec;
                    numcol = 0;
                    continue;
                }
                //if (p.DataType == TokenType.Data) {
                C[numcol].Add(p.Data);
                //}
                //Console.WriteLine ("===> type: {0}, data: '{1}'", p.DataType, p.Data);
            }
            this.InputTokenizer = tokenizer;
            this.Columns = new Column[_num_cols];
            for (int i = 0; i < _num_cols; ++i) {
                Console.WriteLine ("*** compressing column-{0} of '{1}'", i, path);
                C[i].Add (recsep);
                this.Columns[i] = C[i].Finish(recsep, seq_builder);
            }
        }
 public void Setup()
 {
     _builder = new ColumnBuilder<Person>();
 }