1 // ****************************************************************
2 // Copyright 2008, Charlie Poole
3 // This is free software licensed under the NUnit license. You may
4 // obtain a copy of the license at http://nunit.org/?p=license&r=2.4
5 // ****************************************************************
12 /// Abstract base for classes that capture text output
13 /// and redirect it to a TextWriter.
15 public abstract class TextCapture
17 #region Private Fields
19 /// True if capture is enabled
24 /// The TextWriter to which text is redirected
26 private TextWriter writer
;
31 /// The TextWriter to which text is redirected
33 public TextWriter Writer
35 get { return writer; }
40 if (writer
!= null && enabled
)
46 /// Controls whether text is captured or not
50 get { return enabled; }
55 if (writer
!= null && enabled
)
60 if (writer
!= null && enabled
&& DefaultThreshold
!= "Off")
67 /// Returns the default threshold value, which represents
68 /// the degree of verbosity of the output text stream.
69 /// Returns "None" in the base class. Derived classes that
70 /// support verbosity levels should override it.
72 public virtual string DefaultThreshold
74 get { return "None"; }
78 #region Abstract Members
80 /// Override this to perform whatever actions are needed
81 /// to start capturing text and sending it to the Writer.
83 protected abstract void StartCapture();
86 /// Override this to perform whatever actions are needed
87 /// to flush remaining output and stop capturing text.
88 /// The Writer should not be changed, allowing capture
89 /// to be restarted at a future point.
91 protected abstract void StopCapture();