public void GetAzureSqlDatabaseWithSqlAuthv12() { var mockConn = new MockSqlConnection(); TSqlConnectionContext.MockSqlConnection = mockConn; using (System.Management.Automation.PowerShell powershell = System.Management.Automation.PowerShell.Create()) { // Create a context NewAzureSqlDatabaseServerContextTests.CreateServerContextSqlAuthV12( powershell, manageUrl, username, password, "$context"); Collection <PSObject> database1, database2, database3; database1 = powershell.InvokeBatchScript( @"$testdb1 = Get-AzureSqlDatabase " + @"-Context $context " + @"-DatabaseName testdb1 ", @"$testdb1"); database2 = powershell.InvokeBatchScript( @"$testdb2 = Get-AzureSqlDatabase " + @"-Context $context " + @"-Database $testdb1 ", @"$testdb2"); database3 = powershell.InvokeBatchScript( @"$testdb3 = Get-AzureSqlDatabase " + @"-Context $context ", @"$testdb3"); Assert.AreEqual(0, powershell.Streams.Error.Count, "Errors during run!"); Assert.AreEqual(0, powershell.Streams.Warning.Count, "Warnings during run!"); powershell.Streams.ClearStreams(); Services.Server.Database database = database1.Single().BaseObject as Services.Server.Database; Assert.IsTrue(database != null, "Expecting a Database object"); ValidateDatabaseProperties(database, "testdb1", "Standard", 250, 268435456000L, "SQL_Latin1_General_CP1_CI_AS", false, DatabaseTestHelper.StandardS0SloGuid); database = database2.Single().BaseObject as Services.Server.Database; Assert.IsTrue(database != null, "Expecting a Database object"); ValidateDatabaseProperties(database, "testdb1", "Standard", 250, 268435456000L, "SQL_Latin1_General_CP1_CI_AS", false, DatabaseTestHelper.StandardS0SloGuid); Assert.IsTrue(database3.Count == 5); foreach (var entry in database3) { var db = entry.BaseObject as Services.Server.Database; Assert.IsTrue(db != null, "Expecting a Database object"); } } }
public void NewAzureSqlDatabaseWithSqlAuthv12() { var mockConn = new MockSqlConnection(); TSqlConnectionContext.MockSqlConnection = mockConn; using (System.Management.Automation.PowerShell powershell = System.Management.Automation.PowerShell.Create()) { // Create a context NewAzureSqlDatabaseServerContextTests.CreateServerContextSqlAuthV12( powershell, manageUrl, username, password, "$context"); Collection <PSObject> database1, database2, database3, database4; database1 = powershell.InvokeBatchScript( @"$testdb1 = New-AzureSqlDatabase " + @"-Context $context " + @"-DatabaseName testdb1 " + @"-Force", @"$testdb1"); database2 = powershell.InvokeBatchScript( @"$testdb2 = New-AzureSqlDatabase " + @"-Context $context " + @"-DatabaseName testdb2 " + @"-Collation Japanese_CI_AS " + @"-Edition Basic " + @"-MaxSizeGB 2 " + @"-Force", @"$testdb2"); database3 = powershell.InvokeBatchScript( @"$testdb3 = New-AzureSqlDatabase " + @"-Context $context " + @"-DatabaseName testdb3 " + @"-MaxSizeBytes 107374182400 " + @"-Force", @"$testdb3"); var slo = powershell.InvokeBatchScript( @"$so = Get-AzureSqlDatabaseServiceObjective " + @"-Context $context " + @"-ServiceObjectiveName S2 ", @"$so"); database4 = powershell.InvokeBatchScript( @"$testdb4 = New-AzureSqlDatabase " + @"-Context $context " + @"-DatabaseName testdb4 " + @"-Edition Standard " + @"-ServiceObjective $so " + @"-Force", @"$testdb4"); Assert.AreEqual(0, powershell.Streams.Error.Count, "Errors during run!"); Assert.AreEqual(0, powershell.Streams.Warning.Count, "Warnings during run!"); powershell.Streams.ClearStreams(); Services.Server.Database database = database1.Single().BaseObject as Services.Server.Database; Assert.IsTrue(database != null, "Expecting a Database object"); ValidateDatabaseProperties(database, "testdb1", "Standard", 250, 268435456000L, "SQL_Latin1_General_CP1_CI_AS", false, DatabaseTestHelper.StandardS0SloGuid); database = database2.Single().BaseObject as Services.Server.Database; Assert.IsTrue(database != null, "Expecting a Database object"); ValidateDatabaseProperties(database, "testdb2", "Basic", 2, 2147483648L, "Japanese_CI_AS", false, DatabaseTestHelper.BasicSloGuid); database = database3.Single().BaseObject as Services.Server.Database; Assert.IsTrue(database != null, "Expecting a Database object"); ValidateDatabaseProperties(database, "testdb3", "Standard", 100, 107374182400L, "SQL_Latin1_General_CP1_CI_AS", false, DatabaseTestHelper.StandardS0SloGuid); database = database4.Single().BaseObject as Services.Server.Database; Assert.IsTrue(database != null, "Expecting a Database object"); ValidateDatabaseProperties(database, "testdb4", "Standard", 250, 268435456000L, "SQL_Latin1_General_CP1_CI_AS", false, DatabaseTestHelper.StandardS2SloGuid); } }