public void TestInvalidMultiShardConnectionString() { MultiShardConnection conn; try { conn = new MultiShardConnection(_shardMap.GetShards(), connectionString: null); } catch (Exception ex) { Assert.IsTrue(ex is ArgumentNullException, "Expected ArgumentNullException!"); } try { conn = new MultiShardConnection(_shardMap.GetShards(), MultiShardTestUtils.ShardMapManagerConnectionString); } catch (Exception ex) { Assert.IsTrue(ex is ArgumentException, "Expected ArgumentException!"); } // Validate that the ApplicationName is updated properly var applicationStringBldr = new StringBuilder(); for (int i = 0; i < ApplicationNameHelper.MaxApplicationNameLength; i++) { applicationStringBldr.Append('x'); } string applicationName = applicationStringBldr.ToString(); SqlConnectionStringBuilder connStringBldr = new SqlConnectionStringBuilder(MultiShardTestUtils.ShardConnectionString); connStringBldr.ApplicationName = applicationName; conn = new MultiShardConnection(_shardMap.GetShards(), connStringBldr.ConnectionString); string updatedApplicationName = new SqlConnectionStringBuilder (conn.ShardConnections[0].Item2.ConnectionString).ApplicationName; Assert.IsTrue(updatedApplicationName.Length == ApplicationNameHelper.MaxApplicationNameLength && updatedApplicationName.EndsWith(MultiShardConnection.ApplicationNameSuffix), "ApplicationName not appended with {0}!", MultiShardConnection.ApplicationNameSuffix); }