~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/AddIns/BackendBindings/CSharpBinding/Tests/CSharpFormattingTests.cs

  • Committer: sk
  • Date: 2011-09-10 05:17:57 UTC
  • Revision ID: halega@halega.com-20110910051757-qfouz1llya9m6boy
4.1.0.7915 Release Candidate 1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
 
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
 
3
 
 
4
using CSharpBinding.FormattingStrategy;
 
5
using System;
 
6
using NUnit.Framework;
 
7
 
 
8
namespace CSharpBinding.Tests
 
9
{
 
10
        [TestFixture]
 
11
        public class CSharpFormattingTests
 
12
        {
 
13
                [Test]
 
14
                public void EnterInsideString()
 
15
                {
 
16
                        const string start = "class X {\n" + 
 
17
                                "\tstring text = \"a";
 
18
                        const string insertedMiddle = "\" +\n\t\"";
 
19
                        const string end = "b\";\n" +
 
20
                                "}";
 
21
                        MockTextEditor textEditor = new MockTextEditor();
 
22
                        textEditor.Document.Text = start + end;
 
23
                        textEditor.Select(start.Length, 0);
 
24
                        CSharpFormattingStrategy formattingStrategy = new CSharpFormattingStrategy();
 
25
                        textEditor.TextEditor.TextArea.PerformTextInput("\n");
 
26
                        formattingStrategy.FormatLine(textEditor, '\n');
 
27
                        Assert.AreEqual(start + insertedMiddle + end, textEditor.Document.Text);
 
28
                        Assert.AreEqual(start.Length + insertedMiddle.Length, textEditor.SelectionStart);
 
29
                        Assert.AreEqual(0, textEditor.SelectionLength);
 
30
                }
 
31
        }
 
32
}