Mercurial > repos > IBBoard.Tests
annotate Xml/XmlResourceResolverTests.cs @ 49:99e4c1949c92 default tip
* Update to v2.6 of NUnit and new syntax/API changes
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 28 Apr 2013 19:32:14 +0100 |
parents | 1e731dda7608 |
children |
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 |
179c4cf6aecf
Re #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
9 namespace IBBoard.Xml |
179c4cf6aecf
Re #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
10 { |
179c4cf6aecf
Re #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
11 [TestFixture()] |
179c4cf6aecf
Re #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
12 public class XmlResourceResolverTests |
179c4cf6aecf
Re #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
13 { |
179c4cf6aecf
Re #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
14 [Test()] |
179c4cf6aecf
Re #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
15 public void TestGettingStreamForAddedResource() |
179c4cf6aecf
Re #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
16 { |
179c4cf6aecf
Re #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
17 Assembly localAssembly = Assembly.GetExecutingAssembly(); |
179c4cf6aecf
Re #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
18 XmlResourceResolver resolver = new XmlResourceResolver(localAssembly); |
179c4cf6aecf
Re #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
19 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
|
20 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
|
21 resolver.AddMapping(uriString, resourceID); |
48
1e731dda7608
Re #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
22 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
|
23 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
|
24 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
|
25 } |
47
66eee91f51b3
Fixes #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
26 |
66eee91f51b3
Fixes #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
27 [Test()] |
66eee91f51b3
Fixes #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
28 public void TestGettingStreamForNonStandardURI() |
66eee91f51b3
Fixes #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
29 { |
66eee91f51b3
Fixes #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
30 Assembly localAssembly = Assembly.GetExecutingAssembly(); |
66eee91f51b3
Fixes #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
31 XmlResourceResolver resolver = new XmlResourceResolver(localAssembly); |
66eee91f51b3
Fixes #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
32 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
|
33 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
|
34 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
|
35 resolver.AddMapping(dtdString, uriString, resourceID); |
66eee91f51b3
Fixes #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
36 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
|
37 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
|
38 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
|
39 } |
46
179c4cf6aecf
Re #49: XmlResourceResolver fails with HTML DTD on Windows
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
40 } |
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 |