But by god - does it have to be so poorly documented?
In this case I'm looking at NUnit.Util. This is part of the standard NUnit install, and it contains a bunch of classes - and no documentation on them. I've done searches through google - no documentation found.
Does this stuff get used?
What I needed: A way to trap output that is supposed to go to the console so I can make sure that something that writes to it is actually writing what I wanted.
What I eventually did: I took the NUnit.Util.ConsoleWriter, and inherited from it as below. Then, I passed it in as a TextWriter, which my console app would write to.
using System;
using System.Text;
using System.IO;
using NUnit.Util;
namespace moCSCXIImport.Tests
{
///
/// Summary description for MockConsole.
///
public class MockConsole : ConsoleWriter
{
private StringBuilder TextBuffer;
public MockConsole(TextWriter console) : base(console)
{
TextBuffer = new StringBuilder();
}
public override void Write(char c)
{
TextBuffer.Append(c);
base.Write(c);
}
public override void Write(String s)
{
TextBuffer.Append(s);
base.Write(s);
}
public override void WriteLine(string s)
{
TextBuffer.Append(s);
TextBuffer.Append("\n"); // newline
base.WriteLine(s);
}
public string TextWritten
{
get { return TextBuffer.ToString(); }
}
public long GetTextLength()
{
return TextBuffer.Length;
}
}
}
But I'm sure someone's done something like this before. But why couldn't I *find* it?
