Browse Source

Added unit tests for the XmlCodeCompletionBinding class.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5247 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Matt Ward 17 years ago
parent
commit
62f7808f01
  1. 4
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/QualifiedNameCollection.cs
  2. 62
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlCodeCompletionBinding.cs
  3. 20
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlCompletionDataProvider.cs
  4. 18
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlCompletionItem.cs
  5. 15
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlCompletionItemList.cs
  6. 2
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlDisplayBinding.cs
  7. 22
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlEditorOptions.cs
  8. 4
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlElementPath.cs
  9. 4
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlSchemaCompletionData.cs
  10. 22
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlSchemaCompletionDataCollection.cs
  11. 11
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlTreeView.cs
  12. 2
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlView.cs
  13. 58
      src/AddIns/DisplayBindings/XmlEditor/Test/Completion/AttributeCompletionWindowTestFixture.cs
  14. 82
      src/AddIns/DisplayBindings/XmlEditor/Test/Completion/CtrlSpaceAttributeValueCompletionTestFixture.cs
  15. 55
      src/AddIns/DisplayBindings/XmlEditor/Test/Completion/CtrlSpaceNoAttributeValuesForCompletionTestFixture.cs
  16. 57
      src/AddIns/DisplayBindings/XmlEditor/Test/Completion/ElementCompletionWindowTestFixture.cs
  17. 46
      src/AddIns/DisplayBindings/XmlEditor/Test/Completion/FirstCompletionListItemSelectedTestFixture.cs
  18. 62
      src/AddIns/DisplayBindings/XmlEditor/Test/Completion/GetCompletionDataProviderTestFixture.cs
  19. 61
      src/AddIns/DisplayBindings/XmlEditor/Test/Completion/NamespaceCompletionWindowTestFixture.cs
  20. 53
      src/AddIns/DisplayBindings/XmlEditor/Test/Completion/NamespaceCompletionWindowTestFixtureBase.cs
  21. 34
      src/AddIns/DisplayBindings/XmlEditor/Test/Completion/NoCompletionItemsTestFixture.cs
  22. 47
      src/AddIns/DisplayBindings/XmlEditor/Test/Completion/NullCompletionItemsReturnedTestFixture.cs
  23. 33
      src/AddIns/DisplayBindings/XmlEditor/Test/Completion/ProcessKeyTests.cs
  24. 33
      src/AddIns/DisplayBindings/XmlEditor/Test/Completion/ShowCompletionWindowReturnsNullTestFixture.cs
  25. 35
      src/AddIns/DisplayBindings/XmlEditor/Test/Completion/XmlCompletionItemCollectionTests.cs
  26. 51
      src/AddIns/DisplayBindings/XmlEditor/Test/Completion/XmlCompletionItemIsEqualTests.cs
  27. 8
      src/AddIns/DisplayBindings/XmlEditor/Test/Editor/DefaultXmlEditorOptionsTestFixture.cs
  28. 9
      src/AddIns/DisplayBindings/XmlEditor/Test/Paths/NoElementPathTestFixture.cs
  29. 19
      src/AddIns/DisplayBindings/XmlEditor/Test/Paths/QualifiedNameCollectionTests.cs
  30. 3
      src/AddIns/DisplayBindings/XmlEditor/Test/Tree/XmlTreeViewClipboardHandlerTestFixture.cs
  31. 63
      src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockCaret.cs
  32. 85
      src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockCompletionListWindow.cs
  33. 148
      src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockDocument.cs
  34. 188
      src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockTextEditor.cs
  35. 72
      src/AddIns/DisplayBindings/XmlEditor/Test/Utils/Tests/MockDocumentTests.cs
  36. 116
      src/AddIns/DisplayBindings/XmlEditor/Test/Utils/Tests/MockTextEditorTests.cs
  37. 34
      src/AddIns/DisplayBindings/XmlEditor/Test/Utils/TextSection.cs
  38. 23
      src/AddIns/DisplayBindings/XmlEditor/Test/XmlEditor.Tests.csproj
  39. 8
      src/AddIns/DisplayBindings/XmlEditor/XmlEditor.sln

4
src/AddIns/DisplayBindings/XmlEditor/Project/Src/QualifiedNameCollection.cs

@ -34,6 +34,10 @@ namespace ICSharpCode.XmlEditor @@ -34,6 +34,10 @@ namespace ICSharpCode.XmlEditor
get { return Count > 0; }
}
public bool IsEmpty {
get { return !HasItems; }
}
public override string ToString()
{
StringBuilder text = new StringBuilder();

62
src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlCodeCompletionBinding.cs

@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
// </file>
using System;
using System.Collections.Generic;
using System.IO;
using ICSharpCode.Core;
@ -15,39 +16,38 @@ using ICSharpCode.SharpDevelop.Editor.CodeCompletion; @@ -15,39 +16,38 @@ using ICSharpCode.SharpDevelop.Editor.CodeCompletion;
namespace ICSharpCode.XmlEditor
{
public class XmlCodeCompletionBinding : ICodeCompletionBinding
{
static XmlCodeCompletionBinding instance;
{
XmlEditorOptions options;
public static XmlCodeCompletionBinding Instance {
get {
if (instance == null) {
instance = new XmlCodeCompletionBinding();
}
return instance;
}
public XmlCodeCompletionBinding()
: this(XmlEditorService.XmlEditorOptions)
{
}
public XmlCodeCompletionBinding()
public XmlCodeCompletionBinding(XmlEditorOptions options)
{
this.options = options;
}
public CodeCompletionKeyPressResult HandleKeyPress(ITextEditor editor, char ch)
{
{
string text = editor.Document.GetText(0, editor.Caret.Offset);
XmlCompletionDataProvider provider = GetProvider(editor.FileName);
ICompletionItemList completionItems = provider.GenerateCompletionData(text, ch);
ICompletionListWindow completionWindow = editor.ShowCompletionWindow(completionItems);
if (completionWindow != null) {
XmlCompletionItem item = completionItems.SuggestedItem as XmlCompletionItem;
if (item.DataType == XmlCompletionDataType.NamespaceUri) {
completionWindow.Width = double.NaN;
XmlCompletionDataProvider provider = options.GetProvider(editor.FileName);
XmlCompletionItemList completionItems = provider.GenerateCompletionData(text, ch);
if (completionItems.Items.Count > 0) {
ICompletionListWindow completionWindow = editor.ShowCompletionWindow(completionItems);
if (completionWindow != null) {
XmlCompletionItem firstListItem = (XmlCompletionItem)completionItems.Items[0];
if (firstListItem.DataType == XmlCompletionDataType.NamespaceUri) {
completionWindow.Width = double.NaN;
}
}
}
if ((ch == '<') || (ch == ' ') || (ch == '=')) {
return CodeCompletionKeyPressResult.Completed;
}
return CodeCompletionKeyPressResult.CompletedIncludeKeyInCompletion;
return CodeCompletionKeyPressResult.None;
}
public bool CtrlSpace(ITextEditor editor)
@ -57,27 +57,15 @@ namespace ICSharpCode.XmlEditor @@ -57,27 +57,15 @@ namespace ICSharpCode.XmlEditor
int offset = editor.Caret.Offset;
if (XmlParser.IsInsideAttributeValue(text, offset)) {
XmlElementPath path = XmlParser.GetActiveElementStartPath(text, offset);
if (path.Elements.Count > 0) {
XmlCompletionDataProvider provider = GetProvider(editor.FileName);
editor.ShowCompletionWindow(provider.GetAttributeValueCompletionData(path, XmlParser.GetAttributeNameAtIndex(text, offset)));
XmlCompletionDataProvider provider = options.GetProvider(editor.FileName);
string attributeName = XmlParser.GetAttributeNameAtIndex(text, offset);
XmlCompletionItemList completionItems = provider.GetAttributeValueCompletionData(path, attributeName);
if (completionItems.Items.Count > 0) {
editor.ShowCompletionWindow(completionItems);
return true;
}
}
return false;
}
public static XmlCompletionDataProvider GetProvider(string fileName)
{
string extension = Path.GetExtension(fileName);
if (PropertyService.DataDirectory != null) {
XmlSchemaCompletionDataCollection schemas = XmlEditorService.XmlSchemaManager.Schemas;
string defaultNamespacePrefix = XmlEditorService.XmlEditorOptions.GetNamespacePrefix(extension);
XmlSchemaCompletionData defaultSchemaCompletionData = XmlEditorService.XmlEditorOptions.GetSchemaCompletionData(extension);
return new XmlCompletionDataProvider(schemas, defaultSchemaCompletionData, defaultNamespacePrefix);
}
// for unit tests
return new XmlCompletionDataProvider(new XmlSchemaCompletionDataCollection(), null, String.Empty);
}
}
}

20
src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlCompletionDataProvider.cs

@ -28,11 +28,19 @@ namespace ICSharpCode.XmlEditor @@ -28,11 +28,19 @@ namespace ICSharpCode.XmlEditor
this.defaultNamespacePrefix = defaultNamespacePrefix;
}
public ICompletionItemList GenerateCompletionData(string fileContent, char charTyped)
public string DefaultNamespacePrefix {
get { return defaultNamespacePrefix; }
}
public XmlSchemaCompletionData DefaultSchemaCompletionData {
get { return defaultSchemaCompletionData; }
}
public XmlCompletionItemList GenerateCompletionData(string fileContent, char charTyped)
{
string text = String.Concat(fileContent, charTyped);
DefaultCompletionItemList list = null;
XmlCompletionItemList list = null;
switch (charTyped) {
case '=':
@ -77,6 +85,8 @@ namespace ICSharpCode.XmlEditor @@ -77,6 +85,8 @@ namespace ICSharpCode.XmlEditor
if (list != null) {
list.SortItems();
list.SuggestedItem = list.Items.FirstOrDefault();
} else {
list = new XmlCompletionItemList();
}
return list;
@ -125,7 +135,7 @@ namespace ICSharpCode.XmlEditor @@ -125,7 +135,7 @@ namespace ICSharpCode.XmlEditor
return schemaCompletionDataItems.GetSchemaFromFileName(fileName);
}
public DefaultCompletionItemList GetChildElementCompletionData(XmlElementPath path)
public XmlCompletionItemList GetChildElementCompletionData(XmlElementPath path)
{
XmlCompletionItemList list = new XmlCompletionItemList();
@ -139,7 +149,7 @@ namespace ICSharpCode.XmlEditor @@ -139,7 +149,7 @@ namespace ICSharpCode.XmlEditor
return list;
}
public DefaultCompletionItemList GetAttributeCompletionData(XmlElementPath path)
public XmlCompletionItemList GetAttributeCompletionData(XmlElementPath path)
{
XmlCompletionItemList list = new XmlCompletionItemList();
@ -153,7 +163,7 @@ namespace ICSharpCode.XmlEditor @@ -153,7 +163,7 @@ namespace ICSharpCode.XmlEditor
return list;
}
public DefaultCompletionItemList GetAttributeValueCompletionData(XmlElementPath path, string name)
public XmlCompletionItemList GetAttributeValueCompletionData(XmlElementPath path, string name)
{
XmlCompletionItemList list = new XmlCompletionItemList();

18
src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlCompletionItem.cs

@ -76,14 +76,28 @@ namespace ICSharpCode.XmlEditor @@ -76,14 +76,28 @@ namespace ICSharpCode.XmlEditor
case XmlCompletionDataType.XmlAttribute:
context.Editor.Document.Insert(context.EndOffset, "=\"\"");
context.Editor.Caret.Offset--;
XmlCodeCompletionBinding.Instance.CtrlSpace(context.Editor);
// XmlCodeCompletionBinding.Instance.CtrlSpace(context.Editor);
break;
}
}
public override string ToString()
{
return "[" + this.Text + "]";
return "[" + Text + "]";
}
public override int GetHashCode()
{
return base.GetHashCode();
}
public override bool Equals(object obj)
{
XmlCompletionItem item = obj as XmlCompletionItem;
if (item != null) {
return (dataType == item.dataType) && (Text == item.Text);
}
return false;
}
}
}

15
src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlCompletionItemList.cs

@ -1,29 +1,30 @@ @@ -1,29 +1,30 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Siegfried Pammer" email="sie_pam@gmx.at"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using ICSharpCode.SharpDevelop.Editor.CodeCompletion;
namespace ICSharpCode.XmlEditor
{
/// <summary>
/// Description of XmlCompletionItemList.
/// </summary>
sealed class XmlCompletionItemList : DefaultCompletionItemList
public sealed class XmlCompletionItemList : DefaultCompletionItemList
{
List<char> normalKeys = new List<char>();
public XmlCompletionItemList()
{
normalKeys.AddRange(new char[] { ' ', ':', '.' });
}
public override CompletionItemListKeyResult ProcessInput(char key)
{
if (key == ':' || key == '.' || key == ' ')
if (normalKeys.Contains(key)) {
return CompletionItemListKeyResult.NormalKey;
}
return base.ProcessInput(key);
}
}

2
src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlDisplayBinding.cs

@ -60,7 +60,7 @@ namespace ICSharpCode.XmlEditor @@ -60,7 +60,7 @@ namespace ICSharpCode.XmlEditor
public IViewContent[] CreateSecondaryViewContent(IViewContent viewContent)
{
List<IViewContent> views = new List<IViewContent>();
views.Add(new XmlTreeView(viewContent));
views.Add(new XmlTreeView(viewContent, XmlEditorService.XmlEditorOptions));
return views.ToArray();
}

22
src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlEditorOptions.cs

@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
using System;
using System.Diagnostics;
using System.IO;
using ICSharpCode.Core;
using System.Globalization;
@ -39,9 +40,9 @@ namespace ICSharpCode.XmlEditor @@ -39,9 +40,9 @@ namespace ICSharpCode.XmlEditor
/// <summary>
/// Gets an association between a schema and a file extension.
/// </summary>
public XmlSchemaFileAssociation GetSchemaFileAssociation(string extension)
{
extension = extension.ToLowerInvariant();
public XmlSchemaFileAssociation GetSchemaFileAssociation(string fileName)
{
string extension = Path.GetExtension(fileName).ToLowerInvariant();
string property = properties.Get("ext" + extension, String.Empty);
XmlSchemaFileAssociation schemaFileAssociation = XmlSchemaFileAssociation.ConvertFromString(property);
if (schemaFileAssociation.IsEmpty) {
@ -50,15 +51,15 @@ namespace ICSharpCode.XmlEditor @@ -50,15 +51,15 @@ namespace ICSharpCode.XmlEditor
return schemaFileAssociation;
}
public XmlSchemaCompletionData GetSchemaCompletionData(string fileExtension)
public XmlSchemaCompletionData GetSchemaCompletionData(string fileName)
{
XmlSchemaFileAssociation association = GetSchemaFileAssociation(fileExtension);
XmlSchemaFileAssociation association = GetSchemaFileAssociation(fileName);
return schemas[association.NamespaceUri];
}
public string GetNamespacePrefix(string fileExtension)
public string GetNamespacePrefix(string fileName)
{
return GetSchemaFileAssociation(fileExtension).NamespacePrefix;
return GetSchemaFileAssociation(fileName).NamespacePrefix;
}
public void SetSchemaFileAssociation(XmlSchemaFileAssociation association)
@ -75,5 +76,12 @@ namespace ICSharpCode.XmlEditor @@ -75,5 +76,12 @@ namespace ICSharpCode.XmlEditor
get { return properties.Get(ShowSchemaAnnotationPropertyName, true); }
set { properties.Set(ShowSchemaAnnotationPropertyName, value); }
}
public XmlCompletionDataProvider GetProvider(string fileName)
{
XmlSchemaFileAssociation schemaFileAssociation = GetSchemaFileAssociation(fileName);
XmlSchemaCompletionData defaultSchemaCompletionData = schemas[schemaFileAssociation.NamespaceUri];
return new XmlCompletionDataProvider(schemas, defaultSchemaCompletionData, schemaFileAssociation.NamespacePrefix);
}
}
}

4
src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlElementPath.cs

@ -30,6 +30,10 @@ namespace ICSharpCode.XmlEditor @@ -30,6 +30,10 @@ namespace ICSharpCode.XmlEditor
get { return elements; }
}
public bool IsEmpty {
get { return elements.IsEmpty; }
}
/// <summary>
/// Compacts the path so it only contains the elements that are from
/// the namespace of the last element in the path.

4
src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlSchemaCompletionData.cs

@ -130,7 +130,7 @@ namespace ICSharpCode.XmlEditor @@ -130,7 +130,7 @@ namespace ICSharpCode.XmlEditor
/// <summary>
/// Gets the possible root elements for an xml document using this schema.
/// </summary>
public DefaultCompletionItemList GetElementCompletionData()
public XmlCompletionItemList GetElementCompletionData()
{
return GetElementCompletionData(String.Empty);
}
@ -138,7 +138,7 @@ namespace ICSharpCode.XmlEditor @@ -138,7 +138,7 @@ namespace ICSharpCode.XmlEditor
/// <summary>
/// Gets the possible root elements for an xml document using this schema.
/// </summary>
public DefaultCompletionItemList GetElementCompletionData(string namespacePrefix)
public XmlCompletionItemList GetElementCompletionData(string namespacePrefix)
{
XmlCompletionItemCollection data = new XmlCompletionItemCollection();

22
src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlSchemaCompletionDataCollection.cs

@ -33,9 +33,9 @@ namespace ICSharpCode.XmlEditor @@ -33,9 +33,9 @@ namespace ICSharpCode.XmlEditor
/// <param name='val'>
/// A <see cref='XmlSchemaCompletionDataCollection'/> from which the contents are copied
/// </param>
public XmlSchemaCompletionDataCollection(XmlSchemaCompletionDataCollection val)
public XmlSchemaCompletionDataCollection(XmlSchemaCompletionDataCollection schemas)
{
this.AddRange(val);
this.AddRange(schemas);
}
/// <summary>
@ -44,12 +44,12 @@ namespace ICSharpCode.XmlEditor @@ -44,12 +44,12 @@ namespace ICSharpCode.XmlEditor
/// <param name='val'>
/// A array of <see cref='XmlSchemaCompletionData'/> objects with which to intialize the collection
/// </param>
public XmlSchemaCompletionDataCollection(XmlSchemaCompletionData[] val)
public XmlSchemaCompletionDataCollection(XmlSchemaCompletionData[] schemas)
{
this.AddRange(val);
this.AddRange(schemas);
}
public DefaultCompletionItemList GetNamespaceCompletionData()
public XmlCompletionItemList GetNamespaceCompletionData()
{
XmlCompletionItemList list = new XmlCompletionItemList();
@ -79,10 +79,10 @@ namespace ICSharpCode.XmlEditor @@ -79,10 +79,10 @@ namespace ICSharpCode.XmlEditor
/// An array of type <see cref='XmlSchemaCompletionData'/> containing the objects to add to the collection.
/// </param>
/// <seealso cref='XmlSchemaCompletionDataCollection.Add'/>
public void AddRange(XmlSchemaCompletionData[] val)
public void AddRange(XmlSchemaCompletionData[] schema)
{
for (int i = 0; i < val.Length; i++) {
this.Add(val[i]);
for (int i = 0; i < schema.Length; i++) {
this.Add(schema[i]);
}
}
@ -93,10 +93,10 @@ namespace ICSharpCode.XmlEditor @@ -93,10 +93,10 @@ namespace ICSharpCode.XmlEditor
/// A <see cref='XmlSchemaCompletionDataCollection'/> containing the objects to add to the collection.
/// </param>
/// <seealso cref='XmlSchemaCompletionDataCollection.Add'/>
public void AddRange(XmlSchemaCompletionDataCollection val)
public void AddRange(XmlSchemaCompletionDataCollection schemas)
{
for (int i = 0; i < val.Count; i++) {
this.Add(val[i]);
for (int i = 0; i < schemas.Count; i++) {
this.Add(schemas[i]);
}
}

11
src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlTreeView.cs

@ -25,11 +25,14 @@ namespace ICSharpCode.XmlEditor @@ -25,11 +25,14 @@ namespace ICSharpCode.XmlEditor
public class XmlTreeView : AbstractSecondaryViewContent, IClipboardHandler
{
XmlTreeViewContainerControl treeViewContainer;
XmlCodeCompletionBinding xmlCompletionBinding;
XmlEditorOptions options;
bool ignoreDirtyChange;
public XmlTreeView(IViewContent parent)
public XmlTreeView(IViewContent parent, XmlEditorOptions options)
: base(parent)
{
this.options = options;
this.TabPageText = "${res:ICSharpCode.XmlEditor.XmlTreeView.Title}";
this.treeViewContainer = new XmlTreeViewContainerControl();
this.treeViewContainer.DirtyChanged += TreeViewContainerDirtyChanged;
@ -126,15 +129,13 @@ namespace ICSharpCode.XmlEditor @@ -126,15 +129,13 @@ namespace ICSharpCode.XmlEditor
#endregion
public override object Control {
get {
return this.treeViewContainer;
}
get { return this.treeViewContainer; }
}
protected override void LoadFromPrimary()
{
IFileDocumentProvider provider = this.PrimaryViewContent as IFileDocumentProvider;
treeViewContainer.LoadXml(provider.GetDocumentForFile(this.PrimaryFile).Text, XmlCodeCompletionBinding.GetProvider(Path.GetExtension(this.PrimaryFileName)));
treeViewContainer.LoadXml(provider.GetDocumentForFile(this.PrimaryFile).Text, options.GetProvider(this.PrimaryFileName));
XmlView view = XmlView.ForFile(this.PrimaryFile);
if (view != null) {
XmlView.CheckIsWellFormed(view.TextEditor);

2
src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlView.cs

@ -76,7 +76,7 @@ namespace ICSharpCode.XmlEditor @@ -76,7 +76,7 @@ namespace ICSharpCode.XmlEditor
public XmlCompletionDataProvider GetProvider()
{
return XmlCodeCompletionBinding.GetProvider(Path.GetExtension(File.FileName));
return XmlEditorService.XmlEditorOptions.GetProvider(File.FileName);
}
public ITextEditor TextEditor

58
src/AddIns/DisplayBindings/XmlEditor/Test/Completion/AttributeCompletionWindowTestFixture.cs

@ -0,0 +1,58 @@ @@ -0,0 +1,58 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using System.IO;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Editor.CodeCompletion;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using XmlEditor.Tests.Utils;
namespace XmlEditor.Tests.Completion
{
[TestFixture]
public class AttributeCompletionWindowTestFixture
{
MockTextEditor textEditor;
CodeCompletionKeyPressResult keyPressResult;
XmlSchemaCompletionDataCollection schemas;
[SetUp]
public void Init()
{
schemas = new XmlSchemaCompletionDataCollection();
schemas.Add(new XmlSchemaCompletionData(ResourceManager.GetXsdSchema()));
XmlEditorOptions options = new XmlEditorOptions(new Properties(), new DefaultXmlSchemaFileAssociations(new AddInTreeNode()), schemas);
options.SetSchemaFileAssociation(new XmlSchemaFileAssociation(".xsd", "http://www.w3.org/2001/XMLSchema", "xs"));
textEditor = new MockTextEditor();
textEditor.FileName = new FileName(@"c:\projects\test.xsd");
textEditor.Document.Text = "<xs:schema></xs:schema>";
// Put cursor after the first 'a' in "<xs:schema>"
textEditor.Caret.Offset = 10;
XmlCodeCompletionBinding completionBinding = new XmlCodeCompletionBinding(options);
keyPressResult = completionBinding.HandleKeyPress(textEditor, ' ');
}
[Test]
public void KeyPressResultIsCompletedAfterPressingSpaceBar()
{
Assert.AreEqual(CodeCompletionKeyPressResult.Completed, keyPressResult);
}
[Test]
public void CompletionListUsedInShowCompletionWindowHasItems()
{
Assert.IsTrue(textEditor.CompletionItemsDisplayedToArray().Length > 0);
}
}
}

82
src/AddIns/DisplayBindings/XmlEditor/Test/Completion/CtrlSpaceAttributeValueCompletionTestFixture.cs

@ -0,0 +1,82 @@ @@ -0,0 +1,82 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Editor.CodeCompletion;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using XmlEditor.Tests.Utils;
namespace XmlEditor.Tests.Completion
{
[TestFixture]
public class CtrlSpaceAttributeValueCompletionTestFixture
{
bool result;
MockTextEditor textEditor;
XmlCodeCompletionBinding completionBinding;
XmlEditorOptions options;
XmlSchemaCompletionData xsdSchema;
[SetUp]
public void Init()
{
XmlSchemaCompletionDataCollection schemas = new XmlSchemaCompletionDataCollection();
xsdSchema = new XmlSchemaCompletionData(ResourceManager.GetXsdSchema());
schemas.Add(xsdSchema);
options = new XmlEditorOptions(new Properties(), new DefaultXmlSchemaFileAssociations(new AddInTreeNode()), schemas);
options.SetSchemaFileAssociation(new XmlSchemaFileAssociation(".xsd", "http://www.w3.org/2001/XMLSchema", "xs"));
textEditor = new MockTextEditor();
textEditor.FileName = new FileName(@"c:\projects\test.xsd");
textEditor.Document.Text = "<xs:schema elementFormDefault=\"\"></xs:schema>";
// Put cursor inside the double quotes following the elementFormDefault attribute
textEditor.Caret.Offset = 31;
completionBinding = new XmlCodeCompletionBinding(options);
result = completionBinding.CtrlSpace(textEditor);
}
[Test]
public void CtrlSpaceMethodResultIsTrueWhenCursorIsInsideAttributeValue()
{
Assert.IsTrue(result);
}
[Test]
public void CtrlSpaceMethodResultIsFalseWhenCursorIsOutsideAttributeValue()
{
textEditor.Caret.Offset = 0;
Assert.IsFalse(completionBinding.CtrlSpace(textEditor));
}
[Test]
public void ShowCompletionWindowCalledWithCompletionItems()
{
ICompletionItem[] items = textEditor.CompletionItemsDisplayedToArray();
ICompletionItem[] expectedItems = GetXsdSchemaElementFormDefaultAttributeValues();
Assert.AreEqual(expectedItems, items);
}
ICompletionItem[] GetXsdSchemaElementFormDefaultAttributeValues()
{
XmlElementPath path = new XmlElementPath();
path.Elements.Add(new QualifiedName("schema", "http://www.w3.org/2001/XMLSchema", "xs"));
return xsdSchema.GetAttributeValueCompletionData(path, "elementFormDefault");
}
[Test]
public void ElementFormDefaultAttributeHasAttributeValues()
{
Assert.IsTrue(GetXsdSchemaElementFormDefaultAttributeValues().Length > 0);
}
}
}

55
src/AddIns/DisplayBindings/XmlEditor/Test/Completion/CtrlSpaceNoAttributeValuesForCompletionTestFixture.cs

@ -0,0 +1,55 @@ @@ -0,0 +1,55 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Editor.CodeCompletion;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using XmlEditor.Tests.Utils;
namespace XmlEditor.Tests.Completion
{
[TestFixture]
public class CtrlSpaceNoAttributeValuesForCompletionTestFixture
{
bool result;
MockTextEditor textEditor;
XmlCodeCompletionBinding completionBinding;
XmlEditorOptions options;
XmlSchemaCompletionData xsdSchema;
[SetUp]
public void Init()
{
XmlSchemaCompletionDataCollection schemas = new XmlSchemaCompletionDataCollection();
options = new XmlEditorOptions(new Properties(), new DefaultXmlSchemaFileAssociations(new AddInTreeNode()), schemas);
textEditor = new MockTextEditor();
textEditor.FileName = new FileName(@"c:\projects\test.xsd");
textEditor.Document.Text = "<xs:schema elementFormDefault=\"\"></xs:schema>";
// Put cursor inside the double quotes following the elementFormDefault attribute
textEditor.Caret.Offset = 31;
completionBinding = new XmlCodeCompletionBinding(options);
result = completionBinding.CtrlSpace(textEditor);
}
[Test]
public void ShowCompletionWindowIsNotCalledWhenThereAreNoCompletionItems()
{
Assert.IsFalse(textEditor.IsShowCompletionWindowMethodCalled);
}
[Test]
public void CtrlSpaceMethodReturnsFalse()
{
Assert.IsFalse(result);
}
}
}

57
src/AddIns/DisplayBindings/XmlEditor/Test/Completion/ElementCompletionWindowTestFixture.cs

@ -0,0 +1,57 @@ @@ -0,0 +1,57 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using System.IO;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Editor.CodeCompletion;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using XmlEditor.Tests.Utils;
namespace XmlEditor.Tests.Completion
{
[TestFixture]
public class ElementCompletionWindowTestFixture
{
MockTextEditor textEditor;
CodeCompletionKeyPressResult keyPressResult;
XmlSchemaCompletionDataCollection schemas;
[SetUp]
public void Init()
{
schemas = new XmlSchemaCompletionDataCollection();
schemas.Add(new XmlSchemaCompletionData(ResourceManager.GetXhtmlStrictSchema()));
XmlEditorOptions options = new XmlEditorOptions(new Properties(), new DefaultXmlSchemaFileAssociations(new AddInTreeNode()), schemas);
options.SetSchemaFileAssociation(new XmlSchemaFileAssociation(".xml", "http://www.w3.org/1999/xhtml"));
textEditor = new MockTextEditor();
textEditor.Document.Text = String.Empty;
textEditor.FileName = new FileName(@"c:\projects\test.xml");
textEditor.Caret.Offset = 0;
XmlCodeCompletionBinding completionBinding = new XmlCodeCompletionBinding(options);
keyPressResult = completionBinding.HandleKeyPress(textEditor, '<');
}
[Test]
public void KeyPressResultIsCompletedAfterPressingEqualsSign()
{
Assert.AreEqual(CodeCompletionKeyPressResult.Completed, keyPressResult);
}
[Test]
public void CompletionWindowWidthIsNotSetToMatchLongestNamespaceTextWidth()
{
Assert.AreNotEqual(double.NaN, textEditor.CompletionWindowDisplayed.Width);
}
}
}

46
src/AddIns/DisplayBindings/XmlEditor/Test/Completion/FirstCompletionListItemSelectedTestFixture.cs

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using ICSharpCode.SharpDevelop.Editor.CodeCompletion;
using ICSharpCode.TextEditor;
@ -19,7 +18,7 @@ namespace XmlEditor.Tests.Completion @@ -19,7 +18,7 @@ namespace XmlEditor.Tests.Completion
{
/// <summary>
/// Tests that the first item in the completion list view is selected by
/// default. When coding in C# the default is to not selected the
/// default. When coding in C# the default is to not select the
/// first item in the completion list. With XML there tends to not
/// be very many items in the completion list so selecting the first
/// one can often make editing quicker.
@ -30,17 +29,19 @@ namespace XmlEditor.Tests.Completion @@ -30,17 +29,19 @@ namespace XmlEditor.Tests.Completion
XmlCompletionDataProvider provider;
ICompletionItem selectedCompletionData;
ICompletionItemList completionDataItems;
XmlSchemaCompletionData defaultSchema;
IList<ICompletionItem> completionList;
[TestFixtureSetUp]
public void SetUpFixture()
{
XmlSchemaCompletionData schema = new XmlSchemaCompletionData(ResourceManager.GetXhtmlStrictSchema());
defaultSchema = new XmlSchemaCompletionData(ResourceManager.GetXhtmlStrictSchema());
XmlSchemaCompletionDataCollection schemas = new XmlSchemaCompletionDataCollection();
schemas.Add(schema);
provider = new XmlCompletionDataProvider(schemas, schema, string.Empty);
TextEditorControl textEditor = new TextEditorControl();
completionDataItems = provider.GenerateCompletionData("", '<');
schemas.Add(defaultSchema);
provider = new XmlCompletionDataProvider(schemas, defaultSchema, String.Empty);
completionDataItems = provider.GenerateCompletionData(String.Empty, '<');
selectedCompletionData = completionDataItems.SuggestedItem;
completionList = (IList<ICompletionItem>)completionDataItems.Items;
}
/// <summary>
@ -48,38 +49,15 @@ namespace XmlEditor.Tests.Completion @@ -48,38 +49,15 @@ namespace XmlEditor.Tests.Completion
/// data items from the xml completion data provider.
/// </summary>
[Test]
public void HasGeneratedCompletionDataItems()
public void GeneratedCompletionItemsHasMoreThanOneItem()
{
Assert.IsNotNull(completionDataItems);
Assert.IsTrue(completionDataItems.Items.ToArray().Length > 0);
Assert.IsTrue(completionList.Count > 1);
}
/// <summary>
/// Default index should be zero so that the first item in the
/// list view is selected.
/// </summary>
[Test]
public void DefaultIndex()
{
Assert.True(completionDataItems.Items.FirstOrDefault() == selectedCompletionData);
}
[Test]
public void SelectedCompletionDataExists()
{
Assert.IsNotNull(selectedCompletionData);
}
/// <summary>
/// First item returned from completion list view should correspond
/// to the first completion item returned from the xml completion
/// data provider after those items have been sorted.
/// </summary>
[Test]
public void SelectedCompletionDataMatches()
public void SelectedCompletionItemMatchesFirstItemInCompletionList()
{
List<ICompletionItem> items = completionDataItems.Items.OrderBy(item => item.Text).ToList();
Assert.AreEqual(items[0].Text, selectedCompletionData.Text);
Assert.AreSame(completionList[0], selectedCompletionData);
}
}
}

62
src/AddIns/DisplayBindings/XmlEditor/Test/Completion/GetCompletionDataProviderTestFixture.cs

@ -0,0 +1,62 @@ @@ -0,0 +1,62 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.IO;
using ICSharpCode.Core;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
namespace XmlEditor.Tests.Completion
{
[TestFixture]
public class GetCompletionDataProviderTestFixture
{
XmlCompletionDataProvider completionProvider;
XmlSchemaCompletionData defaultSchemaCompletionData;
XmlEditorOptions options;
XmlSchemaCompletionData otherSchema;
[SetUp]
public void Init()
{
XmlSchemaCompletionDataCollection schemas = new XmlSchemaCompletionDataCollection();
options = new XmlEditorOptions(new Properties(), new DefaultXmlSchemaFileAssociations(new AddInTreeNode()), schemas);
XmlSchemaFileAssociation schemaFileAssociation = new XmlSchemaFileAssociation(".xml", "http://test", "x");
options.SetSchemaFileAssociation(schemaFileAssociation);
string xml = "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' targetNamespace='http://test' />";
defaultSchemaCompletionData = new XmlSchemaCompletionData(new StringReader(xml));
schemas.Add(defaultSchemaCompletionData);
xml = "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' targetNamespace='http://other-schema' />";
otherSchema = new XmlSchemaCompletionData(new StringReader(xml));
schemas.Add(otherSchema);
completionProvider = options.GetProvider(".xml");
}
[Test]
public void XmlCompletionDataProviderCreatedWithCorrectDefaultNamespacePrefix()
{
Assert.AreEqual("x", completionProvider.DefaultNamespacePrefix);
}
[Test]
public void XmlCompletionDataProviderCreatedWithCorrectDefaultSchemaCompletionData()
{
Assert.AreSame(defaultSchemaCompletionData, completionProvider.DefaultSchemaCompletionData);
}
[Test]
public void XmlCompletionDataProviderCreatedWithSchemasCollection()
{
Assert.AreSame(otherSchema, completionProvider.FindSchema("http://other-schema"));
}
}
}

61
src/AddIns/DisplayBindings/XmlEditor/Test/Completion/NamespaceCompletionWindowTestFixture.cs

@ -0,0 +1,61 @@ @@ -0,0 +1,61 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using System.IO;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Editor.CodeCompletion;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using XmlEditor.Tests.Utils;
namespace XmlEditor.Tests.Completion
{
[TestFixture]
public class NamespaceCompletionWindowTestFixture : NamespaceCompletionWindowTestFixtureBase
{
[SetUp]
public void Init()
{
base.InitBase();
XmlCodeCompletionBinding completionBinding = new XmlCodeCompletionBinding(options);
keyPressResult = completionBinding.HandleKeyPress(textEditor, '=');
}
[Test]
public void KeyPressResultIsCompletedAfterPressingEqualsSign()
{
Assert.AreEqual(CodeCompletionKeyPressResult.Completed, keyPressResult);
}
[Test]
public void CompletionWindowWidthSetToMatchLongestNamespaceTextWidth()
{
Assert.AreEqual(double.NaN, textEditor.CompletionWindowDisplayed.Width);
}
[Test]
public void ExpectedCompletionDataItems()
{
XmlCompletionItemCollection expectedItems = new XmlCompletionItemCollection();
expectedItems.Add(new XmlCompletionItem("a", XmlCompletionDataType.NamespaceUri));
expectedItems.Add(new XmlCompletionItem("b", XmlCompletionDataType.NamespaceUri));
expectedItems.Add(new XmlCompletionItem("c", XmlCompletionDataType.NamespaceUri));
Assert.AreEqual(expectedItems.ToArray(), textEditor.CompletionItemsDisplayedToArray());
}
[Test]
public void TextEditorDocumentGetTextCalledWithOffsetAndLength()
{
TextSection expectedTextSection = new TextSection(0, 8);
Assert.AreEqual(expectedTextSection, textEditor.MockDocument.GetTextSectionUsedWithGetTextMethod());
}
}
}

53
src/AddIns/DisplayBindings/XmlEditor/Test/Completion/NamespaceCompletionWindowTestFixtureBase.cs

@ -0,0 +1,53 @@ @@ -0,0 +1,53 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using System.IO;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Editor.CodeCompletion;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using XmlEditor.Tests.Utils;
namespace XmlEditor.Tests.Completion
{
public class NamespaceCompletionWindowTestFixtureBase
{
protected MockTextEditor textEditor;
protected CodeCompletionKeyPressResult keyPressResult;
protected XmlSchemaCompletionDataCollection schemas;
protected XmlEditorOptions options;
protected void InitBase()
{
schemas = new XmlSchemaCompletionDataCollection();
AddSchemas();
options = new XmlEditorOptions(new Properties(), new DefaultXmlSchemaFileAssociations(new AddInTreeNode()), schemas);
textEditor = new MockTextEditor();
textEditor.Document.Text = "<a xmlns></a>";
textEditor.FileName = new FileName(@"c:\projects\test.xml");
// Put caret just after "xmlns".
textEditor.Caret.Offset = 8;
}
void AddSchemas()
{
string xml = "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' targetNamespace='c' />";
schemas.Add(new XmlSchemaCompletionData(new StringReader(xml)));
xml = "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' targetNamespace='b' />";
schemas.Add(new XmlSchemaCompletionData(new StringReader(xml)));
xml = "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' targetNamespace='a' />";
schemas.Add(new XmlSchemaCompletionData(new StringReader(xml)));
}
}
}

34
src/AddIns/DisplayBindings/XmlEditor/Test/Completion/NoCompletionItemsTestFixture.cs

@ -0,0 +1,34 @@ @@ -0,0 +1,34 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
namespace XmlEditor.Tests.Completion
{
[TestFixture]
public class NoCompletionItemsTestFixture : NamespaceCompletionWindowTestFixtureBase
{
[SetUp]
public void Init()
{
base.InitBase();
schemas.Clear();
XmlCodeCompletionBinding completionBinding = new XmlCodeCompletionBinding(options);
keyPressResult = completionBinding.HandleKeyPress(textEditor, '=');
}
[Test]
public void TextEditorShowCompletionWindowNotCalledWhenNoCompletionItems()
{
Assert.IsFalse(textEditor.IsShowCompletionWindowMethodCalled);
}
}
}

47
src/AddIns/DisplayBindings/XmlEditor/Test/Completion/NullCompletionItemsReturnedTestFixture.cs

@ -0,0 +1,47 @@ @@ -0,0 +1,47 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using System.IO;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Editor.CodeCompletion;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using XmlEditor.Tests.Utils;
namespace XmlEditor.Tests.Completion
{
[TestFixture]
public class NullCompletionItemsReturnedTestFixture
{
MockTextEditor textEditor;
XmlSchemaCompletionDataCollection schemas;
XmlCodeCompletionBinding completionBinding;
[SetUp]
public void Init()
{
schemas = new XmlSchemaCompletionDataCollection();
XmlEditorOptions options = new XmlEditorOptions(new Properties(), new DefaultXmlSchemaFileAssociations(new AddInTreeNode()), schemas);
textEditor = new MockTextEditor();
textEditor.FileName = new FileName(@"c:\projects\test.xsd");
textEditor.Document.Text = "";
textEditor.Caret.Offset = 0;
completionBinding = new XmlCodeCompletionBinding(options);
}
[Test]
public void NullReferenceExceptionNotThrownWhenCallingHandleKeyPress()
{
Assert.DoesNotThrow(delegate { completionBinding.HandleKeyPress(textEditor, '='); } );
}
}
}

33
src/AddIns/DisplayBindings/XmlEditor/Test/Completion/ProcessKeyTests.cs

@ -14,42 +14,39 @@ using XmlEditor.Tests.Utils; @@ -14,42 +14,39 @@ using XmlEditor.Tests.Utils;
namespace XmlEditor.Tests.Completion
{
/// <summary>
/// Tests the XmlCompletionDataProvider's ProcessKey method.
/// </summary>
[TestFixture]
public class ProcessKeyTests
public class CompletionListProcessKeyTests
{
ICompletionItemList list;
XmlCompletionItemList completionItemList;
[SetUp]
public void Init()
{
XmlSchemaCompletionData schema = new XmlSchemaCompletionData(ResourceManager.GetXhtmlStrictSchema());
XmlSchemaCompletionDataCollection schemas = new XmlSchemaCompletionDataCollection();
schemas.Add(schema);
list = new XmlCompletionDataProvider(schemas, schema, "").GenerateCompletionData("", '<');
completionItemList = new XmlCompletionItemList();
}
/// <summary>
/// A space character should be treated as a normal character.
/// </summary>
[Test]
public void SpaceChar()
public void ProcessInputWithSpaceCharReturnsNormalKey()
{
Assert.AreEqual(CompletionItemListKeyResult.NormalKey, list.ProcessInput(' '));
Assert.AreEqual(CompletionItemListKeyResult.NormalKey, completionItemList.ProcessInput(' '));
}
[Test]
public void TabChar()
public void ProcessInputWithTabCharReturnsInsertionKey()
{
Assert.AreEqual(CompletionItemListKeyResult.InsertionKey, list.ProcessInput('\t'));
Assert.AreEqual(CompletionItemListKeyResult.InsertionKey, completionItemList.ProcessInput('\t'));
}
[Test]
public void ReturnChar()
public void ProcessInputWithColonCharReturnsNormalKey()
{
Assert.AreEqual(CompletionItemListKeyResult.InsertionKey, list.ProcessInput((char)Keys.Return));
Assert.AreEqual(CompletionItemListKeyResult.NormalKey, completionItemList.ProcessInput(':'));
}
[Test]
public void ProcessInputWithDotCharReturnsNormalKey()
{
Assert.AreEqual(CompletionItemListKeyResult.NormalKey, completionItemList.ProcessInput('.'));
}
}
}

33
src/AddIns/DisplayBindings/XmlEditor/Test/Completion/ShowCompletionWindowReturnsNullTestFixture.cs

@ -0,0 +1,33 @@ @@ -0,0 +1,33 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using System.IO;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Editor.CodeCompletion;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using XmlEditor.Tests.Utils;
namespace XmlEditor.Tests.Completion
{
[TestFixture]
public class ShowCompletionWindowReturnsNullTestFixture : NamespaceCompletionWindowTestFixtureBase
{
[Test]
public void CompletionBindingHandleKeyPressDoesNotThrowNullReferenceException()
{
base.InitBase();
textEditor.ShowCompletionWindowReturnsNull = true;
XmlCodeCompletionBinding completionBinding = new XmlCodeCompletionBinding(options);
Assert.DoesNotThrow(delegate { keyPressResult = completionBinding.HandleKeyPress(textEditor, '='); });
}
}
}

35
src/AddIns/DisplayBindings/XmlEditor/Test/Completion/XmlCompletionItemCollectionTests.cs

@ -0,0 +1,35 @@ @@ -0,0 +1,35 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
namespace XmlEditor.Tests.Completion
{
[TestFixture]
public class XmlCompletionItemCollectionTests
{
[Test]
public void CollectionToArrayReturnsExpectedArray()
{
XmlCompletionItem firstItem = new XmlCompletionItem("text", "desc", XmlCompletionDataType.XmlElement);
XmlCompletionItem secondItem = new XmlCompletionItem("text2", "desc", XmlCompletionDataType.XmlAttribute);
List<XmlCompletionItem> items = new List<XmlCompletionItem>();
items.Add(firstItem);
items.Add(secondItem);
XmlCompletionItemCollection itemCollection = new XmlCompletionItemCollection();
itemCollection.Add(firstItem);
itemCollection.Add(secondItem);
Assert.AreEqual(items.ToArray(), itemCollection.ToArray());
}
}
}

51
src/AddIns/DisplayBindings/XmlEditor/Test/Completion/XmlCompletionItemIsEqualTests.cs

@ -0,0 +1,51 @@ @@ -0,0 +1,51 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
namespace XmlEditor.Tests.Completion
{
[TestFixture]
public class XmlCompletionItemIsEqualTests
{
[Test]
public void TwoItemsAreEqualIfTextAndXmlCompletionDataTypeAreEqual()
{
XmlCompletionItem lhs = new XmlCompletionItem("text", "description", XmlCompletionDataType.XmlElement);
XmlCompletionItem rhs = new XmlCompletionItem("text", "description", XmlCompletionDataType.XmlElement);
Assert.IsTrue(lhs.Equals(rhs));
}
[Test]
public void TwoItemsAreNotEqualIfTextIsDifferent()
{
XmlCompletionItem lhs = new XmlCompletionItem("text", "description", XmlCompletionDataType.XmlElement);
XmlCompletionItem rhs = new XmlCompletionItem("different-text", "description", XmlCompletionDataType.XmlElement);
Assert.IsFalse(lhs.Equals(rhs));
}
[Test]
public void TwoItemsAreNotEqualIfXmlCompletionDataTypeIsDifferent()
{
XmlCompletionItem lhs = new XmlCompletionItem("text", "description", XmlCompletionDataType.XmlElement);
XmlCompletionItem rhs = new XmlCompletionItem("text", "description", XmlCompletionDataType.XmlAttribute);
Assert.IsFalse(lhs.Equals(rhs));
}
[Test]
public void NullIsNotEqualToCompletionItem()
{
XmlCompletionItem lhs = new XmlCompletionItem("text");
Assert.IsFalse(lhs.Equals(null));
}
}
}

8
src/AddIns/DisplayBindings/XmlEditor/Test/Editor/DefaultXmlEditorOptionsTestFixture.cs

@ -154,6 +154,14 @@ namespace XmlEditor.Tests.Editor @@ -154,6 +154,14 @@ namespace XmlEditor.Tests.Editor
properties.Set("ext.abc", ".abc|namespace-uri|prefix");
Assert.AreEqual(expectedSchemaAssociation, options.GetSchemaFileAssociation(".ABC"));
}
[Test]
public void RegisteredSchemaAssociationMatchedByFullFileNameInsteadOfExtension()
{
XmlSchemaFileAssociation expectedSchemaAssociation = new XmlSchemaFileAssociation(".abc", "namespace-uri", "prefix");
properties.Set("ext.abc", ".abc|namespace-uri|prefix");
Assert.AreEqual(expectedSchemaAssociation, options.GetSchemaFileAssociation(@"d:\projects\a.abc"));
}
[Test]
public void DefaultXmlExtensionRevertedToIfNoFileExtensionSavedInXmlEditorOptionsProperties()

9
src/AddIns/DisplayBindings/XmlEditor/Test/Paths/NoElementPathTestFixture.cs

@ -25,8 +25,13 @@ namespace XmlEditor.Tests.Paths @@ -25,8 +25,13 @@ namespace XmlEditor.Tests.Paths
[Test]
public void HasNoItems()
{
Assert.AreEqual(0, path.Elements.Count,
"Should not be any elements.");
Assert.AreEqual(0, path.Elements.Count);
}
[Test]
public void PathIsEmpty()
{
Assert.IsTrue(path.IsEmpty);
}
[Test]

19
src/AddIns/DisplayBindings/XmlEditor/Test/Paths/QualifiedNameCollectionTests.cs

@ -55,7 +55,7 @@ namespace XmlEditor.Tests.Paths @@ -55,7 +55,7 @@ namespace XmlEditor.Tests.Paths
public void RemoveFirstItemFromEmptyCollectionDoesNotThrowArgumentOutOfRangeException()
{
qualifiedNameCollection = new QualifiedNameCollection();
qualifiedNameCollection.RemoveFirst();
Assert.DoesNotThrow(delegate { qualifiedNameCollection.RemoveFirst(); });
}
[Test]
@ -76,7 +76,7 @@ namespace XmlEditor.Tests.Paths @@ -76,7 +76,7 @@ namespace XmlEditor.Tests.Paths
public void RemoveLastItemFromEmptyCollectionDoesNotThrowArgumentOutOfRangeException()
{
qualifiedNameCollection = new QualifiedNameCollection();
qualifiedNameCollection.RemoveLast();
Assert.DoesNotThrow(delegate { qualifiedNameCollection.RemoveLast(); });
}
[Test]
@ -140,8 +140,21 @@ namespace XmlEditor.Tests.Paths @@ -140,8 +140,21 @@ namespace XmlEditor.Tests.Paths
[Test]
public void RemovingMoreItemsThanInCollectionDoesNotThrowArgumentOutOfRangeException()
{
qualifiedNameCollection.RemoveFirst(5);
Assert.DoesNotThrow(delegate { qualifiedNameCollection.RemoveFirst(5); });
Assert.AreEqual(0, qualifiedNameCollection.Count);
}
[Test]
public void NewQualifiedNameCollectionIsEmpty()
{
qualifiedNameCollection = new QualifiedNameCollection();
Assert.IsTrue(qualifiedNameCollection.IsEmpty);
}
[Test]
public void QualifiedNameCollectionWithItemsIsNotEmpty()
{
Assert.IsFalse(qualifiedNameCollection.IsEmpty);
}
}
}

3
src/AddIns/DisplayBindings/XmlEditor/Test/Tree/XmlTreeViewClipboardHandlerTestFixture.cs

@ -37,10 +37,11 @@ namespace XmlEditor.Tests.Tree @@ -37,10 +37,11 @@ namespace XmlEditor.Tests.Tree
[SetUp]
public void SetUp()
{
XmlEditorOptions options = new XmlEditorOptions(new Properties(), new DefaultXmlSchemaFileAssociations(new AddInTreeNode()), new XmlSchemaCompletionDataCollection());
MockOpenedFile openedFile = new MockOpenedFile("test.xml");
XmlSchemaCompletionDataCollection schemas = new XmlSchemaCompletionDataCollection();
xmlView = new MockXmlViewContent(openedFile);
view = new XmlTreeView(xmlView);
view = new XmlTreeView(xmlView, options);
treeViewContainer = (XmlTreeViewContainerControl)view.Control;
treeView = treeViewContainer.TreeView;
clipboardHandler = view as IClipboardHandler;

63
src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockCaret.cs

@ -0,0 +1,63 @@ @@ -0,0 +1,63 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using ICSharpCode.NRefactory;
using ICSharpCode.SharpDevelop.Editor;
namespace XmlEditor.Tests.Utils
{
public class MockCaret : ITextEditorCaret
{
int offset = -1;
public MockCaret()
{
}
public event EventHandler PositionChanged;
protected virtual void OnPositionChanged(EventArgs e)
{
if (PositionChanged != null) {
PositionChanged(this, e);
}
}
public int Offset {
get { return offset; }
set { offset = value; }
}
public int Line {
get {
throw new NotImplementedException();
}
set {
throw new NotImplementedException();
}
}
public int Column {
get {
throw new NotImplementedException();
}
set {
throw new NotImplementedException();
}
}
public Location Position {
get {
throw new NotImplementedException();
}
set {
throw new NotImplementedException();
}
}
}
}

85
src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockCompletionListWindow.cs

@ -0,0 +1,85 @@ @@ -0,0 +1,85 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using ICSharpCode.SharpDevelop.Editor.CodeCompletion;
namespace XmlEditor.Tests.Utils
{
public class MockCompletionListWindow : ICompletionListWindow
{
double width = 0.0;
public MockCompletionListWindow()
{
}
public event EventHandler Closed;
protected virtual void OnClosed(EventArgs e)
{
if (Closed != null) {
Closed(this, e);
}
}
public ICompletionItem SelectedItem {
get {
throw new NotImplementedException();
}
set {
throw new NotImplementedException();
}
}
public double Width {
get { return width; }
set { width = value; }
}
public double Height {
get {
throw new NotImplementedException();
}
set {
throw new NotImplementedException();
}
}
public bool CloseAutomatically {
get {
throw new NotImplementedException();
}
set {
throw new NotImplementedException();
}
}
public int StartOffset {
get {
throw new NotImplementedException();
}
set {
throw new NotImplementedException();
}
}
public int EndOffset {
get {
throw new NotImplementedException();
}
set {
throw new NotImplementedException();
}
}
public void Close()
{
throw new NotImplementedException();
}
}
}

148
src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockDocument.cs

@ -0,0 +1,148 @@ @@ -0,0 +1,148 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.IO;
using ICSharpCode.NRefactory;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Editor;
namespace XmlEditor.Tests.Utils
{
public class MockDocument : IDocument
{
string text = String.Empty;
TextSection textSectionUsedWithGetTextMethod;
public MockDocument()
{
}
public event EventHandler TextChanged;
protected virtual void OnTextChanged(EventArgs e)
{
if (TextChanged != null) {
TextChanged(this, e);
}
}
public string Text {
get { return text; }
set { text = value; }
}
public int TotalNumberOfLines {
get {
throw new NotImplementedException();
}
}
public ITextBufferVersion Version {
get {
throw new NotImplementedException();
}
}
public int TextLength {
get {
throw new NotImplementedException();
}
}
public IDocumentLine GetLine(int lineNumber)
{
throw new NotImplementedException();
}
public IDocumentLine GetLineForOffset(int offset)
{
throw new NotImplementedException();
}
public int PositionToOffset(int line, int column)
{
throw new NotImplementedException();
}
public Location OffsetToPosition(int offset)
{
throw new NotImplementedException();
}
public void Insert(int offset, string text)
{
throw new NotImplementedException();
}
public void Remove(int offset, int length)
{
throw new NotImplementedException();
}
public void Replace(int offset, int length, string newText)
{
throw new NotImplementedException();
}
public void StartUndoableAction()
{
throw new NotImplementedException();
}
public void EndUndoableAction()
{
throw new NotImplementedException();
}
public IDisposable OpenUndoGroup()
{
throw new NotImplementedException();
}
public ITextAnchor CreateAnchor(int offset)
{
throw new NotImplementedException();
}
public ITextBuffer CreateSnapshot()
{
throw new NotImplementedException();
}
public ITextBuffer CreateSnapshot(int offset, int length)
{
throw new NotImplementedException();
}
public TextReader CreateReader()
{
throw new NotImplementedException();
}
public char GetCharAt(int offset)
{
throw new NotImplementedException();
}
public string GetText(int offset, int length)
{
textSectionUsedWithGetTextMethod = new TextSection(offset, length);
return text.Substring(offset, length);
}
public TextSection GetTextSectionUsedWithGetTextMethod()
{
return textSectionUsedWithGetTextMethod;
}
public object GetService(Type serviceType)
{
throw new NotImplementedException();
}
}
}

188
src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockTextEditor.cs

@ -0,0 +1,188 @@ @@ -0,0 +1,188 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using System.Windows.Input;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.CodeCompletion;
using ICSharpCode.TextEditor.Gui.CompletionWindow;
namespace XmlEditor.Tests.Utils
{
public class MockTextEditor : ITextEditor
{
MockCompletionListWindow completionWindowDisplayed;
ICompletionItemList completionItemsDisplayed;
MockCaret caret = new MockCaret();
MockDocument document = new MockDocument();
FileName fileName;
bool showCompletionWindowReturnsNull;
bool showCompletionWindowMethodCalled;
public MockTextEditor()
{
}
public event EventHandler SelectionChanged;
protected virtual void OnSelectionChanged(EventArgs e)
{
if (SelectionChanged != null) {
SelectionChanged(this, e);
}
}
public event KeyEventHandler KeyPress;
protected virtual void OnKeyPress(KeyEventArgs e)
{
if (KeyPress != null) {
KeyPress(this, e);
}
}
public ITextEditor PrimaryView {
get {
throw new NotImplementedException();
}
}
public IDocument Document {
get { return document; }
}
public MockDocument MockDocument {
get { return document; }
}
public ITextEditorCaret Caret {
get { return caret; }
}
public ITextEditorOptions Options {
get {
throw new NotImplementedException();
}
}
public ILanguageBinding Language {
get {
throw new NotImplementedException();
}
}
public int SelectionStart {
get {
throw new NotImplementedException();
}
}
public int SelectionLength {
get {
throw new NotImplementedException();
}
}
public string SelectedText {
get {
throw new NotImplementedException();
}
set {
throw new NotImplementedException();
}
}
public FileName FileName {
get { return fileName; }
set { fileName = value; }
}
public ICompletionListWindow ActiveCompletionWindow {
get {
throw new NotImplementedException();
}
}
public IInsightWindow ActiveInsightWindow {
get {
throw new NotImplementedException();
}
}
public void Select(int selectionStart, int selectionLength)
{
throw new NotImplementedException();
}
public void JumpTo(int line, int column)
{
throw new NotImplementedException();
}
public ICompletionListWindow ShowCompletionWindow(ICompletionItemList data)
{
completionItemsDisplayed = data;
showCompletionWindowMethodCalled = true;
if (showCompletionWindowReturnsNull) {
completionWindowDisplayed = null;
} else {
completionWindowDisplayed = new MockCompletionListWindow();
}
return completionWindowDisplayed;
}
public bool IsShowCompletionWindowMethodCalled {
get { return showCompletionWindowMethodCalled; }
}
public bool ShowCompletionWindowReturnsNull {
get { return showCompletionWindowReturnsNull; }
set { showCompletionWindowReturnsNull = value; }
}
public MockCompletionListWindow CompletionWindowDisplayed {
get { return completionWindowDisplayed; }
}
public ICompletionItemList CompletionItemsDisplayed {
get { return completionItemsDisplayed; }
}
public ICompletionItem[] CompletionItemsDisplayedToArray()
{
List<ICompletionItem> items = new List<ICompletionItem>();
foreach (ICompletionItem item in completionItemsDisplayed.Items) {
items.Add(item);
}
return items.ToArray();
}
public IInsightWindow ShowInsightWindow(IEnumerable<IInsightItem> items)
{
throw new NotImplementedException();
}
public IEnumerable<ICompletionItem> GetSnippets()
{
throw new NotImplementedException();
}
public void ShowCompletionWindow(ICompletionDataProvider provider, char ch)
{
throw new NotImplementedException();
}
public object GetService(Type serviceType)
{
throw new NotImplementedException();
}
}
}

72
src/AddIns/DisplayBindings/XmlEditor/Test/Utils/Tests/MockDocumentTests.cs

@ -0,0 +1,72 @@ @@ -0,0 +1,72 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.CodeCompletion;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using XmlEditor.Tests.Utils;
namespace XmlEditor.Tests.Utils.Tests
{
[TestFixture]
public class MockDocumentTests
{
[Test]
public void TextEditorDocumentCanGetOffsetAndLengthUsedAsParametersInGetTextMethod()
{
TextSection expectedSection = new TextSection(0, 5);
MockDocument document = new MockDocument();
document.Text = "abcdefghi";
document.GetText(0, 5);
Assert.AreEqual(expectedSection, document.GetTextSectionUsedWithGetTextMethod());
}
[Test]
public void TextEditorDocumentGetTextReturnsCorrectSectionOfText()
{
TextSection expectedSection = new TextSection(0, 5);
MockDocument document = new MockDocument();
document.Text = "abcdefghi";
Assert.AreEqual("def", document.GetText(3, 3));
}
[Test]
public void TextSectionWithSameOffsetAndLengthAreEqual()
{
TextSection lhs = new TextSection(0, 1);
TextSection rhs = new TextSection(0, 1);
Assert.IsTrue(lhs.Equals(rhs));
}
[Test]
public void TextSectionWithDifferentOffsetAreNotEqual()
{
TextSection lhs = new TextSection(0, 1);
TextSection rhs = new TextSection(1, 1);
Assert.IsFalse(lhs.Equals(rhs));
}
[Test]
public void TextSectionWithDifferentLengthAreNotEqual()
{
TextSection lhs = new TextSection(0, 15);
TextSection rhs = new TextSection(0, 1);
Assert.IsFalse(lhs.Equals(rhs));
}
}
}

116
src/AddIns/DisplayBindings/XmlEditor/Test/Utils/Tests/MockTextEditorTests.cs

@ -0,0 +1,116 @@ @@ -0,0 +1,116 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.CodeCompletion;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using XmlEditor.Tests.Utils;
namespace XmlEditor.Tests.Utils.Tests
{
[TestFixture]
public class MockTextEditorTests
{
MockTextEditor editor;
[SetUp]
public void Init()
{
editor = new MockTextEditor();
}
[Test]
public void CanCheckCompletionWindowFromShowCompletionHasWidthPropertyModified()
{
XmlCompletionItemList list = new XmlCompletionItemList();
list.Items.Add(new XmlCompletionItem("a"));
ICompletionListWindow window = editor.ShowCompletionWindow(list);
window.Width = double.NaN;
Assert.AreEqual(double.NaN, editor.CompletionWindowDisplayed.Width);
}
[Test]
public void CanGetCompletionItemsUsedAsShowCompletionMethodParameters()
{
XmlCompletionItemList list = new XmlCompletionItemList();
list.Items.Add(new XmlCompletionItem("a"));
editor.ShowCompletionWindow(list);
Assert.AreSame(list, editor.CompletionItemsDisplayed);
}
[Test]
public void CanConvertCompletionItemsUsedAsShowCompletionMethodParametersToArray()
{
XmlCompletionItem item = new XmlCompletionItem("a");
List<XmlCompletionItem> expectedArray = new List<XmlCompletionItem>();
expectedArray.Add(item);
XmlCompletionItemList list = new XmlCompletionItemList();
list.Items.Add(item);
editor.ShowCompletionWindow(list);
Assert.AreEqual(expectedArray.ToArray(), editor.CompletionItemsDisplayedToArray());
}
[Test]
public void TextEditorDocumentCanGetAndSetText()
{
editor.Document.Text = "test";
Assert.AreEqual("test", editor.Document.Text);
}
[Test]
public void TextEditorCaretCanGetAndSetCaretOffset()
{
editor.Caret.Offset = 5;
Assert.AreEqual(5, editor.Caret.Offset);
}
[Test]
public void TextEditorMockDocumentPropertyIsSameAsTextEditorDocumentProperty()
{
Assert.AreSame(editor.MockDocument, editor.Document);
}
[Test]
public void TextEditorCanGetAndSetFileName()
{
editor.FileName = new FileName(@"c:\projects\a.xml");
Assert.AreEqual(@"c:\projects\a.xml", editor.FileName.ToString());
}
[Test]
public void TextEditorShowCompletionListReturnsNullWhenConfigured()
{
XmlCompletionItemList list = new XmlCompletionItemList();
list.Items.Add(new XmlCompletionItem("a"));
editor.ShowCompletionWindowReturnsNull = true;
Assert.IsNull(editor.ShowCompletionWindow(list));
}
[Test]
public void TextEditorShowCompletionListIsCalledReturnsTrueIfShowCompletionListMethodReturnsNullWindow()
{
TextEditorShowCompletionListReturnsNullWhenConfigured();
Assert.IsTrue(editor.IsShowCompletionWindowMethodCalled);
}
[Test]
public void IsShowCompletionWindowMethodCalledReturnsFalseByDefault()
{
Assert.IsFalse(editor.IsShowCompletionWindowMethodCalled);
}
}
}

34
src/AddIns/DisplayBindings/XmlEditor/Test/Utils/TextSection.cs

@ -0,0 +1,34 @@ @@ -0,0 +1,34 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
namespace XmlEditor.Tests.Utils
{
public class TextSection
{
int offset;
int length;
public TextSection(int offset, int length)
{
this.offset = offset;
this.length = length;
}
public override bool Equals(object obj)
{
TextSection rhs = obj as TextSection;
return (rhs.offset == offset) && (rhs.length == length);
}
public override int GetHashCode()
{
return base.GetHashCode();
}
}
}

23
src/AddIns/DisplayBindings/XmlEditor/Test/XmlEditor.Tests.csproj

@ -76,8 +76,20 @@ @@ -76,8 +76,20 @@
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />
<Compile Include="Completion\AttributeCompletionWindowTestFixture.cs" />
<Compile Include="Completion\CtrlSpaceAttributeValueCompletionTestFixture.cs" />
<Compile Include="Completion\CtrlSpaceNoAttributeValuesForCompletionTestFixture.cs" />
<Compile Include="Completion\ElementCompletionWindowTestFixture.cs" />
<Compile Include="Completion\FirstCompletionListItemSelectedTestFixture.cs" />
<Compile Include="Completion\GetCompletionDataProviderTestFixture.cs" />
<Compile Include="Completion\NamespaceCompletionWindowTestFixture.cs" />
<Compile Include="Completion\NamespaceCompletionWindowTestFixtureBase.cs" />
<Compile Include="Completion\NoCompletionItemsTestFixture.cs" />
<Compile Include="Completion\NullCompletionItemsReturnedTestFixture.cs" />
<Compile Include="Completion\ProcessKeyTests.cs" />
<Compile Include="Completion\ShowCompletionWindowReturnsNullTestFixture.cs" />
<Compile Include="Completion\XmlCompletionItemCollectionTests.cs" />
<Compile Include="Completion\XmlCompletionItemIsEqualTests.cs" />
<Compile Include="Editor\AddUserSchemaTestFixture.cs" />
<Compile Include="Editor\DefaultSchemaFileAssociationsTestFixture.cs" />
<Compile Include="Editor\DefaultXmlEditorOptionsTestFixture.cs" />
@ -181,8 +193,12 @@ @@ -181,8 +193,12 @@
<Compile Include="Utils\ExceptionErrorMessage.cs" />
<Compile Include="Utils\FormattedErrorMessage.cs" />
<Compile Include="Utils\MockAddXmlNodeDialog.cs" />
<Compile Include="Utils\MockCaret.cs" />
<Compile Include="Utils\MockCompletionListWindow.cs" />
<Compile Include="Utils\MockDocument.cs" />
<Compile Include="Utils\MockFileSystem.cs" />
<Compile Include="Utils\MockSelectXmlSchemaWindow.cs" />
<Compile Include="Utils\MockTextEditor.cs" />
<Compile Include="Utils\MockXmlSchemaCompletionDataFactory.cs" />
<Compile Include="Utils\MockXmlSchemasPanel.cs" />
<Compile Include="Utils\MockXmlTreeView.cs" />
@ -191,10 +207,13 @@ @@ -191,10 +207,13 @@
<Compile Include="Utils\SchemaIncludeTestFixtureHelper.cs" />
<Compile Include="Utils\Tests\ExceptionErrorMessageAreEqualTests.cs" />
<Compile Include="Utils\Tests\FormattedErrorMessageAreEqualTests.cs" />
<Compile Include="Utils\Tests\MockDocumentTests.cs" />
<Compile Include="Utils\Tests\MockFileSystemTests.cs" />
<Compile Include="Utils\Tests\MockSelectXmlSchemaWindowTests.cs" />
<Compile Include="Utils\Tests\MockTextEditorTests.cs" />
<Compile Include="Utils\Tests\MockXmlSchemaCompletionDataFactoryTests.cs" />
<Compile Include="Utils\Tests\MockXmlSchemasPanelTests.cs" />
<Compile Include="Utils\TextSection.cs" />
<Compile Include="XPathQuery\XmlNamespaceTests.cs" />
<Compile Include="XPathQuery\GetNamespacesFromListViewTestFixture.cs" />
<Compile Include="XPathQuery\RunXPathQueryTests.cs" />
@ -257,6 +276,10 @@ @@ -257,6 +276,10 @@
<Name>ICSharpCode.TextEditor</Name>
<Private>True</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Libraries\NRefactory\Project\NRefactory.csproj">
<Project>{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}</Project>
<Name>NRefactory</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Main\Base\Test\ICSharpCode.SharpDevelop.Tests.csproj">
<Project>{4980B743-B32F-4aba-AABD-45E2CAD3568D}</Project>
<Name>ICSharpCode.SharpDevelop.Tests</Name>

8
src/AddIns/DisplayBindings/XmlEditor/XmlEditor.sln

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
# SharpDevelop 4.0.0.5187
# SharpDevelop 4.0.0.5201
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XmlEditor", "Project\XmlEditor.csproj", "{DCA2703D-250A-463E-A68A-07ED105AE6BD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XmlEditor.Tests", "Test\XmlEditor.Tests.csproj", "{FC0FE702-A87D-4D70-A9B6-1ECCD611125F}"
@ -20,6 +20,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Do @@ -20,6 +20,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Do
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.TextEditor", "..\..\..\Libraries\ICSharpCode.TextEditor\Project\ICSharpCode.TextEditor.csproj", "{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactory", "..\..\..\Libraries\NRefactory\Project\NRefactory.csproj", "{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -62,5 +64,9 @@ Global @@ -62,5 +64,9 @@ Global
{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}.Release|Any CPU.Build.0 = Release|Any CPU
{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Release|Any CPU.Build.0 = Release|Any CPU
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Release|Any CPU.ActiveCfg = Release|Any CPU
EndGlobalSection
EndGlobal

Loading…
Cancel
Save