Since this is a Data Object in the data access layer, it should depend directly on a database service. You could specify a DatabaseService to the constructor:
DataObject dataObject = new DataObject(new DatabaseService());
dataObject.Update();
But, the injection doesn't have to be in the constructor. Alternatively, you could provide the dependency via each CRUD method. I prefer this method to the previous because your Data Object doesn't need to know where it will persist until you actually need to persist it.
DataObject dataObject = new DataObject();
dataObject.Update(new DatabaseService());
You definitely do not want to hide the construction away in the CRUD methods!
public void Update()
{
// DON'T DO THIS!
using (DatabaseService dbService = new DatabaseService())
{
...
}
}
An alternative option would be to construct the DatabaseService via an overridable class method.
public void Update()
{
// GetDatabaseService() is protected virtual, so in unit testing
// you can subclass the Data Object and return your own
// MockDatabaseService.
using (DatabaseService dbService = GetDatabaseService())
{
...
}
}
A final alternative is to use a singleton-style ServiceLocator. Although I dislike this option, it is unit testable.
public void Update()
{
// The ServiceLocator would not be a real singleton. It would have a setter
// property so that unit tests can swap it out with a mock implementation
// for unit tests.
using (DatabaseService dbService = ServiceLocator.GetDatabaseService())
{
...
}
}