Create a wrapper for the dependency. You don't need to test the implementation of code you didn't write. Mock the dependency wrapper with the anticipated or hypothetical outputs.
public sealed class SomeBadDependency
{
public int CalculateSuperSecretValue(int inputX, int inputY)
{
return Math.Max(inputX, inputY);
}
}
public interface IDependencyWrapper
{
int CalculateSuperSecretValue(int inputX, int inputY);
}
public sealed class DependencyWrapper : IDependencyWrapper
{
private readonly SomeBadDependency _someBadDependency;
public DependencyWrapper(SomeBadDependency someBadDependency)
{
_someBadDependency = someBadDependency;
}
public int CalculateSuperSecretValue(int inputX, int inputY)
{
return _someBadDependency.CalculateSuperSecretValue(inputX, inputY);
}
}
public sealed class YourCode
{
private readonly IDependencyWrapper _dependencyWrapper;
public YourCode(IDependencyWrapper dependencyWrapper)
{
_dependencyWrapper = dependencyWrapper;
}
public decimal CalculateYourValue(decimal inputX, decimal inputY)
{
return _dependencyWrapper.CalculateSuperSecretValue((int) inputX, (int) inputY);
}
}