示例#1
0
        public void MultipleLevelsOfResources()
        {
            EAMetaModel meta = new EAMetaModel();

            meta.setupAPIPackage();
            EAFactory api = APIModel.createMOM(meta);

            YamlMappingNode map = new YamlMappingNode();

            //Test
            RAMLManager.reifyAPI(EARepository.Repository, api.clientElement, map);

            YamlScalarNode mom = new YamlScalarNode();
            YamlNode       momValue;

            mom.Value = "/mom";
            Assert.IsTrue(map.Children.TryGetValue(mom, out momValue));


            YamlMappingNode resourceProps = (YamlMappingNode)momValue;
            YamlScalarNode  ev            = new YamlScalarNode();
            YamlNode        eventValue;

            ev.Value = "/event";
            Assert.IsTrue(resourceProps.Children.TryGetValue(ev, out eventValue));
        }
示例#2
0
        public void TestHomeQuote()
        {
            EAMetaModel meta = new EAMetaModel().setupAPIPackage();
            EAFactory   api  = APIModels.APIModel.createHomeQuote(meta);

            YamlMappingNode map = new YamlMappingNode();

            //Test
            RAMLManager.reifyAPI(EARepository.Repository, api.clientElement, map);

            YamlDocument d = new YamlDocument(map);

            YamlStream stream = new YamlStream();

            stream.Documents.Add(d);

            StringWriter writer = new StringWriter();

            stream.Save(writer, false);

            string yaml = writer.ToString();

            FileManager fileManager = new FileManager(null);

            fileManager.setBasePath(".");
            fileManager.initializeAPI(EARepository.currentPackage.Name);
            fileManager.setup(APIAddinClass.RAML_0_8);
            fileManager.exportAPI(EARepository.currentPackage.Name, APIAddinClass.RAML_0_8, yaml, "");
        }
示例#3
0
        public void TestRAML1()
        {
            EAMetaModel meta = new EAMetaModel();

            meta.setupAPIPackage();
            EAFactory api = APIModel.createAPI1(meta);

            YamlMappingNode map = new YamlMappingNode();

            RAMLManager.REIFY_VERSION = APIAddinClass.RAML_1_0;

            //Test
            RAMLManager.reifyAPI(EARepository.Repository, api.clientElement, map);

            YamlDocument d = new YamlDocument(map);

            YamlStream stream = new YamlStream();

            stream.Documents.Add(d);

            StringWriter writer = new StringWriter();

            stream.Save(writer, false);

            string yaml = writer.ToString();

            Assert.IsTrue(yaml.Contains("is: [notcacheable]"));

            Assert.IsTrue(yaml.Contains("dev-environment"));
            Assert.IsTrue(yaml.Contains("prod-environment"));

            Assert.IsTrue(yaml.Contains("someuriparameter"));

            Assert.IsTrue(yaml.Contains("data_item_description"));

            FileManager fileManager = new FileManager(null);

            fileManager.setBasePath(".");
            fileManager.initializeAPI(EARepository.currentPackage.Name);
            fileManager.setup(APIAddinClass.RAML_0_8);
            fileManager.exportAPI(EARepository.currentPackage.Name, APIAddinClass.RAML_0_8, yaml.ToString(), "");
        }