@@ -48,7 +48,7 @@ public void CreatePremiumDatabasesWithSqlAuth()
4848 "$context" ) ;
4949 HttpSession testSession = MockServerHelper . DefaultSessionCollection . GetSession (
5050 "UnitTest.Common.CreatePremiumDatabasesWithSqlAuth" ) ;
51- DatabaseTestHelper . SetDefaultTestSessionSettings ( testSession ) ;
51+ DatabaseTestHelper . SetDefaultTestSessionSettings ( testSession ) ;
5252 testSession . RequestValidator =
5353 new Action < HttpMessage , HttpMessage . Request > (
5454 ( expected , actual ) =>
@@ -57,69 +57,79 @@ public void CreatePremiumDatabasesWithSqlAuth()
5757 Assert . AreEqual ( expected . RequestInfo . UserAgent , actual . UserAgent ) ;
5858 } ) ;
5959
60- using ( AsyncExceptionManager exceptionManager = new AsyncExceptionManager ( ) )
60+ TestCreatePremiumDatabase ( powershell , testSession ) ;
61+ }
62+ }
63+
64+ /// <summary>
65+ /// Helper function to create premium database in the powershell environment provided.
66+ /// </summary>
67+ /// <param name="powershell">The powershell environment</param>
68+ /// <param name="testSession">The test session</param>
69+ private static void TestCreatePremiumDatabase ( System . Management . Automation . PowerShell powershell , HttpSession testSession )
70+ {
71+ using ( AsyncExceptionManager exceptionManager = new AsyncExceptionManager ( ) )
72+ {
73+ Collection < PSObject > premiumDB_P1 , PremiumDB_P2 ;
74+ using ( new MockHttpServer (
75+ exceptionManager ,
76+ MockHttpServer . DefaultServerPrefixUri ,
77+ testSession ) )
6178 {
62- Collection < PSObject > premiumDB_P1 , PremiumDB_P2 ;
63- using ( new MockHttpServer (
64- exceptionManager ,
65- MockHttpServer . DefaultServerPrefixUri ,
66- testSession ) )
67- {
68- powershell . InvokeBatchScript (
69- @"$P1 = Get-AzureSqlDatabaseServiceObjective" +
70- @" -Context $context" +
71- @" -ServiceObjectiveName ""P1""" ) ;
72-
73- powershell . InvokeBatchScript (
74- @"$P2 = Get-AzureSqlDatabaseServiceObjective " +
75- @"-Context $context" +
76- @" -ServiceObjectiveName ""P2""" ) ;
77-
78- premiumDB_P1 = powershell . InvokeBatchScript (
79- @"$premiumDB_P1 = New-AzureSqlDatabase " +
80- @"-Context $context " +
81- @"-DatabaseName NewAzureSqlPremiumDatabaseTests_P1 " +
82- @"-Edition Premium " +
83- @"-ServiceObjective $P1 " ) ;
84- premiumDB_P1 = powershell . InvokeBatchScript ( "$PremiumDB_P1" ) ;
85-
86- powershell . InvokeBatchScript (
87- @"$PremiumDB_P2 = New-AzureSqlDatabase " +
88- @"-Context $context " +
89- @"-DatabaseName NewAzureSqlPremiumDatabaseTests_P2 " +
90- @"-Collation Japanese_CI_AS " +
91- @"-Edition Premium " +
92- @"-ServiceObjective $P2 " +
93- @"-MaxSizeGB 10 " +
94- @"-Force" ) ;
95- PremiumDB_P2 = powershell . InvokeBatchScript ( "$PremiumDB_P2" ) ;
96- }
79+ powershell . InvokeBatchScript (
80+ @"$P1 = Get-AzureSqlDatabaseServiceObjective" +
81+ @" -Context $context" +
82+ @" -ServiceObjectiveName ""P1""" ) ;
9783
98- Assert . AreEqual ( 0 , powershell . Streams . Error . Count , "Errors during run!" ) ;
99- Assert . AreEqual ( 0 , powershell . Streams . Warning . Count , "Warnings during run!" ) ;
100- powershell . Streams . ClearStreams ( ) ;
101-
102- Assert . IsTrue (
103- premiumDB_P1 . Single ( ) . BaseObject is Services . Server . Database ,
104- "Expecting a Database object" ) ;
105- Services . Server . Database databaseP1 =
106- ( Services . Server . Database ) premiumDB_P1 . Single ( ) . BaseObject ;
107- Assert . AreEqual ( "NewAzureSqlPremiumDatabaseTests_P1" , databaseP1 . Name , "Expected db name to be NewAzureSqlPremiumDatabaseTests_P1" ) ;
108-
109- Assert . IsTrue (
110- PremiumDB_P2 . Single ( ) . BaseObject is Services . Server . Database ,
111- "Expecting a Database object" ) ;
112- Services . Server . Database databaseP2 =
113- ( Services . Server . Database ) PremiumDB_P2 . Single ( ) . BaseObject ;
114- Assert . AreEqual ( "NewAzureSqlPremiumDatabaseTests_P2" , databaseP2 . Name , "Expected db name to be NewAzureSqlPremiumDatabaseTests_P2" ) ;
115-
116- Assert . AreEqual (
117- "Japanese_CI_AS" ,
118- databaseP2 . CollationName ,
119- "Expected collation to be Japanese_CI_AS" ) ;
120- Assert . AreEqual ( "Premium" , databaseP2 . Edition , "Expected edition to be Premium" ) ;
121- Assert . AreEqual ( 10 , databaseP2 . MaxSizeGB , "Expected max size to be 10 GB" ) ;
84+ powershell . InvokeBatchScript (
85+ @"$P2 = Get-AzureSqlDatabaseServiceObjective " +
86+ @"-Context $context" +
87+ @" -ServiceObjectiveName ""P2""" ) ;
88+
89+ premiumDB_P1 = powershell . InvokeBatchScript (
90+ @"$premiumDB_P1 = New-AzureSqlDatabase " +
91+ @"-Context $context " +
92+ @"-DatabaseName NewAzureSqlPremiumDatabaseTests_P1 " +
93+ @"-Edition Premium " +
94+ @"-ServiceObjective $P1 " ) ;
95+ premiumDB_P1 = powershell . InvokeBatchScript ( "$PremiumDB_P1" ) ;
96+
97+ powershell . InvokeBatchScript (
98+ @"$PremiumDB_P2 = New-AzureSqlDatabase " +
99+ @"-Context $context " +
100+ @"-DatabaseName NewAzureSqlPremiumDatabaseTests_P2 " +
101+ @"-Collation Japanese_CI_AS " +
102+ @"-Edition Premium " +
103+ @"-ServiceObjective $P2 " +
104+ @"-MaxSizeGB 10 " +
105+ @"-Force" ) ;
106+ PremiumDB_P2 = powershell . InvokeBatchScript ( "$PremiumDB_P2" ) ;
122107 }
108+
109+ Assert . AreEqual ( 0 , powershell . Streams . Error . Count , "Errors during run!" ) ;
110+ Assert . AreEqual ( 0 , powershell . Streams . Warning . Count , "Warnings during run!" ) ;
111+ powershell . Streams . ClearStreams ( ) ;
112+
113+ Assert . IsTrue (
114+ premiumDB_P1 . Single ( ) . BaseObject is Services . Server . Database ,
115+ "Expecting a Database object" ) ;
116+ Services . Server . Database databaseP1 =
117+ ( Services . Server . Database ) premiumDB_P1 . Single ( ) . BaseObject ;
118+ Assert . AreEqual ( "NewAzureSqlPremiumDatabaseTests_P1" , databaseP1 . Name , "Expected db name to be NewAzureSqlPremiumDatabaseTests_P1" ) ;
119+
120+ Assert . IsTrue (
121+ PremiumDB_P2 . Single ( ) . BaseObject is Services . Server . Database ,
122+ "Expecting a Database object" ) ;
123+ Services . Server . Database databaseP2 =
124+ ( Services . Server . Database ) PremiumDB_P2 . Single ( ) . BaseObject ;
125+ Assert . AreEqual ( "NewAzureSqlPremiumDatabaseTests_P2" , databaseP2 . Name , "Expected db name to be NewAzureSqlPremiumDatabaseTests_P2" ) ;
126+
127+ Assert . AreEqual (
128+ "Japanese_CI_AS" ,
129+ databaseP2 . CollationName ,
130+ "Expected collation to be Japanese_CI_AS" ) ;
131+ Assert . AreEqual ( "Premium" , databaseP2 . Edition , "Expected edition to be Premium" ) ;
132+ Assert . AreEqual ( 10 , databaseP2 . MaxSizeGB , "Expected max size to be 10 GB" ) ;
123133 }
124134 }
125135
0 commit comments