Instantiate ErpContext object from connection string in C#

Does anyone know how to mock up an ErpContext object in C#? I’m trying to setup tests on my custom methods used in Epicor configurators & doc rules.

I’ve tried setting my connection string inside my config, but it doesn’t seem to like it.

Connection String in config:
<add name=“ErpContext” connectionString=“data source={EpicorServer};initial catalog=DevEnvironment;integrated security=True;” providerName=“System.Data.EntityClient” />

ErpContext I’m trying to instantiate:
ErpContext context = new ErpContext(System.Configuration.ConfigurationManager.ConnectionStrings[“ErpContext”].ConnectionString);

Is there a specific format to the connection string for the ErpContext to work?

1 Like

This may help

Wait. You’re setting up a test harness for Configurator? We need to talk…

Mark W.

1 Like

Thanks Jose!

Anyway I can get in contact with Dan? I’d like to see how he structured his config. It might help me figure out what I’m missing in mine.