Esempio n. 1
0
        public KAOSModel Parse(string input, string filename)
        {
            KAOSModel model = new KAOSModel();
            Declarations = new Dictionary<KAOSMetaModelElement, IList<Declaration>> ();
            GoalModelParser _parser = new GoalModelParser ();

            Uri RelativePath = null;
            if (!string.IsNullOrEmpty (filename))
                RelativePath = new Uri(Path.GetFullPath (Path.GetDirectoryName(filename) + "/"));

            FirstStageBuilder FSB = new FirstStageBuilder (model, Declarations, RelativePath);
            FormulaBuilder FB = new FormulaBuilder (model, Declarations, FSB, RelativePath);
            SecondStageBuilder SSB = new SecondStageBuilder (model, Declarations, FSB, FB, RelativePath);
            ThirdStageBuilder TSB = new ThirdStageBuilder (model, Declarations, FSB, SSB, FB, RelativePath);

            var elements = _parser.Parse (input, filename) as ParsedElements;

            FSB.BuildElementWithKeys (elements);
            SSB.BuildElement (elements);
            TSB.BuildElement (elements);

            // Ensure that there is at least one alternative system
            if (model.AlternativeSystems().Count() == 0)
                model.Add (new AlternativeSystem (model) {
                    Name = "Default",
                    Definition = "Default alternative"
                });

            return model;
        }
        public void TestParsedDeclareGoal()
        {
            var model   = new KAOSModel();
            var path    = new Uri("/tmp/fake");
            var builder = new FirstStageBuilder(model, path);

            builder.BuildDeclare(new ParsedGoal("my-goal"));
            model.Goals(x => x.Identifier == "my-goal").ShallBeSingle();
        }
        public void TestFailWhenParsedDeclareUnknow()
        {
            var model   = new KAOSModel();
            var path    = new Uri("/tmp/fake");
            var builder = new FirstStageBuilder(model, path);

            Assert.Catch(() => {
                builder.BuildDeclare(new UnknownParsedDeclare("unknown"));
            });
        }
Esempio n. 4
0
 public FormulaBuilder(KAOSModel model, 
                        IDictionary<KAOSMetaModelElement, 
                        IList<Declaration>> declarations, 
                        FirstStageBuilder fsb,
                        Uri relativePath)
 {
     this.model = model;
     this.Declarations = declarations;
     this.FSB = fsb;
     this.relativePath = relativePath;
 }