public void TestDeleteUriStructureOk() { try { ConfigJsonHandler configJsonHandler = new ConfigJsonHandler(); SchemaConfigFileOperations schemaConfigFileOperations = new SchemaConfigFileOperations(configJsonHandler); CreateBackUpConfig(); UriStructureGeneral uriSchema = configJsonHandler.GetUrisConfig(); int oldResourcesClassesCount = uriSchema.ResourcesClasses.Count; int oldUriStructuresCount = uriSchema.UriStructures.Count; if (configJsonHandler.ExistUriStructure("uriPublicationStructure")) { configJsonHandler.DeleteUriStructureInfo("uriPublicationStructure"); schemaConfigFileOperations.SaveConfigJson(); ConfigJsonHandler configJsonHandler2 = new ConfigJsonHandler(); UriStructureGeneral uriSchema2 = configJsonHandler2.GetUrisConfig(); RestoreBackUpConfig(); Assert.True(oldResourcesClassesCount == uriSchema2.ResourcesClasses.Count + 1 && oldUriStructuresCount == uriSchema2.UriStructures.Count + 1); } else { Assert.True(false); } } catch (Exception) { RestoreBackUpConfig(); } }
public void TestDeleteUriStructureNoNameFoundError() { try { ConfigJsonHandler configJsonHandler = new ConfigJsonHandler(); SchemaConfigFileOperations schemaConfigFileOperations = new SchemaConfigFileOperations(configJsonHandler); CreateBackUpConfig(); Assert.Throws <UriStructureConfiguredException>(() => configJsonHandler.DeleteUriStructureInfo("badName")); schemaConfigFileOperations.SaveConfigJson(); configJsonHandler.GetUrisConfig(); RestoreBackUpConfig(); } catch (Exception) { RestoreBackUpConfig(); } }
public void TestDeleteUriStructureOk() { ConfigJsonHandler configJsonHandler = new ConfigJsonHandler(); UriStructureGeneral uriSchema = configJsonHandler.GetUrisConfig(); int oldResourcesClassesCount = uriSchema.ResourcesClasses.Count; int oldUriStructuresCount = uriSchema.UriStructures.Count; if (configJsonHandler.ExistUriStructure("uriResourceStructure")) { configJsonHandler.DeleteUriStructureInfo("uriResourceStructure"); ISchemaConfigOperations schemaConfigOperations = new SchemaConfigMemoryOperations(configJsonHandler); schemaConfigOperations.SaveConfigJson(); UriStructureGeneral uriSchema2 = configJsonHandler.GetUrisConfig(); Assert.True(oldResourcesClassesCount > uriSchema2.ResourcesClasses.Count && oldUriStructuresCount > uriSchema2.UriStructures.Count); } else { Assert.True(false); } }
public IActionResult DeleteUriStructure(string name) { if (_configJsonHandler.ExistUriStructure(name)) { _configJsonHandler.DeleteUriStructureInfo(name); bool deleted = _schemaConfigOperations.SaveConfigJson(); if (deleted) { return(Ok($"uriStructure: {name} has been deleted and the new config schema is loaded")); } else { return(Problem(detail: "Server error has ocurred", null, 500)); } } else { return(BadRequest($"{{\"error\": \"No data of uriStructure {name}\"}}")); } }
public void TestDeleteUriStructureNoNameFoundError() { ConfigJsonHandler configJsonHandler = new ConfigJsonHandler(); Assert.Throws <UriStructureConfiguredException>(() => configJsonHandler.DeleteUriStructureInfo("badName")); }