Suppose I have the following classes from a third-party library:
public class ThirdPartyType { ... }
public class ThirdPartyFunction
{
public ThirdPartyType DoSomething() { ... }
}
The implementation details are not important, and they are actually outside of my control for this third-party library.
Suppose I write an adapter class for ThirdPartyFunction
:
public class Adapter
{
private readonly ThirdPartyFunction f;
public Adapter()
{
f = new ThirdPartyFunction();
}
public string DoSomething()
{
var result = f.DoSomething();
// Convert to a type that my clients can understand
return Convert(result);
}
private string Convert(ThirdPartyType value)
{
// Complex conversion from ThirdPartyType to string
// (how do I test this private method?)
...
}
}
How can I test that my implementation of Convert(ThirdPartyType)
is correct? It's only needed by the Adapter
class, which is why it's a private method.