CreateTestDatabasesWithSqlAuth() public static method

Helper function to create the test databases.
public static CreateTestDatabasesWithSqlAuth ( ) : void
return void
Esempio n. 1
0
 public void SetupTest()
 {
     AzureSessionInitializer.InitializeAzureSession();
     ServiceManagementProfileProvider.InitializeServiceManagementProfile();
     AzureSMProfileProvider.Instance.Profile = new AzureSMProfile();
     // Create 2 test databases
     NewAzureSqlDatabaseTests.CreateTestDatabasesWithSqlAuth();
 }
Esempio n. 2
0
        public static void InitializeClass(TestContext context)
        {
            // Create atleast two test databases
            NewAzureSqlDatabaseTests.CreateTestDatabasesWithSqlAuth();

            // Remove the test databases
            NewAzureSqlDatabaseTests.RemoveTestDatabasesWithSqlAuth();
        }
Esempio n. 3
0
        public static void InitializeClass(TestContext context)
        {
            AzureSessionInitializer.InitializeAzureSession();
            ServiceManagementProfileProvider.InitializeServiceManagementProfile();
            AzureSMProfileProvider.Instance.Profile = new AzureSMProfile();
            // Create atleast two test databases
            NewAzureSqlDatabaseTests.CreateTestDatabasesWithSqlAuth();

            // Remove the test databases
            NewAzureSqlDatabaseTests.RemoveTestDatabasesWithSqlAuth();
        }
Esempio n. 4
0
        /// <summary>
        /// Helper function to create the test databases.
        /// </summary>
        public static void CreateTestDatabasesWithSqlAuth()
        {
            using (System.Management.Automation.PowerShell powershell =
                       System.Management.Automation.PowerShell.Create())
            {
                // Create a context
                NewAzureSqlDatabaseServerContextTests.CreateServerContextSqlAuth(
                    powershell,
                    "$context");

                // Create the 2 test databases
                NewAzureSqlDatabaseTests.CreateTestDatabasesWithSqlAuth(
                    powershell,
                    "$context");
            }
        }
Esempio n. 5
0
 public void InitializeTest()
 {
     // Create 2 test databases
     NewAzureSqlDatabaseTests.CreateTestDatabasesWithSqlAuth();
 }
Esempio n. 6
0
 public void SetupTest()
 {
     // Create 2 test databases
     NewAzureSqlDatabaseTests.CreateTestDatabasesWithSqlAuth();
 }
Esempio n. 7
0
        public void RemoveAzureSqlDatabaseWithSqlAuth()
        {
            using (System.Management.Automation.PowerShell powershell =
                       System.Management.Automation.PowerShell.Create())
            {
                // Create a context
                NewAzureSqlDatabaseServerContextTests.CreateServerContextSqlAuth(
                    powershell,
                    "$context");

                // Create 2 test databases
                NewAzureSqlDatabaseTests.CreateTestDatabasesWithSqlAuth(
                    powershell,
                    "$context");

                HttpSession testSession = MockServerHelper.DefaultSessionCollection.GetSession(
                    "UnitTests.RemoveAzureSqlDatabaseWithSqlAuth");
                DatabaseTestHelper.SetDefaultTestSessionSettings(testSession);
                testSession.RequestValidator =
                    new Action <HttpMessage, HttpMessage.Request>(
                        (expected, actual) =>
                {
                    Assert.AreEqual(expected.RequestInfo.Method, actual.Method);
                    Assert.AreEqual(expected.RequestInfo.UserAgent, actual.UserAgent);
                    if (expected.Index < 8)
                    {
                        // Request 0-5: Remove database requests
                        // Request 6-7: Get all database request
                        DatabaseTestHelper.ValidateHeadersForODataRequest(
                            expected.RequestInfo,
                            actual);
                    }
                    else
                    {
                        Assert.Fail("No more requests expected.");
                    }
                });

                using (AsyncExceptionManager exceptionManager = new AsyncExceptionManager())
                {
                    // Create context with both ManageUrl and ServerName overriden
                    Collection <PSObject> databases;
                    using (new MockHttpServer(
                               exceptionManager,
                               MockHttpServer.DefaultServerPrefixUri,
                               testSession))
                    {
                        powershell.InvokeBatchScript(
                            @"Remove-AzureSqlDatabase " +
                            @"-Context $context " +
                            @"-DatabaseName testdb1 " +
                            @"-Force");
                        powershell.InvokeBatchScript(
                            @"Remove-AzureSqlDatabase " +
                            @"-Context $context " +
                            @"-DatabaseName testdb2 " +
                            @"-Force");

                        databases = powershell.InvokeBatchScript(
                            @"Get-AzureSqlDatabase " +
                            @"-Context $context");
                    }

                    Assert.AreEqual(0, powershell.Streams.Error.Count, "Errors during run!");
                    Assert.AreEqual(0, powershell.Streams.Warning.Count, "Warnings during run!");
                    powershell.Streams.ClearStreams();

                    Assert.AreEqual(1, databases.Count, "Expecting only master database object");
                }
            }
        }