Skip to content

Commit

Permalink
restore point create and delete API missed test added (#4168)
Browse files Browse the repository at this point in the history
  • Loading branch information
sarvesh-s authored and shahabhijeet committed Mar 29, 2018
1 parent 151b4cb commit 1773064
Show file tree
Hide file tree
Showing 2 changed files with 1,754 additions and 0 deletions.
70 changes: 70 additions & 0 deletions src/SDKs/SqlManagement/Sql.Tests/DatabaseRestoreScenarioTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -339,5 +339,75 @@ public void TestDatabaseGeoRecovery()
});
}
}

[Fact]
public void TestDatabaseRestorePoint()
{
using (SqlManagementTestContext context = new SqlManagementTestContext(this))
{
ResourceGroup resourceGroup = context.CreateResourceGroup();
Server server = context.CreateServer(resourceGroup);
SqlManagementClient sqlClient = context.GetClient<SqlManagementClient>();
string restoreLabel = "restorePointLabel";

// Create database with only required parameters
var db = sqlClient.Databases.CreateOrUpdate(resourceGroup.Name, server.Name, SqlManagementTestUtilities.GenerateName(),
new Database
{
Location = server.Location,
Edition = DatabaseEdition.DataWarehouse,
RequestedServiceObjectiveName = ServiceObjectiveName.DW100
});
Assert.NotNull(db);

CreateDatabaseRestorePointDefinition restoreDefinition = new CreateDatabaseRestorePointDefinition { RestorePointLabel = restoreLabel };

RestorePoint postResponse = sqlClient.RestorePoints.Create(
resourceGroup.Name,
server.Name,
db.Name,
restoreDefinition);

Assert.True(postResponse.RestorePointType == RestorePointType.DISCRETE);
Assert.True(postResponse.RestorePointLabel == restoreLabel);
Assert.True(!string.IsNullOrWhiteSpace(postResponse.RestorePointCreationDate.ToString()));

IEnumerable<RestorePoint> listResponse =
sqlClient.RestorePoints.ListByDatabase(
resourceGroup.Name,
server.Name,
db.Name);

IEnumerable<RestorePoint> restorePointList = listResponse.ToList<RestorePoint>();

Assert.True(restorePointList.Any());

RestorePoint getResponse =
sqlClient.RestorePoints.Get(
resourceGroup.Name,
server.Name,
db.Name,
postResponse.Name);

Assert.True(getResponse.RestorePointType == RestorePointType.DISCRETE);
Assert.True(!string.IsNullOrWhiteSpace(getResponse.RestorePointCreationDate.ToString()));
Assert.True(getResponse.Name == postResponse.Name);

sqlClient.RestorePoints.Delete(
resourceGroup.Name,
server.Name,
db.Name,
getResponse.Name);

IEnumerable<RestorePoint> listResponseAfterDelete =
sqlClient.RestorePoints.ListByDatabase(
resourceGroup.Name,
server.Name,
db.Name);

Assert.True(!listResponseAfterDelete.Any()
|| !listResponseAfterDelete.Where(x => x.Name == postResponse.Name).Any());
}
}
}
}
Loading

0 comments on commit 1773064

Please sign in to comment.