I have the following class in C# which creates an object from a propriatery .DLL that requires a license in a reachable directory at the initialization .
public CplexServices{
private Cplex _cplex;
public Cplex Cplex { get { return _cplex; } }
public CplexServices()
{
try
{
_cplex = new Cplex();
}
catch
{
throw new Exception("Path or license file is wrong");
}
}
}
"new Cplex()" might fail if the Windows system path is wrong or the license file is not correct. I want to write a test to assert if the correct exception is thrown when the path and/or license file is wrong.
How can I write this test without changing the path or the license file?