示例#1
0
 public void AssertStoredProcedureExists_WhenTheStoredProcedureDoesExist_DoesNothing()
 {
     RunnerContainer.MigrateUp(new UpOnlyMigration((m, a) =>
     {
         a.StoredProcedureExists("CustOrderHist");
         m.Create.Table("Hello").WithColumn("Id").AsInt32().PrimaryKey();
     }));
     SqlExecutor.TableExists("Hello").Should().BeTrue();
 }
示例#2
0
 public void AssertServerPrincipalHasRole_WhenTheRoleHasBeenAssigned_DoesNothing()
 {
     RunnerContainer.MigrateUp(new UpOnlyMigration((m, a) =>
     {
         a.ServerPrincipalExists("sa").WithRole("sysadmin");
         m.Create.Table("Hello").WithColumn("Id").AsInt32().PrimaryKey();
     }));
     SqlExecutor.TableExists("Hello").Should().BeTrue();
 }
示例#3
0
 public void AssertDatabasePrincipalExists_WhenTheDatabasePrincipalDoesExist_DoesNothing()
 {
     RunnerContainer.MigrateUp(new UpOnlyMigration((m, a) =>
     {
         a.DatabasePrincipalExists("guest");
         m.Create.Table("Hello").WithColumn("Id").AsInt32().PrimaryKey();
     }));
     SqlExecutor.TableExists("Hello").Should().BeTrue();
 }
示例#4
0
 public void AssertStoredProcedureWithDefinition_WhenTheDefinitionIsCorrect_DoesNothing()
 {
     RunnerContainer.MigrateUp(new UpOnlyMigration((m, a) =>
     {
         a.StoredProcedureExists("CustOrderHist").WithDefinitionFromEmbeddedResource("CustOrderHistDefinition.sql");
         m.Create.Table("Hello").WithColumn("Id").AsInt32().PrimaryKey();
     }));
     SqlExecutor.TableExists("Hello").Should().BeTrue();
 }
 public void AssertFunctionWithDefinition_WhenTheDefinitionIsCorrect_DoesNothing()
 {
     RunnerContainer.MigrateUp(new UpOnlyMigration((m, a) =>
     {
         a.FunctionExists("Echo", FunctionType.Scalar).WithDefinition(@"CREATE FUNCTION Echo(	@Param int)RETURNS intASBEGIN	RETURN @ParamEND");
         m.Create.Table("Hello").WithColumn("Id").AsInt32().PrimaryKey();
     }));
     SqlExecutor.TableExists("Hello").Should().BeTrue();
 }
 public void AssertFunctionExists_WhenTheFunctionDoesExist_DoesNothing()
 {
     RunnerContainer.MigrateUp(new UpOnlyMigration((m, a) =>
     {
         a.FunctionExists("Echo", FunctionType.Scalar);
         m.Create.Table("Hello").WithColumn("Id").AsInt32().PrimaryKey();
     }));
     SqlExecutor.TableExists("Hello").Should().BeTrue();
 }
示例#7
0
 public void AssertServerPrincipalHasRole_WhenTheRoleHasNotBeenAssigned_AbortsTheMigration()
 {
     Assert.Throws <Exception>(() => RunnerContainer.MigrateUp(new UpOnlyMigration((m, a) =>
     {
         m.Create.Table("Hello").WithColumn("Id").AsInt32().PrimaryKey();
         a.ServerPrincipalExists("sa").WithRole("sadsda");
         m.Create.Table("World").WithColumn("Id").AsInt32().PrimaryKey();
     })));
     SqlExecutor.TableExists("Hello").Should().BeFalse();
     SqlExecutor.TableExists("World").Should().BeFalse();
 }
示例#8
0
 public void AssertDatabasePrincipalExists_WhenTheDatabasePrincipalDoesNotExist_AbortsTheMigration()
 {
     Assert.Throws <Exception>(() => RunnerContainer.MigrateUp(new UpOnlyMigration((m, a) =>
     {
         m.Create.Table("Hello").WithColumn("Id").AsInt32().PrimaryKey();
         a.DatabasePrincipalExists("Gdfsf");
         m.Create.Table("World").WithColumn("Id").AsInt32().PrimaryKey();
     })));
     SqlExecutor.TableExists("Hello").Should().BeFalse();
     SqlExecutor.TableExists("World").Should().BeFalse();
 }
示例#9
0
 public void AssertStoredProcedureWithDefinition_WhenTheDefinitionIsIncorrect_AbortsTheMigration()
 {
     Assert.Throws <Exception>(() => RunnerContainer.MigrateUp(new UpOnlyMigration((m, a) =>
     {
         m.Create.Table("Hello").WithColumn("Id").AsInt32().PrimaryKey();
         a.StoredProcedureExists("CustOrderHist").WithDefinitionFromEmbeddedResource("CustOrderHistDefinitionWrong.sql");
         m.Create.Table("World").WithColumn("Id").AsInt32().PrimaryKey();
     })));
     SqlExecutor.TableExists("Hello").Should().BeFalse();
     SqlExecutor.TableExists("World").Should().BeFalse();
 }
 public void AssertFunctionWithDefinition_WhenTheDefinitionIsIncorrect_AbortsTheMigration()
 {
     Assert.Throws <Exception>(() => RunnerContainer.MigrateUp(new UpOnlyMigration((m, a) =>
     {
         m.Create.Table("Hello").WithColumn("Id").AsInt32().PrimaryKey();
         a.FunctionExists("Echo", FunctionType.Scalar).WithDefinition("dsdfdf");
         m.Create.Table("World").WithColumn("Id").AsInt32().PrimaryKey();
     })));
     SqlExecutor.TableExists("Hello").Should().BeFalse();
     SqlExecutor.TableExists("World").Should().BeFalse();
 }
 public void AssertFunctionExists_WhenTheFunctionDoesNotExist_AbortsTheMigration()
 {
     Assert.Throws <Exception>(() => RunnerContainer.MigrateUp(new UpOnlyMigration((m, a) =>
     {
         m.Create.Table("Hello").WithColumn("Id").AsInt32().PrimaryKey();
         a.FunctionExists("Gdfsf", FunctionType.InlineTableValued);
         m.Create.Table("World").WithColumn("Id").AsInt32().PrimaryKey();
     })));
     SqlExecutor.TableExists("Hello").Should().BeFalse();
     SqlExecutor.TableExists("World").Should().BeFalse();
 }
 public void AssertObjectExists_WhenTheObjectDoesNotExist_AbortsTheMigration()
 {
     Assert.Throws <Exception>(() => RunnerContainer.MigrateUp(new UpOnlyMigration((m, a) =>
     {
         m.Create.Table("Hello").WithColumn("Id").AsInt32().PrimaryKey();
         a.ObjectExists("Gdfsf", ObjectType.StoredProcedure);
         m.Create.Table("World").WithColumn("Id").AsInt32().PrimaryKey();
     })));
     SqlExecutor.TableExists("Hello").Should().BeFalse();
     SqlExecutor.TableExists("World").Should().BeFalse();
 }