Ejemplo n.º 1
0
 public void TestAddUriStructureOk()
 {
     try
     {
         ConfigJsonHandler          configJsonHandler          = new ConfigJsonHandler();
         SchemaConfigFileOperations schemaConfigFileOperations = new SchemaConfigFileOperations(configJsonHandler);
         CreateBackUpConfig();
         UriStructureGeneral uriSchema         = configJsonHandler.GetUrisConfig();
         UriStructure        newUriStructure   = CreateUriStructureExample("newUriExample");
         ResourcesClass      newResourcesClass = CreateResourceClassExample("newUriExample", "rsp", "pipaon");
         int oldResourcesClassesCount          = uriSchema.ResourcesClasses.Count;
         int oldUriStructuresCount             = uriSchema.UriStructures.Count;
         configJsonHandler.AddUriStructureInfo(newUriStructure, newResourcesClass);
         schemaConfigFileOperations.SaveConfigJson();
         ConfigJsonHandler   configJsonHandler2 = new ConfigJsonHandler();
         UriStructureGeneral uriSchema2         = configJsonHandler2.GetUrisConfig();
         RestoreBackUpConfig();
         configJsonHandler2.LoadConfigJson();
         Assert.True(oldResourcesClassesCount + 1 == uriSchema2.ResourcesClasses.Count && oldUriStructuresCount + 1 == uriSchema2.UriStructures.Count);
     }
     catch (Exception)
     {
         RestoreBackUpConfig();
     }
 }
Ejemplo n.º 2
0
 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();
     }
 }
Ejemplo n.º 3
0
        public void TestGetSchemaFileData()
        {
            ISchemaConfigOperations schemaConfigOperations = new SchemaConfigFileOperations(null);
            var bytesSchema               = schemaConfigOperations.GetFileSchemaData();
            var bytesAsString             = Encoding.UTF8.GetString(bytesSchema);
            UriStructureGeneral uriSchema = JsonConvert.DeserializeObject <UriStructureGeneral>(bytesAsString);
            bool correctGenerated         = uriSchema != null && uriSchema.Base != null && uriSchema.Characters != null && uriSchema.ResourcesClasses != null && uriSchema.ResourcesClasses.Count > 0 && uriSchema.UriStructures != null && uriSchema.UriStructures.Count > 0;

            Assert.True(correctGenerated);
        }
Ejemplo n.º 4
0
 public void TestAddUriStructureFailMatchNames()
 {
     try
     {
         ConfigJsonHandler          configJsonHandler          = new ConfigJsonHandler();
         SchemaConfigFileOperations schemaConfigFileOperations = new SchemaConfigFileOperations(configJsonHandler);
         CreateBackUpConfig();
         UriStructure   newUriStructure   = CreateUriStructureExample("newUriExamp");
         ResourcesClass newResourcesClass = CreateResourceClassExample("newUriExample", "rsp", "pipaon");
         Assert.Throws <UriStructureBadInfoException>(() => configJsonHandler.AddUriStructureInfo(newUriStructure, newResourcesClass));
     }
     catch (Exception)
     {
         RestoreBackUpConfig();
     }
 }
Ejemplo n.º 5
0
 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();
     }
 }