예제 #1
0
        public void SqlLocalDbProvider_As_ISqlLocalDbFactory_GetInstance_Returns_Specified_Instance()
        {
            // Arrange
            Helpers.EnsureLocalDBInstalled();

            ISqlLocalDbProvider target = new SqlLocalDbProvider();
            string instanceName        = Guid.NewGuid().ToString();

            // Act
            SqlLocalDbApi.CreateInstance(instanceName);

            try
            {
                // Assert
                ISqlLocalDbInstance result = target.GetInstance(instanceName);

                Assert.IsNotNull(result, "CreateInstance() returned null.");
                Assert.AreEqual(instanceName, result.Name, "SqlLocalDbInstance.Name is incorrect.");

                ISqlLocalDbInstanceInfo info = result.GetInstanceInfo();

                Assert.IsTrue(info.Exists, "ISqlLocalDbInstanceInfo.Exists is incorrect.");
                Assert.IsFalse(info.IsRunning, "ISqlLocalDbInstanceInfo.IsRunning is incorrect.");

                Assert.IsTrue(Guid.TryParse(result.Name, out Guid unused), "SqlLocalDbInstance.Name is not a valid GUID.");
            }
            finally
            {
                SqlLocalDbApi.DeleteInstance(instanceName);
            }
        }
 /// <summary>
 /// Returns information about the LocalDB instance.
 /// </summary>
 /// <returns>
 /// An instance of <see cref="ISqlLocalDbInstanceInfo" /> containing
 /// information about the LocalDB instance.
 /// </returns>
 /// <exception cref="ObjectDisposedException">
 /// The instance has been disposed.
 /// </exception>
 public ISqlLocalDbInstanceInfo GetInstanceInfo()
 {
     EnsureNotDisposed();
     return(_instance.GetInstanceInfo());
 }