Inheritance: ISqlConnection
        //public EntityFrameworkConnectionString(string serverName, string databaseName, string entityName):this(serverName, databaseName, true, null, null, entityName)
        //{
        //}

        //public EntityFrameworkConnectionString(string serverName, string databaseName, string userId, string password, string entityName)
        //    :this(serverName, databaseName, false, userId, password, entityName)
        //{
        //}

        //public EntityFrameworkConnectionString(string serverName, string databaseName, bool trustedConnection, string userId, string password, string entityName)
        //{
        //    this.trustedConnection = trustedConnection;
        //    this.databaseName = databaseName;
        //    this.serverName = serverName;
        //    this.password = password;
        //    this.userId = userId;
        //    this.entityName = entityName;
        //}

        #endregion

        #region IConnectionProvider Members

        public string GetConnectionString()
        {
            ISqlConnection             sqlprovider = new SqlConnectionString(config);
            SqlConnectionStringBuilder sqlBuilder  = sqlprovider.GetConnectionStringBuilder();

            return(BuildEntityFrameworkConnection(sqlBuilder, config.Database.EntityFrameworkEntitiesName).ToString());
        }
示例#2
0
        public void standard_sql_connection_string_with_integrated_security()
        {
            // Arrange
            InstallerConfig config = new InstallerConfig();

            config.Database.DataSource           = @"kingwilder-pc\sqlserver";
            config.Database.InitialCatalog       = "BloggerApp";
            config.Database.UseTrustedConnection = true;

            ISqlConnection provider = new SqlConnectionString(config);

            // Act
            var actual   = provider.GetConnectionString();
            var expected = @"Data Source=kingwilder-pc\sqlserver;Initial Catalog=BloggerApp;Integrated Security=True";

            // Assert
            Assert.AreEqual(expected, actual);
        }
示例#3
0
        public void standard_sql_connection_string_with_all_parameters_returns_credentials()
        {
            // Arrange
            InstallerConfig config = new InstallerConfig();

            config.Database.DataSource           = @"kingwilder-pc\sqlserver";
            config.Database.InitialCatalog       = "CommerceApp";
            config.Database.UseTrustedConnection = false;
            config.Database.UserName             = "******";
            config.Database.Password             = "******";

            IConnectionProvider provider = new SqlConnectionString(config);

            // Act
            var actual   = provider.GetConnectionString();
            var expected = @"Data Source=kingwilder-pc\sqlserver;Initial Catalog=CommerceApp;User ID=samAdmin;Password=myPassword";

            // Assert
            Assert.AreEqual(expected, actual);
        }
示例#4
0
        public void standard_sql_connection_string_with_all_parameters_returns_integrated_security()
        {
            // Arrange
            InstallerConfig config = new InstallerConfig();

            config.Database.DataSource           = @"kingwilder-pc\sqlserver";
            config.Database.InitialCatalog       = "CommerceApp";
            config.Database.UseTrustedConnection = true;
            config.Database.UserName             = "******";
            config.Database.Password             = "******";

            IConnectionProvider provider = new SqlConnectionString(config);

            // Act
            var actual   = provider.GetConnectionString();
            var expected = @"Data Source=kingwilder-pc\sqlserver;Initial Catalog=CommerceApp;Integrated Security=True";

            // Assert
            Assert.AreEqual(expected, actual);
        }