public void Backup_SubDrawingsWithCompositeKeyIsDependent_BackupAllDependencies() { // Arrange var productionStorageProvider = new SqlServerStorageProvider(productionConnectionString); var backupStorageProvider = new SqlServerStorageProvider(backupConnectionString); var metadataProvider = new XmlMetadataProvider(drawingsXmlMetadataLocation); var metadataWorkspace = metadataProvider.GetMetadataWorkspace(); var entities = SetUpSourceEntities(); EnsureInDatabase(productionConnectionString, metadataWorkspace, entities); var entityName = "SubDrawings"; var keys = new List <string>() { "1", "2", "300", "400", "1" }; var api = new Api(metadataProvider, productionStorageProvider, backupStorageProvider); // Act api.Backup(entityName, keys); // Assert foreach (var entity in entities) { string message = string.Format("Entity '{0}' could not be backed up.", entity.Name); Assert.IsTrue(CheckEntityExistsInSqlServerDb(backupConnectionString, metadataWorkspace, entity), message); } }
public void Restore_DrawingsWithSimpleKeyToDatabaseWithRemovedAndModifiedEntities_RestoreAllDependencies() { // Arrange var productionStorageProvider = new SqlServerStorageProvider(productionConnectionString); var backupStorageProvider = new SqlServerStorageProvider(backupConnectionString); var metadataProvider = new XmlMetadataProvider(drawingsXmlMetadataLocation); var metadataWorkspace = metadataProvider.GetMetadataWorkspace(); var entities = SetUpSourceEntities(); EnsureInDatabase(backupConnectionString, metadataWorkspace, entities); var defectiveEntities = SetUpDefectiveEntities(); EnsureInDatabase(productionConnectionString, metadataWorkspace, defectiveEntities); var entityName = "Drawings"; var keys = new List <string>() { "1" }; var api = new Api(metadataProvider, productionStorageProvider, backupStorageProvider); // Act api.Restore(entityName, keys); // Assert foreach (var entity in entities) { string message = string.Format("Entity '{0}' could not be backed up.", entity.Name); Assert.IsTrue(CheckEntityExistsInSqlServerDb(productionConnectionString, metadataWorkspace, entity), message); } }
public void Backup_EntityDoesNotExist_ThrowsException() { // Arrange var productionStorageProvider = new SqlServerStorageProvider(productionConnectionString); var backupStorageProvider = new SqlServerStorageProvider(backupConnectionString); var metadataProvider = new XmlMetadataProvider(drawingsXmlMetadataLocation); var entityName = "NotExistingEntity"; var keys = new List <string>(); var api = new Api(metadataProvider, productionStorageProvider, backupStorageProvider); // Act api.Backup(entityName, keys); // Assert }
public void GetDrawingEntityWithSimpleKeyFromDatabase_EntityExists_AssertsTrue() { // Arrange var productionConnectionString = ConfigurationManager.ConnectionStrings["DrawingsProductionContext"].ConnectionString; var sqlServerStorageProvider = new SqlServerStorageProvider(productionConnectionString); var drawingsXmlMetadataLocation = TestSettings.Storage.XmlMetadataManualLocation + @"\Drawings.xml"; var metadataProvider = new XmlMetadataProvider(drawingsXmlMetadataLocation); var sqlServerRepository = sqlServerStorageProvider.GetRepository(metadataProvider); var keys = new EntityKey[1]; keys[0] = new EntityKey() { Name = "Id", Value = 30 }; // Act sqlServerRepository.Read("Drawings", keys); // Assert }
public void Backup_SubDrawingsMissingKey_ThrowsException() { // Arrange var productionStorageProvider = new SqlServerStorageProvider(productionConnectionString); var backupStorageProvider = new SqlServerStorageProvider(backupConnectionString); var metadataProvider = new XmlMetadataProvider(drawingsXmlMetadataLocation); var metadataWorkspace = metadataProvider.GetMetadataWorkspace(); var entities = SetUpSourceEntities(); EnsureInDatabase(productionConnectionString, metadataWorkspace, entities); var entityName = "SubDrawings"; var keys = new List <string>() { "1", "2" }; var api = new Api(metadataProvider, productionStorageProvider, backupStorageProvider); // Act api.Backup(entityName, keys); }