public void GetAzureSqlDatabasesWithCertAuth() { SimpleSqlDatabaseManagement channel = new SimpleSqlDatabaseManagement(); channel.GetDatabasesThunk = ar => { List<SqlDatabaseResponse> databases = new List<SqlDatabaseResponse>(); SqlDatabaseResponse db1 = new SqlDatabaseResponse(); db1.CollationName = "Japanese_CI_AS"; db1.Edition = "Web"; db1.Id = "1"; db1.MaxSizeGB = "1"; db1.Name = "testdb1"; db1.CreationDate = DateTime.Now.ToString(); db1.IsFederationRoot = true.ToString(); db1.IsSystemObject = true.ToString(); db1.MaxSizeBytes = "1073741824"; databases.Add(db1); SqlDatabaseResponse db2 = new SqlDatabaseResponse(); db2.CollationName = "Japanese_CI_AS"; db2.Edition = "Business"; db2.Id = "2"; db2.MaxSizeGB = "10"; db2.Name = "testdb2"; db2.CreationDate = DateTime.Now.ToString(); db2.IsFederationRoot = true.ToString(); db2.IsSystemObject = true.ToString(); db2.MaxSizeBytes = "10737418240"; databases.Add(db2); SqlDatabaseList operationResult = new SqlDatabaseList(databases); return operationResult; }; SubscriptionData subscriptionData = UnitTestHelper.CreateUnitTestSubscription(); subscriptionData.ServiceEndpoint = MockHttpServer.DefaultHttpsServerPrefixUri.AbsoluteUri; NewAzureSqlDatabaseServerContext contextCmdlet = new NewAzureSqlDatabaseServerContext(); ServerDataServiceCertAuth service = contextCmdlet.GetServerDataServiceByCertAuth("TestServer", subscriptionData); service.Channel = channel; Database[] results = service.GetDatabases(); // Expecting master, testdb1, testdb2 Assert.AreEqual(2, results.Length, "Expecting two Database objects"); Database database1Obj = results[0]; Assert.AreEqual("testdb1", database1Obj.Name, "Expected db name to be testdb1"); Database database2Obj = results[1]; Assert.AreEqual("testdb2", database2Obj.Name, "Expected db name to be testdb2"); Assert.AreEqual( "Japanese_CI_AS", database2Obj.CollationName, "Expected collation to be Japanese_CI_AS"); Assert.AreEqual("Business", database2Obj.Edition, "Expected edition to be Business"); Assert.AreEqual(10, database2Obj.MaxSizeGB, "Expected max size to be 10 GB"); }
public void SetAzureSqlDatabaseNameWithCertAuth() { SimpleSqlDatabaseManagement channel = new SimpleSqlDatabaseManagement(); // This is needed because UpdateDatabases calls GetDatabases in order to // get the necessary database information for the delete. channel.GetDatabaseThunk = ar => { Assert.AreEqual( ar.Values["databaseName"], "testdb1", "The input databaseName (for get) did not match the expected"); SqlDatabaseResponse db1 = new SqlDatabaseResponse(); db1.CollationName = "Japanese_CI_AS"; db1.Edition = "Web"; db1.Id = "1"; db1.MaxSizeGB = "1"; db1.Name = "testdb1"; db1.CreationDate = DateTime.Now.ToString(); db1.IsFederationRoot = true.ToString(); db1.IsSystemObject = true.ToString(); db1.MaxSizeBytes = "1073741824"; return db1; }; channel.UpdateDatabaseThunk = ar => { Assert.AreEqual( "testdb1", ar.Values["databaseName"], "The input databaseName (for update) did not match the expected"); Assert.AreEqual( "newTestDb1", ((SqlDatabaseInput)ar.Values["input"]).Name, "The database Name input parameter does not match"); Assert.AreEqual( "1", ((SqlDatabaseInput)ar.Values["input"]).MaxSizeGB, "The database MaxSizeGB input parameter does not match"); Assert.AreEqual( "Japanese_CI_AS", ((SqlDatabaseInput)ar.Values["input"]).CollationName, "The database CollationName input parameter does not match"); Assert.AreEqual( "Web", ((SqlDatabaseInput)ar.Values["input"]).Edition, "The database Edition input parameter does not match"); SqlDatabaseResponse response = new SqlDatabaseResponse(); response.CollationName = ((SqlDatabaseInput)ar.Values["input"]).CollationName; response.CreationDate = DateTime.Now.ToString(); response.MaxSizeBytes = "1073741824"; response.Edition = ((SqlDatabaseInput)ar.Values["input"]).Edition.ToString(); response.Id = ((SqlDatabaseInput)ar.Values["input"]).Id; response.IsFederationRoot = true.ToString(); response.IsSystemObject = true.ToString(); response.MaxSizeGB = ((SqlDatabaseInput)ar.Values["input"]).MaxSizeGB.ToString(); response.Name = ((SqlDatabaseInput)ar.Values["input"]).Name; return response; }; SubscriptionData subscriptionData = UnitTestHelper.CreateUnitTestSubscription(); subscriptionData.ServiceEndpoint = MockHttpServer.DefaultHttpsServerPrefixUri.AbsoluteUri; NewAzureSqlDatabaseServerContext contextCmdlet = new NewAzureSqlDatabaseServerContext(); ServerDataServiceCertAuth service = contextCmdlet.GetServerDataServiceByCertAuth("TestServer", subscriptionData); service.Channel = channel; Database database = service.UpdateDatabase("testdb1", "newTestDb1", null, null, null); Assert.AreEqual( database.CollationName, "Japanese_CI_AS", "The updated database collation name is wrong"); Assert.AreEqual( database.Edition, "Web", "The updated database Edition is wrong"); Assert.AreEqual( database.MaxSizeGB, 1, "The updated database Edition is wrong"); Assert.AreEqual( database.Name, "newTestDb1", "The updated database Edition is wrong"); }
public void GetAzureSqlDatabaseWithCertAuth() { SimpleSqlDatabaseManagement channel = new SimpleSqlDatabaseManagement(); channel.GetDatabaseThunk = ar => { Assert.AreEqual( ar.Values["databaseName"], "testdb1", "The input databaseName did not match the expected"); SqlDatabaseResponse db1 = new SqlDatabaseResponse(); db1.CollationName = "Japanese_CI_AS"; db1.Edition = "Web"; db1.Id = "1"; db1.MaxSizeGB = "1"; db1.Name = "testdb1"; db1.CreationDate = DateTime.Now.ToString(); db1.IsFederationRoot = true.ToString(); db1.IsSystemObject = true.ToString(); db1.MaxSizeBytes = "1073741824"; return db1; }; SubscriptionData subscriptionData = UnitTestHelper.CreateUnitTestSubscription(); subscriptionData.ServiceEndpoint = MockHttpServer.DefaultHttpsServerPrefixUri.AbsoluteUri; NewAzureSqlDatabaseServerContext contextCmdlet = new NewAzureSqlDatabaseServerContext(); ServerDataServiceCertAuth service = contextCmdlet.GetServerDataServiceByCertAuth("TestServer", subscriptionData); service.Channel = channel; Database database = service.GetDatabase("testdb1"); Assert.AreEqual("testdb1", database.Name, "Expected db name to be testdb1"); Assert.AreEqual( "Japanese_CI_AS", database.CollationName, "Expected collation to be Japanese_CI_AS"); Assert.AreEqual("Web", database.Edition, "Expected edition to be Web"); Assert.AreEqual(1, database.MaxSizeGB, "Expected max size to be 1 GB"); }
public void NewAzureSqlDatabaseWithCertAuth() { SimpleSqlDatabaseManagement channel = new SimpleSqlDatabaseManagement(); channel.NewDatabaseThunk = ar => { Assert.AreEqual( ((SqlDatabaseInput)ar.Values["input"]).Name, "UnitTestNewDatabase", "The database Name input parameter does not match"); Assert.AreEqual( ((SqlDatabaseInput)ar.Values["input"]).MaxSizeGB, "1", "The database MaxSizeGB input parameter does not match"); Assert.AreEqual( ((SqlDatabaseInput)ar.Values["input"]).CollationName, "Japanese_CI_AS", "The database CollationName input parameter does not match"); Assert.AreEqual( ((SqlDatabaseInput)ar.Values["input"]).Edition, "Web", "The database Edition input parameter does not match"); SqlDatabaseResponse operationResult = new SqlDatabaseResponse(); operationResult.CollationName = "Japanese_CI_AS"; operationResult.Edition = "Web"; operationResult.Id = "1"; operationResult.MaxSizeGB = "1"; operationResult.Name = "TestDatabaseName"; operationResult.CreationDate = DateTime.Now.ToString(); operationResult.IsFederationRoot = true.ToString(); operationResult.IsSystemObject = true.ToString(); operationResult.MaxSizeBytes = "1073741824"; return operationResult; }; SubscriptionData subscriptionData = UnitTestHelper.CreateUnitTestSubscription(); subscriptionData.ServiceEndpoint = MockHttpServer.DefaultHttpsServerPrefixUri.AbsoluteUri; NewAzureSqlDatabaseServerContext contextCmdlet = new NewAzureSqlDatabaseServerContext(); ServerDataServiceCertAuth service = contextCmdlet.GetServerDataServiceByCertAuth("TestServer", subscriptionData); service.Channel = channel; Database result = service.CreateNewDatabase("UnitTestNewDatabase", 1, "Japanese_CI_AS", DatabaseEdition.Web); // Verify that the result matches the stuff in the thunk. Assert.AreEqual(result.CollationName, "Japanese_CI_AS", "The collation does not match"); Assert.AreEqual(result.Edition, DatabaseEdition.Web.ToString(), "The edition does not match"); Assert.AreEqual(result.MaxSizeGB, 1, "The max db size does not match"); Assert.AreEqual(result.Name, "TestDatabaseName", "The name does not match"); }