changeset 46:179c4cf6aecf

Re #49: XmlResourceResolver fails with HTML DTD on Windows * Add test for resolver using standard URIs
author IBBoard <dev@ibboard.co.uk>
date Fri, 31 Aug 2012 20:39:29 +0100
parents 7502653a71a0
children 66eee91f51b3
files IBBoard.Tests.csproj Xml/XmlResourceResolverTests.cs test-data/ResourceResolver/some.xsd
diffstat 2 files changed, 43 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/IBBoard.Tests.csproj	Sun Jun 24 15:50:45 2012 +0100
+++ b/IBBoard.Tests.csproj	Fri Aug 31 20:39:29 2012 +0100
@@ -31,9 +31,9 @@
     <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
-    <DebugSymbols>true</DebugSymbols>
+    <DebugSymbols>True</DebugSymbols>
     <DebugType>full</DebugType>
-    <Optimize>false</Optimize>
+    <Optimize>False</Optimize>
     <OutputPath>bin\Debug</OutputPath>
     <DefineConstants>DEBUG</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
@@ -42,7 +42,7 @@
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
     <DebugType>none</DebugType>
-    <Optimize>false</Optimize>
+    <Optimize>False</Optimize>
     <OutputPath>bin\Release</OutputPath>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
@@ -72,6 +72,7 @@
     <Compile Include="EqualityCheckerTests.cs" />
     <Compile Include="IO\StreamUtilTests.cs" />
     <Compile Include="Collections\CollectionsTest.cs" />
+    <Compile Include="Xml\XmlResourceResolverTests.cs" />
   </ItemGroup>
   <ItemGroup>
     <Reference Include="System" />
@@ -81,38 +82,6 @@
       <SpecificVersion>False</SpecificVersion>
     </Reference>
   </ItemGroup>
-  <ItemGroup>
-    <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
-      <Visible>False</Visible>
-      <ProductName>.NET Framework Client Profile</ProductName>
-      <Install>false</Install>
-    </BootstrapperPackage>
-    <BootstrapperPackage Include="Microsoft.Net.Framework.2.0">
-      <Visible>False</Visible>
-      <ProductName>.NET Framework 2.0 %28x86%29</ProductName>
-      <Install>false</Install>
-    </BootstrapperPackage>
-    <BootstrapperPackage Include="Microsoft.Net.Framework.3.0">
-      <Visible>False</Visible>
-      <ProductName>.NET Framework 3.0 %28x86%29</ProductName>
-      <Install>false</Install>
-    </BootstrapperPackage>
-    <BootstrapperPackage Include="Microsoft.Net.Framework.3.5">
-      <Visible>False</Visible>
-      <ProductName>.NET Framework 3.5</ProductName>
-      <Install>false</Install>
-    </BootstrapperPackage>
-    <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
-      <Visible>False</Visible>
-      <ProductName>.NET Framework 3.5 SP1</ProductName>
-      <Install>true</Install>
-    </BootstrapperPackage>
-    <BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
-      <Visible>False</Visible>
-      <ProductName>Windows Installer 3.1</ProductName>
-      <Install>true</Install>
-    </BootstrapperPackage>
-  </ItemGroup>
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
   <ItemGroup>
     <ProjectReference Include="..\IBBoard\IBBoard.csproj">
@@ -134,27 +103,33 @@
   <ItemGroup>
     <None Include="app.config" />
     <None Include="test-data\TranslationTests\translations\en.translation">
-      <Gettext-ScanForTranslations>false</Gettext-ScanForTranslations>
+      <Gettext-ScanForTranslations>False</Gettext-ScanForTranslations>
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
     <None Include="test-data\TranslationTests\translations\it.translation">
-      <Gettext-ScanForTranslations>false</Gettext-ScanForTranslations>
+      <Gettext-ScanForTranslations>False</Gettext-ScanForTranslations>
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
     <None Include="test-data\XmlLoaderTests\translations\en.translation">
-      <Gettext-ScanForTranslations>false</Gettext-ScanForTranslations>
+      <Gettext-ScanForTranslations>False</Gettext-ScanForTranslations>
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
     <None Include="test-data\XmlLoaderTests\schemas\translation.xsd">
-      <Gettext-ScanForTranslations>false</Gettext-ScanForTranslations>
+      <Gettext-ScanForTranslations>False</Gettext-ScanForTranslations>
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
     <None Include="test-data\XmlLoaderTests\translations\en-GB.translation">
-      <Gettext-ScanForTranslations>false</Gettext-ScanForTranslations>
+      <Gettext-ScanForTranslations>False</Gettext-ScanForTranslations>
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
     <None Include="PrefTestPref.xml">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
   </ItemGroup>
+  <ItemGroup>
+    <Folder Include="test-data\ResourceResolver\" />
+  </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="test-data\ResourceResolver\some.xsd" />
+  </ItemGroup>
 </Project>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Xml/XmlResourceResolverTests.cs	Fri Aug 31 20:39:29 2012 +0100
@@ -0,0 +1,28 @@
+//  This file (XmlResourceResolverTests.cs) is a part of the IBBoard.Tests project and is copyright 2012 IBBoard
+//
+//  The file and the library/program it is in are licensed and distributed, without warranty, under the GNU LGPL, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license.
+using System;
+using NUnit.Framework;
+using System.Reflection;
+using System.IO;
+using NUnit.Framework.SyntaxHelpers;
+
+namespace IBBoard.Xml
+{
+	[TestFixture()]
+	public class XmlResourceResolverTests
+	{
+		[Test()]
+		public void TestGettingStreamForAddedResource()
+		{
+			Assembly localAssembly = Assembly.GetExecutingAssembly();
+			XmlResourceResolver resolver = new XmlResourceResolver(localAssembly);
+			string uriString = "http://ibboard.co.uk/some.xsd";
+			string resourceID = "IBBoard.test-data.ResourceResolver.some.xsd";
+			resolver.AddMapping(uriString, resourceID);
+			Stream resolvedStream = (Stream)resolver.GetEntity(new Uri(uriString), null, typeof(Stream));
+			Assert.That(resolvedStream, Is.EqualTo(localAssembly.GetManifestResourceStream(resourceID)));
+		}
+	}
+}
+