public void Setup() { //mockhttps://stackoverflow.com/questions/64794219/how-to-mock-iconfiguration-getvalue var inMemorySettings = new Dictionary <string, string> { { "TopLevelKey", "TopLevelValue" }, { "ConnectionStrings:Production", "Data Source=ZIT-D0998\\SQL2014; Initial Catalog = salonfr2; Integrated Security = True; Connect Timeout = 30; Encrypt = False; TrustServerCertificate = False; ApplicationIntent = ReadWrite; MultiSubnetFailover = False" }, //...populate as needed for the test }; this.configuration = new ConfigurationBuilder() .AddInMemoryCollection(inMemorySettings) .Build(); connectDB = SDependencyContainer.getCreatorOfDBConnection; // query accessQuery = connectDB.CreateConnectForQuery_MSsql(configuration, "Production"); getDataFromDB = new DataFromTable_With_Sync_and_Async <ModelEmployee>(accessQuery); //command command = connectDB.CreateConnectForCommand_MSsql(configuration, "Production"); execNonQuery = new CommandExecuteNonQuey <ModelEmployee>(command); }
public HomeController(ILogger <HomeController> logger, IConfiguration configuration, ICreatorOfDBConnection connectToMSSql) { _logger = logger; createQueryFromDB = new DataFromTable_With_Sync_and_Async <ModelEmployee>(connectToMSSql.CreateObject_MSsql(configuration, "Production")); }