diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Completion/ElementCompletionWindowTests.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Completion/ElementCompletionWindowTests.cs index 57ff3831ca..ca334673a7 100644 --- a/src/AddIns/DisplayBindings/XmlEditor/Test/Completion/ElementCompletionWindowTests.cs +++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Completion/ElementCompletionWindowTests.cs @@ -13,7 +13,6 @@ using XmlEditor.Tests.Utils; namespace XmlEditor.Tests.Completion { [TestFixture] - [Ignore("Test needs to be adjusted to SD5")] public class ElementCompletionWindowTests { MockTextEditor textEditor; @@ -39,29 +38,54 @@ namespace XmlEditor.Tests.Completion completionBinding = new XmlCodeCompletionBinding(associations); } + void CharacterTypedIntoTextEditor(char ch) + { + textEditor.Document.Text += ch.ToString(); + textEditor.Caret.Offset++; + } + [Test] - public void HandleKeyPress_LessThanKeyPressed_KeyPressResultIsCompletedAfterPressingLessThanSign() + public void HandleKeyPress_AnyKey_ReturnsNone() { - keyPressResult = completionBinding.HandleKeyPress(textEditor, '<'); - Assert.AreEqual(CodeCompletionKeyPressResult.EatKey, keyPressResult); + keyPressResult = completionBinding.HandleKeyPress(textEditor, 'a'); + + Assert.AreEqual(CodeCompletionKeyPressResult.None, keyPressResult); } [Test] - public void HandleKeyPress_LessThanKeyPressed_CompletionWindowWidthIsNotSetToMatchLongestNamespaceTextWidth() + public void HandleKeyPressed_LessThanKeyPressed_ReturnsTrue() { - completionBinding.HandleKeyPress(textEditor, '<'); + CharacterTypedIntoTextEditor('<'); + bool result = completionBinding.HandleKeyPressed(textEditor, '<'); + Assert.IsTrue(result); + } + + [Test] + public void HandleKeyPressed_SpaceCharacterPressed_ReturnsFalse() + { + CharacterTypedIntoTextEditor(' '); + bool result = completionBinding.HandleKeyPressed(textEditor, ' '); + Assert.IsFalse(result); + } + + [Test] + public void HandleKeyPressed_LessThanKeyPressed_CompletionWindowWidthIsNotSetToMatchLongestNamespaceTextWidth() + { + CharacterTypedIntoTextEditor('<'); + completionBinding.HandleKeyPressed(textEditor, '<'); + Assert.AreNotEqual(double.NaN, textEditor.CompletionWindowDisplayed.Width); } [Test] - public void HandleKeyPress_LessThanKeyPressedInsideRootHtmlElement_BodyElementExistsInChildCompletionItems() + public void HandleKeyPressed_LessThanKeyPressedInsideRootHtmlElement_BodyElementExistsInChildCompletionItems() { textEditor.Document.Text = "<\r\n" + ""; - textEditor.Caret.Offset = 6; + textEditor.Caret.Offset = 7; - completionBinding.HandleKeyPress(textEditor, '<'); + completionBinding.HandleKeyPressed(textEditor, '<'); ICompletionItem[] items = textEditor.CompletionItemsDisplayedToArray(); XmlCompletionItem expectedItem = new XmlCompletionItem("body", XmlCompletionItemType.XmlElement); diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Editor/DefaultXmlEditorOptionsTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Editor/DefaultXmlEditorOptionsTestFixture.cs index 220e6f3218..0023c761b2 100644 --- a/src/AddIns/DisplayBindings/XmlEditor/Test/Editor/DefaultXmlEditorOptionsTestFixture.cs +++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Editor/DefaultXmlEditorOptionsTestFixture.cs @@ -15,7 +15,6 @@ using XmlEditor.Tests.Utils; namespace XmlEditor.Tests.Editor { [TestFixture] - [Ignore("Test needs to be adjusted to SD5")] public class DefaultXmlEditorOptionsTestFixture { XmlSchemaFileAssociations associations; @@ -37,12 +36,13 @@ namespace XmlEditor.Tests.Editor DefaultXmlSchemaFileAssociations CreateDefaultXmlSchemaFileExtensions() { - string addinXml = "\r\n" + - ""; + string addinXml = + "\r\n" + + ""; using (StringReader reader = new StringReader(addinXml)) { var addInTree = MockRepository.GenerateStrictMock();