Mercurial > repos > IBBoard.Tests
annotate Xml/XmlResourceResolverTests.cs @ 48:1e731dda7608
Re #49: XmlResourceResolver fails with HTML DTD on Windows
* Make absolute URI mapping test URI resolving
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 01 Sep 2012 14:17:09 +0100 |
parents | 66eee91f51b3 |
children | 99e4c1949c92 |
rev | line source |
---|---|
46
179c4cf6aecf
Re #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1 // This file (XmlResourceResolverTests.cs) is a part of the IBBoard.Tests project and is copyright 2012 IBBoard |
179c4cf6aecf
Re #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
2 // |
179c4cf6aecf
Re #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
3 // 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. |
179c4cf6aecf
Re #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
4 using System; |
179c4cf6aecf
Re #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
5 using NUnit.Framework; |
179c4cf6aecf
Re #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
6 using System.Reflection; |
179c4cf6aecf
Re #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
7 using System.IO; |
179c4cf6aecf
Re #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
8 using NUnit.Framework.SyntaxHelpers; |
179c4cf6aecf
Re #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
9 |
179c4cf6aecf
Re #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
10 namespace IBBoard.Xml |
179c4cf6aecf
Re #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
11 { |
179c4cf6aecf
Re #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
12 [TestFixture()] |
179c4cf6aecf
Re #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
13 public class XmlResourceResolverTests |
179c4cf6aecf
Re #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
14 { |
179c4cf6aecf
Re #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
15 [Test()] |
179c4cf6aecf
Re #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
16 public void TestGettingStreamForAddedResource() |
179c4cf6aecf
Re #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
17 { |
179c4cf6aecf
Re #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
18 Assembly localAssembly = Assembly.GetExecutingAssembly(); |
179c4cf6aecf
Re #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
19 XmlResourceResolver resolver = new XmlResourceResolver(localAssembly); |
179c4cf6aecf
Re #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
20 string uriString = "http://ibboard.co.uk/some.xsd"; |
179c4cf6aecf
Re #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
21 string resourceID = "IBBoard.test-data.ResourceResolver.some.xsd"; |
179c4cf6aecf
Re #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
22 resolver.AddMapping(uriString, resourceID); |
48
1e731dda7608
Re #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
23 Assert.That(resolver.ResolveUri(null, uriString), Is.EqualTo(new Uri(uriString))); |
46
179c4cf6aecf
Re #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
24 Stream resolvedStream = (Stream)resolver.GetEntity(new Uri(uriString), null, typeof(Stream)); |
179c4cf6aecf
Re #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
25 Assert.That(resolvedStream, Is.EqualTo(localAssembly.GetManifestResourceStream(resourceID))); |
179c4cf6aecf
Re #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
26 } |
47
66eee91f51b3
Fixes #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
27 |
66eee91f51b3
Fixes #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
28 [Test()] |
66eee91f51b3
Fixes #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
29 public void TestGettingStreamForNonStandardURI() |
66eee91f51b3
Fixes #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
30 { |
66eee91f51b3
Fixes #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
31 Assembly localAssembly = Assembly.GetExecutingAssembly(); |
66eee91f51b3
Fixes #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
32 XmlResourceResolver resolver = new XmlResourceResolver(localAssembly); |
66eee91f51b3
Fixes #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
33 string dtdString = "-//W3C//ENTITIES Latin 1 for XHTML//EN"; |
66eee91f51b3
Fixes #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
34 string uriString = "http://w3c.org/latin.xsd"; |
66eee91f51b3
Fixes #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
35 string resourceID = "IBBoard.test-data.ResourceResolver.some.xsd"; |
66eee91f51b3
Fixes #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
36 resolver.AddMapping(dtdString, uriString, resourceID); |
66eee91f51b3
Fixes #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
37 Assert.That(resolver.ResolveUri(null, dtdString), Is.EqualTo(new Uri(uriString))); |
66eee91f51b3
Fixes #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
38 Stream resolvedStream = (Stream)resolver.GetEntity(new Uri(uriString), null, typeof(Stream)); |
66eee91f51b3
Fixes #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
39 Assert.That(resolvedStream, Is.EqualTo(localAssembly.GetManifestResourceStream(resourceID))); |
66eee91f51b3
Fixes #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
40 } |
46
179c4cf6aecf
Re #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
41 } |
179c4cf6aecf
Re #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
42 } |
179c4cf6aecf
Re #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
43 |