- mhtmllib_src.zip
- Rilling.MhtmlLib
- docs
- api
- design
- ClassDiagram.vsd
- tutorials
- MhtmlLib.sln
- src
- Rilling.Web.Mhtml.TestHarness
- Rilling.Web.Mhtml.TestHarness_old
- Rilling.Web.Mhtml.TestSite
- Rilling.Web.Mhtml
- WinCapture
- mhtmllib_demo.zip
|
using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using System.IO;
using Rilling.MhtmlLib.Media;
using Rilling.MhtmlLib.Media.Artifacts;
using Rilling.MhtmlLib.Media.Resolvers;
using Rilling.MhtmlLib.Media;
namespace Rilling.Web.Mhtml.TestHarness
{
[TestFixture()]
public class XmlIslandLinkResolverTest
{
string[] testVals1 = new string[]
{
"<xml src=\"mydata.xml\"/>",
"<xml src=\"mydata.xml\" xxx=\"nothing\"/>",
"<xml xxx=\"nothing\" src=\"mydata.xml\"/>",
"<xml src='mydata.xml'/>",
"<xml src=mydata.xml/>"
};
XmlIslandLinkResolver testObj = null;
[SetUp]
public void InitTest()
{
testObj = new XmlIslandLinkResolver();
}
[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void Call_LocateReferences_NullParam_ContentData()
{
testObj.LocateReferences(null, new Uri("http://www.rilling.net/"));
}
[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void Call_LocateReferences_NullParam_BaseUrl()
{
testObj.LocateReferences(new TextArtifact(new MemoryStream()), null);
}
private void CallLocateReferencesHelper(string baseUri,
string[] testVals,
string expected)
{
foreach (string testVal in testVals)
{
//
// Prepare the artifact.
//
MemoryStream stream = new MemoryStream();
StreamWriter writer = new StreamWriter(stream);
writer.Write(testVal);
writer.Flush();
TextArtifact artifact = new TextArtifact(stream);
artifact.ContentType = ContentTypes.Html;
//
// Try to locate and validate the found link.
//
LinkIdentification[] results =
testObj.LocateReferences(artifact, new Uri(baseUri));
//
// Make sure it is as expected.
//
Assert.AreEqual(1, results.Length, "Unable to locate any links (" + testVal + ")");
Assert.AreEqual(expected, results[0].Url.ToString(), "Unable to locate any links (" + testVal + ")");
}
}
[Test()]
public void Call_LocateReferences_FolderBaseUri()
{
CallLocateReferencesHelper("http://www.rilling.net/nowhere/",
testVals1,
"http://www.rilling.net/nowhere/mydata.xml");
}
[Test()]
public void Call_LocateReferences_FileBaseUri()
{
CallLocateReferencesHelper("http://www.rilling.net/nowhere",
testVals1,
"http://www.rilling.net/mydata.xml");
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.