public void SqlLocalDbInstance_CreateConnectionStringBuilder_If_Instance_Started() { // Arrange Helpers.EnsureLocalDBInstalled(); string instanceName = Guid.NewGuid().ToString(); SqlLocalDbApi.CreateInstance(instanceName); try { SqlLocalDbInstance target = new SqlLocalDbInstance(instanceName); target.Start(); try { // Act SqlConnectionStringBuilder result = target.CreateConnectionStringBuilder(); // Assert Assert.IsNotNull(result, "CreateConnection() returned null."); StringAssert.Contains(result.ConnectionString, target.NamedPipe, "SqlConnection.ConnectionString is incorrect."); } finally { SqlLocalDbApi.StopInstance(instanceName); } } finally { SqlLocalDbApi.DeleteInstance(instanceName); } }
public void SqlLocalDbInstance_CreateConnectionStringBuilder_Throws_If_Instance_Not_Started() { // Arrange Helpers.EnsureLocalDBInstalled(); string instanceName = Guid.NewGuid().ToString(); SqlLocalDbApi.CreateInstance(instanceName); try { SqlLocalDbInstance target = new SqlLocalDbInstance(instanceName); // Act and Assert throw ErrorAssert.Throws <InvalidOperationException>( () => target.CreateConnectionStringBuilder()); } finally { SqlLocalDbApi.DeleteInstance(instanceName); } }
public void SqlLocalDbInstance_CreateConnectionStringBuilder_Throws_If_Instance_Not_Started() { // Arrange Helpers.EnsureLocalDBInstalled(); string instanceName = Guid.NewGuid().ToString(); SqlLocalDbApi.CreateInstance(instanceName); try { SqlLocalDbInstance target = new SqlLocalDbInstance(instanceName); // Act and Assert throw ErrorAssert.Throws<InvalidOperationException>( () => target.CreateConnectionStringBuilder()); } finally { SqlLocalDbApi.DeleteInstance(instanceName); } }
public void SqlLocalDbInstance_CreateConnectionStringBuilder_If_Instance_Started() { // Arrange Helpers.EnsureLocalDBInstalled(); string instanceName = Guid.NewGuid().ToString(); SqlLocalDbApi.CreateInstance(instanceName); try { SqlLocalDbInstance target = new SqlLocalDbInstance(instanceName); target.Start(); try { // Act SqlConnectionStringBuilder result = target.CreateConnectionStringBuilder(); // Assert Assert.IsNotNull(result, "CreateConnection() returned null."); StringAssert.Contains(result.ConnectionString, target.NamedPipe, "SqlConnection.ConnectionString is incorrect."); } finally { SqlLocalDbApi.StopInstance(instanceName); } } finally { SqlLocalDbApi.DeleteInstance(instanceName); } }