you said:
Most of the time, the third party dependency can't be mocked
Why? You can always define an interface for your interactions with the 3rd party component, then provide an implementation which simply delegates each call to the 3rd party component, then you are able to provide a mock of this interface for your tests.
this might be a lot of work if the 3rd party component has a large API, but it might still be worth doing.
Similar projects exist for creating wrappers around the .net filesystem classes so that you can write tests which do not rely on the filesystem.
So you could do something like this:
public interface IMyDependency
{
public void SomeMethod();
public int CaclateSomething();
//add other methods that you will call in the 3rd party dependency
}
Then have a wrapper which just delegates to the actual 3rd party component you are using, like this:
public class MyDependencyWrapper : IMyDependency
{
private My3rdPartyDepency actualDependency;
public MyDependencyWrapper(My3rdPartyDepency actualDependency)
{
this.actualDependency=actualDependency;
}
public void SomeMethod()
{
actualDependency.SomeMethod()l
}
public int CaclateSomething(string aParam)
{
return actualDependency.CalculateSomething(aParam);
}
//add other methods that you will call in the 3rd party dependency
}
now with this you can use just the interface in your tests, and so can write unit tests with no dependency on the actual 3rd party component.