view Xml/XmlResourceResolverTests.cs @ 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
children 66eee91f51b3
line wrap: on
line source

//  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)));
		}
	}
}