I have the example above and i need to decouple the code to ease the tests, how i can do this to can test using mock?
public sealed class XCommand : BaseCommand
{
public IResult Author()
{
//DO SOMETHING AND RETURN BASE.
return base.run();
}
}
public abstract class BaseCommand
{
public virtual IResult Run()
{
ProcessStartInfo startInfo = new ProcessStartInfo();
using (Process process = new Process() { StartInfo = startInfo })
{
process.Start();
process.WaitForExit();
String error = process.StandardError.ReadToEnd().Trim();
String output = process.StandardOutput.ReadToEnd().Trim();
return new Result()
{
Error = error,
Output = output
};
}
}
}
sealed class Result : IResult
{
public String Error { get; set; }
public String Output { get; set; }
}
there are a lot of class that will inherits the class BaseCommand and i need to test every class individually, so how i can decouple this code to be possible make this?
Thanks
Aucun commentaire:
Enregistrer un commentaire