I am trying to mock out the constructor of a class.
Mock<DocumentManager> mockDManager = MockManager.Mock<DocumentManager>(Constructor.Mocked);
When running my test it gets to a line in a function:
public string GenerateFileName(string fileName, string extension, string userId, DataConnection dbConn)
{
DocumentManager docManager = new DocumentManager(dbConn.ActiveConnection, dbConn.CreateAdapter());
return (docManager.CreateWorkingDocument(fileName, extension, userId));
}
Fails at the first line, with: System.NullReferenceException: Object reference not set to an instance of an object..
I don't want it to create a new instance of the DocumentManager based on the DataConnection instance (a SQL database connection class), I want it to just create a mocked object and continue on and call the 2nd line, the CreateWorkingDocument function which doesn't really need the database connection. Stepping through the code it actually goes through and looks up the dbConn.ActiveConnection and calls dbConn.CreateAdapter().
How do I set it up to do what I am expecting it to do?