Esempio n. 1
0
        public void TestUninstall(
            [ValueSource("ConnectionStrings")] string connectionString,
            [ValueSource("Schemas")] IEnumerable <string> schema)
        {
            TestWithRollback(connectionString, connection =>
            {
                // try to install the schema and verify that they are there
                Install(connection, schema);
                VerifyObjectsAndRegistry(schema, connection);

                // uninstall it
                SchemaInstaller installer = new SchemaInstaller(connection);
                installer.Uninstall(TestSchemaGroup);

                // make sure the registry is empty
                SchemaRegistry registry = new SchemaRegistry(connection, TestSchemaGroup);
                Assert.IsTrue(!registry.Entries.Any());

                // make sure all of the objects exist in the database
                foreach (var schemaObject in schema.Select(s => new SchemaObject(s)))
                {
                    Assert.False(schemaObject.Exists(connection), "Object {0} is not deleted from database", schemaObject.Name);
                }
            });
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            SqlConnectionStringBuilder connectionString = new SqlConnectionStringBuilder("Database=.;Initial Catalog=InsightTest;Integrated Security=true");

            SchemaInstaller.CreateDatabase(connectionString.ConnectionString);

            using (SqlConnection connection = new SqlConnection(connectionString.ConnectionString))
            {
                connection.Open();

                // make sure our database exists
                SchemaInstaller installer = new SchemaInstaller(connection);
                new SchemaEventConsoleLogger().Attach(installer);

                // load the schema from the embedded resources in this project
                SchemaObjectCollection schema = new SchemaObjectCollection();
                schema.Load(Assembly.GetExecutingAssembly());

                // install the schema
                Console.WriteLine("Installing");
                installer.Install("BeerGarten", schema);

                // uninstall the schema
                if (args.Length > 0 && args[0].ToUpperInvariant() == "UNINSTALL")
                {
                    Console.WriteLine("Uninstalling");
                    installer.Uninstall("BeerGarten");
                }
            }
        }
		public void TestUninstall(
			[ValueSource("ConnectionStrings")] string connectionString,
			[ValueSource("Schemas")] IEnumerable<string> schema)
		{
			TestWithRollback(connectionString, connection =>
			{
				// try to install the schema and verify that they are there
				Install(connection, schema);
				VerifyObjectsAndRegistry(schema, connection);

				// uninstall it
				SchemaInstaller installer = new SchemaInstaller(connection);
				installer.Uninstall(TestSchemaGroup);

				// make sure the registry is empty
				SchemaRegistry registry = new SchemaRegistry(connection, TestSchemaGroup);
				Assert.IsTrue(!registry.Entries.Any());

				// make sure all of the objects exist in the database
				foreach (var schemaObject in schema.Select(s => new SchemaObject(s)))
					Assert.False(schemaObject.Exists(connection), "Object {0} is not deleted from database", schemaObject.Name);
			});
		}