示例#1
0
        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(); });
        }
示例#2
0
        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();
        }