Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikayla Hutchinson <m.j.hutchinson@gmail.com>2018-06-04 09:35:28 +0300
committerMikayla Hutchinson <m.j.hutchinson@gmail.com>2018-06-04 20:51:53 +0300
commit867328fcb7f178fc7c2e05a857f0a89d2b699524 (patch)
tree8dbeef3494dbfbf7334b8fb7e58c19cc5c02ddb4 /main/src/addins/Xml
parent2b87fd05f10470e6198376171c8f2ce615d8db7e (diff)
[Xml] Add simple XSL-based validation tests
Diffstat (limited to 'main/src/addins/Xml')
-rw-r--r--main/src/addins/Xml/MonoDevelop.Xml.csproj1
-rw-r--r--main/src/addins/Xml/Tests/MonoDevelop.Xml.Tests.csproj1
-rw-r--r--main/src/addins/Xml/Tests/Schema/SchemaValidationTests.cs60
3 files changed, 62 insertions, 0 deletions
diff --git a/main/src/addins/Xml/MonoDevelop.Xml.csproj b/main/src/addins/Xml/MonoDevelop.Xml.csproj
index 12dd9aa293..40b6b52efb 100644
--- a/main/src/addins/Xml/MonoDevelop.Xml.csproj
+++ b/main/src/addins/Xml/MonoDevelop.Xml.csproj
@@ -44,6 +44,7 @@
<DocumentationFile>..\..\..\build\AddIns\Xml\MonoDevelop.Xml.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
+ <InternalsVisibleTo Include="MonoDevelop.Xml.Tests" />
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="System.Data" />
diff --git a/main/src/addins/Xml/Tests/MonoDevelop.Xml.Tests.csproj b/main/src/addins/Xml/Tests/MonoDevelop.Xml.Tests.csproj
index dcb4895a0c..cbddf9a560 100644
--- a/main/src/addins/Xml/Tests/MonoDevelop.Xml.Tests.csproj
+++ b/main/src/addins/Xml/Tests/MonoDevelop.Xml.Tests.csproj
@@ -129,6 +129,7 @@
<Compile Include="Schema\Includes\AttributeGroupRefSchemaIncludeTestFixture.cs" />
<Compile Include="Schema\Includes\TwoElementSchemaIncludeTestFixture.cs" />
<Compile Include="Formatting\XmlFormatterTests.cs" />
+ <Compile Include="Schema\SchemaValidationTests.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Parser\" />
diff --git a/main/src/addins/Xml/Tests/Schema/SchemaValidationTests.cs b/main/src/addins/Xml/Tests/Schema/SchemaValidationTests.cs
new file mode 100644
index 0000000000..e6c5e7c3b0
--- /dev/null
+++ b/main/src/addins/Xml/Tests/Schema/SchemaValidationTests.cs
@@ -0,0 +1,60 @@
+//
+// Copyright (c) Microsoft Corp
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System.Threading;
+using System.Threading.Tasks;
+using NUnit.Framework;
+using MonoDevelop.Xml.Editor;
+
+namespace MonoDevelop.Xml.Tests.Schema
+{
+ [TestFixture]
+ public class SchemaValidationTests
+ {
+ [Test]
+ public async Task ValidateXsltValid ()
+ {
+ var text =
+@"<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
+<xsl:variable name='foo' select='bar' />
+</xsl:stylesheet>";
+
+ var results = await XmlEditorService.Validate (text, "test.xslt", CancellationToken.None);
+ Assert.AreEqual (0, results.Count);
+ }
+
+ [Test]
+ public async Task ValidateXsltInvalid ()
+ {
+ var text =
+@"<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
+<xsl:varibble name='foo' select='bar' />
+</xsl:stylesheet>";
+
+ var results = await XmlEditorService.Validate (text, "test.xslt", CancellationToken.None);
+ Assert.AreEqual (1, results.Count);
+ Assert.AreEqual ("test.xslt", results [0].FileName);
+ Assert.AreEqual (2, results [0].Line);
+ Assert.AreEqual (2, results [0].Column);
+ Assert.IsTrue (results [0].ErrorText.StartsWith ("The element 'stylesheet' in namespace 'http://www.w3.org/1999/XSL/Transform' has invalid child element 'varibble'", System.StringComparison.Ordinal));
+ }
+ }
+}