Как мне выполнить модульное тестирование следующего класса, используя Rhino Mocks
public interface IXmlTransformer
{
void Transform(Stream inputXml, Stream transformedXml);
}
public class XmlToFOTransformer : IXmlTransformer
{
private string styleSheetPath = string.Empty;
private bool fillable = true;
public XmlToFOTransformer(
string styleSheetUri,
bool shouldAllowUserToEditData)
{
if (string.IsNullOrEmpty(styleSheetUri))
{
throw new ArgumentNullException(
"styleSheetUri",
"styleSheetUri can not be null");
}
styleSheetPath = styleSheetUri;
fillable = shouldAllowUserToEditData;
}
public void Transform(Stream inputXml, Stream transformedXml)
{
if (inputXml == null)
{
throw new ArgumentNullException(
"inputXml",
"Input xml can not be null.");
}
if (transformedXml == null)
{
throw new ArgumentNullExceptio(
"transformedStream",
"TransformedStream can not be null.");
}
XslCompiledTransform transformer = new XslCompiledTransform();
XsltSettings xsltSettings = new XsltSettings();
xsltSettings.EnableDocumentFunction = true;
XmlUrlResolver resolver = new XmlUrlResolver();
XmlReaderSettings readerSettings = new XmlReaderSettings();
readerSettings.DtdProcessing = DtdProcessing.Ignore;
try
{
transformer.Load(styleSheetPath, xsltSettings, resolver);
}
catch (Exception ex)
{
throw new ApplicationException(string.Format(
CultureInfo.InvariantCulture,
"Error while loding & compiling the Xsl file, the system returned {0}",
ex.Message));
}
XmlReader inputXmlReader;
try
{
inputXmlReader = XmlReader.Create(inputXml, readerSettings);
}
catch (Exception ex)
{
throw new ApplicationException(string.Format(System.Globalization.CultureInfo.InvariantCulture, "Error loading the XML file, the system returned {0}", ex.Message));
}
// do the transform
try
{
transformer.Transform(
inputXmlReader,
xsltArguments,
transformedXml);
transformedXml.Position = 0;
}
catch (Exception ex)
{
throw new ApplicationException(string.Format(System.Globalization.CultureInfo.InvariantCulture, "Error in transforming the XML file and XSL file, the system returned {0}", ex.Message));
}
}
}