Browse Source

fixed some XML Unit Tests

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/XmlEditor@4182 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Siegfried Pammer 17 years ago
parent
commit
189828942a
  1. 4
      src/AddIns/BackendBindings/WixBinding/Test/WixBinding.Tests.csproj
  2. 32
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlCompletionDataProvider.cs
  3. 2
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlCompletionItemList.cs
  4. 4
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlSchemaCompletionData.cs
  5. 5
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlSchemaCompletionDataCollection.cs
  6. 2
      src/AddIns/DisplayBindings/XmlEditor/Test/Completion/FirstCompletionListItemSelectedTestFixture.cs
  7. 13
      src/AddIns/DisplayBindings/XmlEditor/Test/Completion/ProcessKeyTests.cs
  8. 3
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/SchemaTestFixtureBase.cs
  9. 4
      src/AddIns/DisplayBindings/XmlEditor/Test/XmlEditor.Tests.csproj

4
src/AddIns/BackendBindings/WixBinding/Test/WixBinding.Tests.csproj

@ -293,10 +293,6 @@ @@ -293,10 +293,6 @@
<Link>ICSharpCode.SharpDevelop.Dom.dll</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="..\..\..\..\..\AddIns\AddIns\DisplayBindings\XmlEditor\XmlEditor.dll">
<Link>XmlEditor.dll</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Folder Include="PropertyGrid" />
<Folder Include="DirectoryImport" />
<Folder Include="Diff" />

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

@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
using ICSharpCode.XmlEditor;
using System;
using System.Linq;
using System.Windows.Forms;
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
using ICSharpCode.SharpDevelop.Editor;
@ -34,20 +35,22 @@ namespace ICSharpCode.XmlEditor @@ -34,20 +35,22 @@ namespace ICSharpCode.XmlEditor
{
string text = String.Concat(fileContent, charTyped);
DefaultCompletionItemList list = null;
switch (charTyped) {
case '=':
// Namespace intellisense.
if (XmlParser.IsNamespaceDeclaration(text, text.Length)) {
return schemaCompletionDataItems.GetNamespaceCompletionData();
list = schemaCompletionDataItems.GetNamespaceCompletionData();
}
break;
case '<':
// Child element intellisense.
XmlElementPath parentPath = XmlParser.GetParentElementPath(text);
if (parentPath.Elements.Count > 0) {
return GetChildElementCompletionData(parentPath);
list = GetChildElementCompletionData(parentPath);
} else if (defaultSchemaCompletionData != null) {
return defaultSchemaCompletionData.GetElementCompletionData(defaultNamespacePrefix);
list = defaultSchemaCompletionData.GetElementCompletionData(defaultNamespacePrefix);
}
break;
@ -56,7 +59,7 @@ namespace ICSharpCode.XmlEditor @@ -56,7 +59,7 @@ namespace ICSharpCode.XmlEditor
if (!XmlParser.IsInsideAttributeValue(text, text.Length)) {
XmlElementPath path = XmlParser.GetActiveElementStartPath(text, text.Length);
if (path.Elements.Count > 0) {
return GetAttributeCompletionData(path);
list = GetAttributeCompletionData(path);
}
}
break;
@ -67,14 +70,19 @@ namespace ICSharpCode.XmlEditor @@ -67,14 +70,19 @@ namespace ICSharpCode.XmlEditor
if (attributeName.Length > 0) {
XmlElementPath elementPath = XmlParser.GetActiveElementStartPath(text, text.Length);
if (elementPath.Elements.Count > 0) {
return GetAttributeValueCompletionData(elementPath, attributeName);
list = GetAttributeValueCompletionData(elementPath, attributeName);
}
}
}
break;
}
return null;
if (list != null) {
list.SortItems();
list.SuggestedItem = list.Items.FirstOrDefault();
}
return list;
}
/// <summary>
@ -120,7 +128,7 @@ namespace ICSharpCode.XmlEditor @@ -120,7 +128,7 @@ namespace ICSharpCode.XmlEditor
return schemaCompletionDataItems.GetSchemaFromFileName(fileName);
}
public ICompletionItemList GetChildElementCompletionData(XmlElementPath path)
public DefaultCompletionItemList GetChildElementCompletionData(XmlElementPath path)
{
XmlCompletionItemList list = new XmlCompletionItemList();
@ -130,11 +138,11 @@ namespace ICSharpCode.XmlEditor @@ -130,11 +138,11 @@ namespace ICSharpCode.XmlEditor
}
list.SortItems();
list.SuggestedItem = list.Items.FirstOrDefault();
return list;
}
public ICompletionItemList GetAttributeCompletionData(XmlElementPath path)
public DefaultCompletionItemList GetAttributeCompletionData(XmlElementPath path)
{
var list = new XmlCompletionItemList();
@ -144,11 +152,11 @@ namespace ICSharpCode.XmlEditor @@ -144,11 +152,11 @@ namespace ICSharpCode.XmlEditor
}
list.SortItems();
list.SuggestedItem = list.Items.FirstOrDefault();
return list;
}
public ICompletionItemList GetAttributeValueCompletionData(XmlElementPath path, string name)
public DefaultCompletionItemList GetAttributeValueCompletionData(XmlElementPath path, string name)
{
var list = new XmlCompletionItemList();
@ -158,7 +166,7 @@ namespace ICSharpCode.XmlEditor @@ -158,7 +166,7 @@ namespace ICSharpCode.XmlEditor
}
list.SortItems();
list.SuggestedItem = list.Items.FirstOrDefault();
return list;
}
}

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

@ -21,7 +21,7 @@ namespace ICSharpCode.XmlEditor @@ -21,7 +21,7 @@ namespace ICSharpCode.XmlEditor
public override CompletionItemListKeyResult ProcessInput(char key)
{
if (key == ':' || key == '.')
if (key == ':' || key == '.' || key == ' ')
return CompletionItemListKeyResult.NormalKey;
return base.ProcessInput(key);

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

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

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

@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
// </file>
using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections.ObjectModel;
@ -49,7 +50,7 @@ namespace ICSharpCode.XmlEditor @@ -49,7 +50,7 @@ namespace ICSharpCode.XmlEditor
this.AddRange(val);
}
public ICompletionItemList GetNamespaceCompletionData()
public DefaultCompletionItemList GetNamespaceCompletionData()
{
XmlCompletionItemList list = new XmlCompletionItemList();
@ -59,7 +60,7 @@ namespace ICSharpCode.XmlEditor @@ -59,7 +60,7 @@ namespace ICSharpCode.XmlEditor
}
list.SortItems();
list.SuggestedItem = list.Items.FirstOrDefault();
return list;
}

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

@ -38,7 +38,7 @@ namespace XmlEditor.Tests.Completion @@ -38,7 +38,7 @@ namespace XmlEditor.Tests.Completion
XmlSchemaCompletionData schema = new XmlSchemaCompletionData(ResourceManager.GetXhtmlStrictSchema());
XmlSchemaCompletionDataCollection schemas = new XmlSchemaCompletionDataCollection();
schemas.Add(schema);
provider = new XmlCompletionDataProvider(schemas, schema, String.Empty);
provider = new XmlCompletionDataProvider(schemas, schema, string.Empty);
TextEditorControl textEditor = new TextEditorControl();
completionDataItems = provider.GenerateCompletionData("", '<');
selectedCompletionData = completionDataItems.SuggestedItem;

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

@ -5,12 +5,13 @@ @@ -5,12 +5,13 @@
// <version>$Revision: 2760 $</version>
// </file>
using ICSharpCode.SharpDevelop.Editor;
using System;
using System.Windows.Forms;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.TextEditor.Gui.CompletionWindow;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using XmlEditor.Tests.Utils;
namespace XmlEditor.Tests.Completion
{
@ -25,8 +26,10 @@ namespace XmlEditor.Tests.Completion @@ -25,8 +26,10 @@ namespace XmlEditor.Tests.Completion
[SetUp]
public void Init()
{
XmlSchemaCompletionData schema = new XmlSchemaCompletionData(ResourceManager.GetXhtmlStrictSchema());
XmlSchemaCompletionDataCollection schemas = new XmlSchemaCompletionDataCollection();
list = new XmlCompletionDataProvider(schemas, null, null).GenerateCompletionData("", '<');
schemas.Add(schema);
list = new XmlCompletionDataProvider(schemas, schema, "").GenerateCompletionData("", '<');
}
/// <summary>
@ -35,19 +38,19 @@ namespace XmlEditor.Tests.Completion @@ -35,19 +38,19 @@ namespace XmlEditor.Tests.Completion
[Test]
public void SpaceChar()
{
Assert.AreEqual(CompletionDataProviderKeyResult.NormalKey, list.ProcessInput(' '));
Assert.AreEqual(CompletionItemListKeyResult.NormalKey, list.ProcessInput(' '));
}
[Test]
public void TabChar()
{
Assert.AreEqual(CompletionDataProviderKeyResult.InsertionKey, list.ProcessInput('\t'));
Assert.AreEqual(CompletionItemListKeyResult.InsertionKey, list.ProcessInput('\t'));
}
[Test]
public void ReturnChar()
{
Assert.AreEqual(CompletionDataProviderKeyResult.InsertionKey, list.ProcessInput((char)Keys.Return));
Assert.AreEqual(CompletionItemListKeyResult.InsertionKey, list.ProcessInput((char)Keys.Return));
}
}
}

3
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/SchemaTestFixtureBase.cs

@ -5,9 +5,10 @@ @@ -5,9 +5,10 @@
// <version>$Revision: 1683 $</version>
// </file>
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.Core;
using System;
using System.IO;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.TextEditor.Gui.CompletionWindow;
using ICSharpCode.XmlEditor;
using NUnit.Framework;

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

@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
<DebugType>Full</DebugType>
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<PlatformTarget>AnyCPU</PlatformTarget>
<PlatformTarget>x86</PlatformTarget>
<OutputPath>..\..\..\..\..\bin\UnitTests\</OutputPath>
<Optimize>False</Optimize>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
@ -212,7 +212,7 @@ @@ -212,7 +212,7 @@
<ProjectReference Include="..\Project\XmlEditor.csproj">
<Project>{6B717BD1-CD5E-498C-A42E-9E6A4584DC48}</Project>
<Name>XmlEditor</Name>
<Private>True</Private>
<Private>False</Private>
</ProjectReference>
<Folder Include="XPathQuery" />
<ProjectReference Include="..\..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj">

Loading…
Cancel
Save