public void R_AutoFormatFuncionDefinition03() { using (var script = new TestScript(RContentTypeDefinition.ContentType)) { string text1 = "x <-function(x, y,{ENTER}"; string text2 = "a,b,"; string text3 = "c, d)"; script.Type(text1); script.DoIdle(300); script.Backspace(); script.Backspace(); script.Backspace(); script.Backspace(); script.DoIdle(300); script.Type(text2); script.Enter(); script.Type(text3); string actual = script.EditorText; string expected = "x <- function(x, y,\r\n" + " a, b,\r\n" + " c, d)"; actual.Should().Be(expected); } }
public void R_AutoFormatScopeBraces08() { using (var script = new TestScript("while (true) {\r\n}", RContentTypeDefinition.ContentType)) { REditorSettings.FormatOptions.BracesOnNewLine = true; script.MoveDown(); script.Enter(); string expected = "while (true)\r\n{\r\n\r\n}"; string actual = script.EditorText; actual.Should().Be(expected); } }
public void R_AutoFormatFuncionDefinition04() { using (var script = new TestScript(RContentTypeDefinition.ContentType)) { string text = "function(){return(1)}"; script.Type(text); script.DoIdle(300); script.Enter(); string actual = script.EditorText; string expected = @"function() { return(1) } "; actual.Should().Be(expected); } }
/// <summary> /// Opens file in an editor window /// </summary> /// <param name="fileName">File name</param> /// <param name="contentType">File content type</param> private string TypeFileInEditor(string fileName, string contentType) { using (var script = new TestScript(contentType)) { string text = _files.LoadDestinationFile(fileName); string[] lines = text.Split(CharExtensions.LineBreakChars); for (int i = 0; i < lines.Length; i++) { string lineText = lines[i]; if (!lineText.TrimStart().StartsWith("#", System.StringComparison.Ordinal)) { lineText = lineText.Replace(" ", string.Empty); } script.Type(lineText, idleTime: 10); script.Enter(); script.DoIdle(300); } return(script.EditorText); } }