public void Lines_Should_Have_Valid_Count() { TextView textView = new TextView(); TextDocument document = new TextDocument(); using var textEditorModel = new TextEditorModel( textView, document, null); document.Text = "puppy\npussy\nbirdie"; Assert.AreEqual(3, textEditorModel.GetNumberOfLines()); }
public void Editing_Line_Should_Update_The_Line_Length() { TextView textView = new TextView(); TextDocument document = new TextDocument(); using var textEditorModel = new TextEditorModel( textView, document, null); document.Text = "puppy\npussy\nbirdie"; document.Insert(0, "cutty "); Assert.AreEqual("cutty puppy".Length, textEditorModel.GetLineLength(0)); }
public void Lines_Should_Have_Valid_Content() { TextView textView = new TextView(); TextDocument document = new TextDocument(); using var textEditorModel = new TextEditorModel( textView, document, null); document.Text = "puppy\npussy\nbirdie"; Assert.AreEqual("puppy", textEditorModel.GetLineText(0)); Assert.AreEqual("pussy", textEditorModel.GetLineText(1)); Assert.AreEqual("birdie", textEditorModel.GetLineText(2)); }
public void Replace_Text_Of_Same_Length_With_CR_Should_Update_Line_Content() { TextView textView = new TextView(); TextDocument document = new TextDocument(); using var textEditorModel = new TextEditorModel( textView, document, null); document.Text = "puppy\npussy\nbirdie"; document.Replace(0, 1, "\n"); Assert.AreEqual("", textEditorModel.GetLineText(0)); }
public void Remove_Document_Text_Should_Update_Line_Contents() { TextView textView = new TextView(); TextDocument document = new TextDocument(); using var textEditorModel = new TextEditorModel( textView, document, null); document.Text = "puppy\npussy\nbirdie"; Assert.AreEqual(3, textEditorModel.GetNumberOfLines()); document.Text = string.Empty; Assert.AreEqual(1, textEditorModel.GetNumberOfLines()); Assert.AreEqual(string.Empty, textEditorModel.GetLineText(0)); }
public void Document_Lines_Count_Should_Match_Model_Lines_Count() { TextView textView = new TextView(); TextDocument document = new TextDocument(); using var textEditorModel = new TextEditorModel( textView, document, null); document.Text = "puppy\npussy\nbirdie"; int count = 0; textEditorModel.ForEach((m) => count++); Assert.AreEqual(document.LineCount, count); }
public void Editing_Line_Should_Update_The_Line_Content() { TextView textView = new TextView(); TextDocument document = new TextDocument(); TextEditorModel textEditorModel = new TextEditorModel( textView, document, null); document.Text = "puppy\npussy\nbirdie"; document.Insert(0, "cutty "); Assert.AreEqual("cutty puppy", textEditorModel.GetLineText(0)); Assert.AreEqual("pussy", textEditorModel.GetLineText(1)); Assert.AreEqual("birdie", textEditorModel.GetLineText(2)); }
public void Removing_Line_Should_Update_The_Line_Ranges() { TextView textView = new TextView(); TextDocument document = new TextDocument(); using var textEditorModel = new TextEditorModel( textView, document, null); document.Text = "puppy\npussy\nbirdie"; document.Remove( document.Lines[0].Offset, document.Lines[0].TotalLength); Assert.AreEqual("pussy", textEditorModel.GetLineText(0)); Assert.AreEqual("birdie", textEditorModel.GetLineText(1)); }
public void Inserting_Line_Should_Update_The_Line_Ranges() { TextView textView = new TextView(); TextDocument document = new TextDocument(); using var textEditorModel = new TextEditorModel( textView, document, null); document.Text = "puppy\npussy\nbirdie"; document.Insert(0, "lion\n"); Assert.AreEqual("lion", textEditorModel.GetLineText(0)); Assert.AreEqual("puppy", textEditorModel.GetLineText(1)); Assert.AreEqual("pussy", textEditorModel.GetLineText(2)); Assert.AreEqual("birdie", textEditorModel.GetLineText(3)); }
public void Insert_Document_Line_Should_Insert_Model_Line() { TextView textView = new TextView(); TextDocument document = new TextDocument(); using var textEditorModel = new TextEditorModel( textView, document, null); document.Text = "puppy\npussy\nbirdie"; document.Insert(0, "lion\n"); int count = 0; textEditorModel.ForEach((m) => count++); Assert.AreEqual(document.LineCount, count); }
public void Edit_Document_Line_Should_Not_Add_Or_Remove_Model_Lines() { TextView textView = new TextView(); TextDocument document = new TextDocument(); TextEditorModel textEditorModel = new TextEditorModel( textView, document, null); document.Text = "puppy\npussy\nbirdie"; document.Insert(0, "cutty "); int count = 0; textEditorModel.ForEach((m) => count++); Assert.AreEqual(document.LineCount, count); }
public void Replace_Document_Text_Should_Update_Line_Contents() { TextView textView = new TextView(); TextDocument document = new TextDocument(); using var textEditorModel = new TextEditorModel( textView, document, null); document.Text = "puppy\npussy\nbirdie"; Assert.AreEqual(3, textEditorModel.GetNumberOfLines()); document.Text = "one\ntwo\nthree\nfour"; Assert.AreEqual(4, textEditorModel.GetNumberOfLines()); Assert.AreEqual("one", textEditorModel.GetLineText(0)); Assert.AreEqual("two", textEditorModel.GetLineText(1)); Assert.AreEqual("three", textEditorModel.GetLineText(2)); Assert.AreEqual("four", textEditorModel.GetLineText(3)); }
public void Nested_Batch_Document_Changes_Should_Invalidate_Lines() { TextView textView = new TextView(); TextDocument document = new TextDocument(); using var textEditorModel = new TextEditorModel( textView, document, null); document.Text = "puppy\npuppy\npuppy"; document.BeginUpdate(); document.Insert(0, "*"); Assert.AreEqual(0, textEditorModel.InvalidRange.StartLine, "Wrong InvalidRange.StartLine 1"); Assert.AreEqual(0, textEditorModel.InvalidRange.EndLine, "Wrong InvalidRange.EndLine 1"); document.BeginUpdate(); document.Insert(7, "*"); Assert.AreEqual(0, textEditorModel.InvalidRange.StartLine, "Wrong InvalidRange.StartLine 2"); Assert.AreEqual(1, textEditorModel.InvalidRange.EndLine, "Wrong InvalidRange.EndLine 2"); document.Insert(14, "*"); Assert.AreEqual(0, textEditorModel.InvalidRange.StartLine, "Wrong InvalidRange.StartLine 3"); Assert.AreEqual(2, textEditorModel.InvalidRange.EndLine, "Wrong InvalidRange.EndLine 3"); document.EndUpdate(); Assert.IsNotNull(textEditorModel.InvalidRange, "InvalidRange should not be null"); document.EndUpdate(); Assert.IsNull(textEditorModel.InvalidRange, "InvalidRange should be null"); Assert.AreEqual("*puppy", textEditorModel.GetLineText(0)); Assert.AreEqual("*puppy", textEditorModel.GetLineText(1)); Assert.AreEqual("*puppy", textEditorModel.GetLineText(2)); }
public void Remove_Document_Line_Should_Remove_Model_Line() { TextView textView = new TextView(); TextDocument document = new TextDocument(); using var textEditorModel = new TextEditorModel( textView, document, null); document.Text = "puppy\npussy\nbirdie"; document.Remove( document.Lines[0].Offset, document.Lines[0].TotalLength); int count = 0; textEditorModel.ForEach((m) => count++); Assert.AreEqual(document.LineCount, count); }
public ActionResult ShowInlineEditing(ITableColumnService tableColumnService, ILocalizationService localizationService, TableColumnModel column, int index, string tableName) { if (column.ColumnDataTypeId == 470 || column.ColumnDataTypeId == 471) { var model = new TextEditorModel() { LabelName = localizationService.GetLocalizedData(column.Id.ToString() + ";" + DataType.TableName + ";ColumnName"), Name = tableName + "[" + index.ToString() + "]." + column.ColumnName, Value = column.ColumnValue, PlaceHolder = localizationService.GetLocalizedData(column.Id.ToString() + ";" + DataType.TableName + ";ColumnName") }; if (column.ColumnDataTypeId == 471) { model.Type = "Number"; } return(PartialView(UrlHelpers.FloatingTemplate("_TextEditor.cshtml"), model)); } else if (column.ColumnDataTypeId == 472) { var model = new DatePickerModel() { LabelName = localizationService.GetLocalizedData(column.Id.ToString() + ";" + DataType.TableName + ";ColumnName"), Name = tableName + "[" + index.ToString() + "]." + column.ColumnName, DateFormat = "dd/MM/yyyy", Vertical = "top", PlaceHolder = localizationService.GetLocalizedData(column.Id.ToString() + ";" + DataType.TableName + ";ColumnName") }; if (column.ColumnValue != null && !string.IsNullOrEmpty(column.ColumnValue)) { model.Value = DateTime.Parse(column.ColumnValue); } else { model.Value = null; } return(PartialView(UrlHelpers.FloatingTemplate("_DatePicker.cshtml"), model)); } else if (column.ColumnDataTypeId == 473) { var model = new DropdownListModel() { LabelName = localizationService.GetLocalizedData(column.Id.ToString() + ";" + DataType.TableName + ";ColumnName"), DataType = DataType.MasterData, PropertyName = "Name", IsAnimationLabel = false, IsTagsInput = false, IsMultipleLanguage = false, ValueField = "Id", DisplayField = "Name", Name = tableName + "[" + index.ToString() + "]." + column.ColumnName, Value = column.ColumnValue }; var responseColumn = tableColumnService.ExcuteSqlString(column.SqlData); if (responseColumn != null) { var resultColumn = JsonConvert.DeserializeObject <HrmResultModel <dynamic> >(responseColumn); if (!CheckPermission(resultColumn)) { //return to Access Denied } else { model.Data = resultColumn.Results; } } return(PartialView(UrlHelpers.FloatingTemplate("_Dropdown.cshtml"), model)); } else if (column.ColumnDataTypeId == 10519) { var model = new CheckboxModel() { LabelName = localizationService.GetLocalizedData(column.Id.ToString() + ";" + DataType.TableName + ";ColumnName"), Name = tableName + "[" + index.ToString() + "]." + column.ColumnName, Value = column.ColumnValue, }; return(PartialView(UrlHelpers.FloatingTemplate("_Checkbox.cshtml"), model)); } else { return(Content("<div class=\"hrm-v2-td-template\"><span id=\"original-row-column-\"" + column.Id + ">" + column.ColumnValue + "</span></div>")); } }
public ActionResult Index(TextEditorModel editor) { return(View()); }