using System;
using System.IO;
using NUnit.Framework;
using Tomboy;
namespace TomboyTest
{
[TestFixture]
public class ExportToHTMLPluginTest
{
static string html_text =
"
Test TitleTest Title
\n" +
"Some text
";
static string html_non_ascii_text =
"Test TitleTest \u00c4 Title
\n" +
"Some text with arabian characters: \u062b\u0642\u06cd.
";
static string html_link_text =
"Test Title\n" +
"Other Note
\n" +
"Some text.
";
[SetUp]
public void SetupNoteArchiver ()
{
NoteArchiver.Instance = new DummyNoteArchiver ();
Logger.Mute ();
}
[TearDown]
public void TearDownNoteArchiver ()
{
NoteArchiver.Instance = null;
Logger.Unmute ();
}
[Test]
public void Construct ()
{
new ExportToHTMLPlugin ();
}
[Test]
public void WriteHTMLForNote ()
{
Note note = Note.CreateNewNote ("Test Title", "note://tomboy/foo", null);
note.XmlContent = "Test Title\n\nSome text";
ExportToHTMLPlugin plugin = new ExportToHTMLPlugin ();
StringWriter writer = new StringWriter ();
plugin.WriteHTMLForNote (writer, note, false);
Assert.AreEqual (html_text, writer.ToString ());
}
[Test]
public void WriteHTMLForNoteWithNonAsciiCharacters ()
{
// Test with non-ASCII characters as well to make sure
// all buffers are large enough to process multi-byte
// characters.
Note note = Note.CreateNewNote ("Test Title", "note://tomboy/foo", null);
note.XmlContent = "Test \u00c4 Title\n\nSome text with arabian characters: \u062b\u0642\u06cd.";
ExportToHTMLPlugin plugin = new ExportToHTMLPlugin ();
StringWriter writer = new StringWriter ();
plugin.WriteHTMLForNote (writer, note, false);
Assert.AreEqual (html_non_ascii_text, writer.ToString ());
}
/* FIXME: Disabled for now.
[Test]
public void WriteHTMLForNoteLinked ()
{
DummyNoteManager manager = new DummyNoteManager ();
manager.Create ("Other Note", "Other Note\n\nSome text.");
Note linking_note = manager.Create ("Test Title", "Test Title\n\nLink here: Other Note.");
ExportToHTMLPlugin plugin = new ExportToHTMLPlugin ();
StringWriter writer = new StringWriter ();
plugin.WriteHTMLForNote (writer, linking_note, true);
Assert.AreEqual (html_link_text, writer.ToString ());
}
*/
}
}