by ghubbard · 13y ago · 0 comments
public bool StringIsEvenLength(string somestring )
public string FetchRemoteString( string uri )
public bool RemoteStringIsEvenLength(string uri)
{
fetched = FetchRemoteString( uri );
if( fetched != null ) {
return StringIsEvenLength( fetched );
}
throw new SomeOtherException("Didn't get a string to check the length of.");
}
Now StringIsEvenLength is trivial to test.
When you want to test RemoteStringIsEvenLengthYou can mock out FetchRemoteString and don't even have to use a WebClient at all.
The general point still stands though - if there was an interface, we wouldn't have to come up with these workarounds.