Пример #1
0
        public void ValidateDatabaseExistsWorks()
        {
            var catalog = "NoneExistsCatalog";
            var smo     = new SmoOperations();
            var results = smo.DatabaseExists(catalog);

            Assert.IsFalse(smo.DatabaseExists(catalog));
        }
Пример #2
0
        public void ValidateServerIsAvailable()
        {
            var backEndOperations = new SqlOperations();
            var smo = new SmoOperations();

            Assert.IsNotNull(smo.LocalServers().FirstOrDefault(server => server.Name == backEndOperations.Server),
                             $"Expected server {backEndOperations.Server} to be available");
        }
Пример #3
0
        public void ValidateServerIsNotAvailable()
        {
            var backEndOperations = new SqlOperations();
            var smo = new SmoOperations();

            var badServerName = "BadBadServerName";

            Assert.IsNull(smo.LocalServers().FirstOrDefault(server => server.Name == badServerName),
                          $"Expected not to find {badServerName}");
        }
Пример #4
0
        public void DefaultCatalogExists()
        {
            var ops = new SqlOperations(TestCatalog);

            SqlConnectionStringBuilder builder =
                new SqlConnectionStringBuilder(ops.ConnectionString);

            var catalog = builder.InitialCatalog;
            var smo     = new SmoOperations();
            var results = smo.DatabaseExists(catalog);

            Assert.IsTrue(smo.DatabaseExists(catalog));
        }
Пример #5
0
        private void Form1_Shown(object sender, EventArgs e)
        {
            try
            {
                serverOperations = new SmoOperations();
                var serverPath = serverOperations.SqlServerInstallPath();

                if (System.IO.Directory.Exists(serverPath))
                {
                    lblInstalledPath.Text = $"SQL Server install path:{serverOperations.SqlServerInstallPath()}";
                }
            }
            catch (Exception ex)
            {
                Controls.OfType <Button>().ToList().ForEach(b => b.Enabled = false);
                Dialogs.ExceptionDialog(ex);
            }
        }
Пример #6
0
        public void TablesExists()
        {
            var ops = new SqlOperations(TestCatalog);

            SqlConnectionStringBuilder builder =
                new SqlConnectionStringBuilder(ops.ConnectionString);

            var catalog = builder.InitialCatalog;
            var smo     = new SmoOperations();

            Assert.IsTrue(smo.TableExists(catalog, "People"),
                          "Expected to find People table");

            Assert.IsTrue(smo.TableExists(catalog, "Gender"),
                          "Expected to find Gender table");

            Assert.IsFalse(smo.TableExists(catalog, "Products"),
                           "Expected not to find Products table");
        }
Пример #7
0
        public void ConstraintExists()
        {
            var ops = new SqlOperations(TestCatalog);

            SqlConnectionStringBuilder builder =
                new SqlConnectionStringBuilder(ops.ConnectionString);

            var catalog = builder.InitialCatalog;
            var smo     = new SmoOperations();


            var test = smo.TableKeys(catalog, "Gender");

            Assert.IsTrue(test.Count == 1,
                          "Expected one constraint");

            Assert.IsTrue(test.First().SchemaName == "FK_People_Gender",
                          "FK_People_Gender does not exists");

            Assert.IsTrue(test.First().TableName == "People",
                          "TableName should be People");
        }