public void SqlLocalDbInstance_Share_Throws_If_SharedName_Is_Invalid() { // Arrange Helpers.EnsureLocalDBInstalled(); string instanceName = Guid.NewGuid().ToString(); string sharedName = "\\\\"; SqlLocalDbApi.CreateInstance(instanceName); try { SqlLocalDbInstance target = new SqlLocalDbInstance(instanceName); // Act SqlLocalDbException error = ErrorAssert.Throws <SqlLocalDbException>( () => target.Share(sharedName)); // Assert Assert.AreEqual(SqlLocalDbErrors.InvalidInstanceName, error.ErrorCode, "SqlLocalDbException.ErrorCode is incorrect."); Assert.AreEqual(instanceName, error.InstanceName, "SqlLocalDbException.InstanceName is incorrect."); throw error; } finally { SqlLocalDbApi.DeleteInstance(instanceName); } }
public void SqlLocalDbInstance_Share_Throws_If_SharedName_Is_Null() { // Arrange Helpers.EnsureLocalDBInstalled(); string instanceName = Guid.NewGuid().ToString(); SqlLocalDbApi.CreateInstance(instanceName); try { SqlLocalDbInstance target = new SqlLocalDbInstance(instanceName); string sharedName = null; // Act and Assert throw ErrorAssert.Throws <ArgumentNullException>( () => target.Share(sharedName), "sharedName"); } finally { SqlLocalDbApi.DeleteInstance(instanceName); } }
public void SqlLocalDbInstance_Unshare_If_Instance_Is_Started() { // Arrange Helpers.EnsureLocalDBInstalled(); Helpers.EnsureUserIsAdmin(); string instanceName = Guid.NewGuid().ToString(); SqlLocalDbApi.CreateInstance(instanceName); try { SqlLocalDbInstance target = new SqlLocalDbInstance(instanceName); target.Start(); try { string sharedName = Guid.NewGuid().ToString(); target.Share(sharedName); ISqlLocalDbInstanceInfo info = SqlLocalDbApi.GetInstanceInfo(instanceName); Assert.IsNotNull(info, "SqlLocalDbApi.GetInstanceInfo() returned null."); Assert.IsTrue(info.IsShared, "ISqlLocalDbInstanceInfo.IsShared is incorrect."); Assert.AreEqual(sharedName, info.SharedName, "ISqlLocalDbInstanceInfo.SharedName is incorrect."); // Act target.Unshare(); // Assert info = SqlLocalDbApi.GetInstanceInfo(instanceName); Assert.IsNotNull(info, "SqlLocalDbApi.GetInstanceInfo() returned null."); Assert.IsFalse(info.IsShared, "ISqlLocalDbInstanceInfo.IsShared is incorrect."); Assert.AreEqual(string.Empty, info.SharedName, "ISqlLocalDbInstanceInfo.SharedName is incorrect."); } finally { SqlLocalDbApi.StopInstance(instanceName); } } finally { SqlLocalDbApi.DeleteInstance(instanceName); } }
public void SqlLocalDbInstance_Share_Throws_If_SharedName_Is_Null() { // Arrange Helpers.EnsureLocalDBInstalled(); string instanceName = Guid.NewGuid().ToString(); SqlLocalDbApi.CreateInstance(instanceName); try { SqlLocalDbInstance target = new SqlLocalDbInstance(instanceName); string sharedName = null; // Act and Assert throw ErrorAssert.Throws<ArgumentNullException>( () => target.Share(sharedName), "sharedName"); } finally { SqlLocalDbApi.DeleteInstance(instanceName); } }
public void SqlLocalDbInstance_Share_Throws_If_SharedName_Is_Invalid() { // Arrange Helpers.EnsureLocalDBInstalled(); string instanceName = Guid.NewGuid().ToString(); string sharedName = "\\\\"; SqlLocalDbApi.CreateInstance(instanceName); try { SqlLocalDbInstance target = new SqlLocalDbInstance(instanceName); // Act SqlLocalDbException error = ErrorAssert.Throws<SqlLocalDbException>( () => target.Share(sharedName)); // Assert Assert.AreEqual(SqlLocalDbErrors.InvalidInstanceName, error.ErrorCode, "SqlLocalDbException.ErrorCode is incorrect."); Assert.AreEqual(instanceName, error.InstanceName, "SqlLocalDbException.InstanceName is incorrect."); throw error; } finally { SqlLocalDbApi.DeleteInstance(instanceName); } }