コード例 #1
0
        public void TestAddUriStructureOkController()
        {
            ConfigJsonHandler       configJsonHandler      = new ConfigJsonHandler();
            ISchemaConfigOperations schemaConfigOperations = new SchemaConfigMemoryOperations(configJsonHandler);
            SchemaController        schemaController       = new SchemaController(configJsonHandler, schemaConfigOperations);
            UriStructure            newUriStructure        = CreateUriStructureExample("newUriExample");
            ResourcesClass          newResourcesClass      = CreateResourceClassExample("newUriExample", "rsp", "pipaon");
            List <ResourcesClass>   lista = new List <ResourcesClass>();

            lista.Add(newResourcesClass);
            InfoUriStructure structure = new InfoUriStructure();

            structure.ResourcesClass = lista;
            structure.UriStructure   = newUriStructure;
            var result = schemaController.AddUriStructure(structure);

            if (result is BadRequestObjectResult)
            {
                Assert.True(false);
            }
            else
            {
                Assert.True(true);
            }
        }
コード例 #2
0
        public void TestGetSchemaFileData()
        {
            ConfigJsonHandler       configJsonHandler      = new ConfigJsonHandler();
            ISchemaConfigOperations schemaConfigOperations = new SchemaConfigMemoryOperations(configJsonHandler);
            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);
        }
コード例 #3
0
 public void TestGetSchemaController()
 {
     try
     {
         ConfigJsonHandler       configJsonHandler      = new ConfigJsonHandler();
         ISchemaConfigOperations schemaConfigOperations = new SchemaConfigMemoryOperations(configJsonHandler);
         SchemaController        schemaController       = new SchemaController(configJsonHandler, schemaConfigOperations);
         var result = schemaController.GetSchema();
         Assert.True(true);
     }
     catch (Exception)
     {
         Assert.True(false);
     }
 }
コード例 #4
0
        public void TestGetUriController()
        {
            ConfigJsonHandler       configJsonHandler      = new ConfigJsonHandler();
            ISchemaConfigOperations schemaConfigOperations = new SchemaConfigMemoryOperations(configJsonHandler);
            SchemaController        schemaController       = new SchemaController(configJsonHandler, schemaConfigOperations);
            var result = schemaController.GetUriStructureInfo("uriResourceStructure");

            if (result is BadRequestObjectResult)
            {
                Assert.True(false);
            }
            else
            {
                Assert.True(true);
            }
        }
コード例 #5
0
        public void TestAddUriStructureOk()
        {
            ConfigJsonHandler   configJsonHandler = new ConfigJsonHandler();
            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);
            ISchemaConfigOperations schemaConfigOperations = new SchemaConfigMemoryOperations(configJsonHandler);

            schemaConfigOperations.SaveConfigJson();
            UriStructureGeneral uriSchema2 = configJsonHandler.GetUrisConfig();

            Assert.True(oldResourcesClassesCount + 1 == uriSchema2.ResourcesClasses.Count && oldUriStructuresCount + 1 == uriSchema2.UriStructures.Count);
        }
コード例 #6
0
        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);
            }
        }
コード例 #7
0
        public void TestBadFormedJson()
        {
            ConfigJsonHandler       configJsonHandler      = new ConfigJsonHandler();
            ISchemaConfigOperations schemaConfigOperations = new SchemaConfigMemoryOperations(configJsonHandler);
            SchemaController        schemaController       = new SchemaController(configJsonHandler, schemaConfigOperations);
            var stream = new MemoryStream();
            var writer = new StreamWriter(stream);

            writer.Write(jsonConfigBad);
            writer.Flush();
            stream.Position = 0;
            var file   = new FormFile(stream, 0, stream.Length, null, "config.json");
            var result = schemaController.ReplaceSchemaConfig(file);

            if (result is BadRequestObjectResult)
            {
                Assert.True(true);
            }
            else
            {
                Assert.True(false);
            }
        }