Esempio n. 1
0
		public void InterfaceEndSub()
		{
			string code = "Public Interface Foo\r\n" +
				"\tPublic Sub Bar\r\n" +
				"\r\n" + // This extra new line is required. This is the new line just entered by the user.
				"End Interface";
			
			string bar = "Sub Bar\r\n";
			int cursorOffset = code.IndexOf(bar) + bar.Length;
			
			string expectedCode = "Public Interface Foo\r\n" +
				"\tPublic Sub Bar\r\n" +
				"\t\r\n" +
				"End Interface";
			
			int expectedOffset = ("Public Interface Foo\r\n" +
				"\tPublic Sub Bar\r\n" +
				"\t").Length;
			
			AvalonEditTextEditorAdapter editor = new AvalonEditTextEditorAdapter(new TextEditor());
			editor.Document.Text = code;
			editor.Caret.Offset = cursorOffset;
			VBNetFormattingStrategy formattingStrategy = new VBNetFormattingStrategy();
			formattingStrategy.FormatLine(editor, '\n');
			
			Assert.AreEqual(expectedCode, editor.Document.Text);
			Assert.AreEqual(expectedOffset, editor.Caret.Offset);
		}
Esempio n. 2
0
		void RunTest(string code, int cursorOffset, string expectedCode, int expectedOffset, char keyPressed)
		{
			AvalonEditTextEditorAdapter editor = new AvalonEditTextEditorAdapter(new TextEditor());
			editor.Document.Text = code;
			editor.Caret.Offset = cursorOffset;
			VBNetFormattingStrategy formattingStrategy = new VBNetFormattingStrategy();
			formattingStrategy.FormatLine(editor, keyPressed);
			Assert.AreEqual(expectedCode, editor.Document.Text);
			Assert.AreEqual(expectedOffset, editor.Caret.Offset);
		}
		/// <summary>
		/// Checks that when the user presses the return key after the Operator line that the
		/// expected code is generated.
		/// </summary>
		void RunFormatLineTest(string code, string expectedCode, int expectedOffset)
		{
			string foo = "As Foo\r\n";
			int cursorOffset = code.IndexOf(foo) + foo.Length;

			AvalonEditTextEditorAdapter editor = new AvalonEditTextEditorAdapter(new TextEditor());
			editor.Document.Text = code;
			editor.Caret.Offset = cursorOffset;
			VBNetFormattingStrategy formattingStrategy = new VBNetFormattingStrategy();
			formattingStrategy.FormatLine(editor, '\n');
			
			Assert.AreEqual(expectedCode, editor.Document.Text);
			Assert.AreEqual(expectedOffset, editor.Caret.Offset);
		}
		void RunFormatTest(string code, string expectedCode)
		{
			AvalonEditTextEditorAdapter editor = new AvalonEditTextEditorAdapter(new TextEditor());
			editor.Document.Text = code;
			VBNetFormattingStrategy formattingStrategy = new VBNetFormattingStrategy();
			formattingStrategy.IndentLines(editor, 1, editor.Document.TotalNumberOfLines);
			
			Console.WriteLine(editor.Document.Text);
			
			Assert.AreEqual(expectedCode, editor.Document.Text);
		}