public void ConnectsToDb() { // Arrange. string dbConnectionString = ConfigurationManager.ConnectionStrings["DbConnectionString"].ConnectionString; int timeoutSeconds = int.Parse(ConfigurationManager.AppSettings["TimeoutSeconds"]); DbConnection dbConnection = new DbConnection(dbConnectionString, timeoutSeconds); SocialNetworkService socialNetworkService = new SocialNetworkService(dbConnection); // Act and assert. Assert.DoesNotThrow(() => { socialNetworkService.CheckService(); }); }
private static void Main() { // First, initialise all the settings and services. string dbConnectionString = ConfigurationManager.ConnectionStrings["DbConnectionString"].ConnectionString; int timeoutSeconds = int.Parse(ConfigurationManager.AppSettings["TimeoutSeconds"]); DbConnection dbConnection = new DbConnection(dbConnectionString, timeoutSeconds); // Make sure we can connect to the database. _socialNetworkService = new SocialNetworkService(dbConnection); _socialNetworkService.CheckService(); // Now handle the user's request(s). ShowMenu(); }