1) set up an interface for your datalayer
2) let your datalayer implement that interface (or extract the interface if you already have the datalayer ready)
3) now you can setup the mock for the interface
public interface IDataLayerMyApp
{
IEnumerable<string> GetMachineType(string werk);
}
public class DataLayerMyApp : IDataLayerMyApp
{
public IEnumerable<string> GetMachineType(string werk)
{
IEnumerable<string> result;
using (var connection = new SqlConnection(ConnectionString))
{
connection.Open();
}
return result;
}
}
[Test]
public void TheTestFunc()
{
var dal = new Mock<IDataLayerMyApp>();
List<string> yourResult = ...
dal.Setup(m => m.GetMachineType(It.IsAny<string>()))
.Returns(yourResult)
}