Esempio n. 1
0
        public void testInvariant()
        {
            AstOclConstraintFactory   factory1 = AstOclConstraintFactoryManager.getInstance(umlModel.getOclPackage());
            AstOclModelElementFactory factory2 = AstOclModelElementFactoryManager.getInstance(umlModel.getOclPackage());

            BooleanLiteralExp      exp1       = factory2.createBooleanLiteralExp(true, getClassifier("Boolean"));
            ExpressionInOcl        expInOcl   = factory1.createExpressionInOcl("name", getClassifier("Film"), exp1);
            OclInvariantConstraint constraint = (OclInvariantConstraint)factory1.createInvariantConstraint("test.ocl", "myInvariant", getClassifier("Film"), expInOcl);

            Assert.AreEqual("inv myInvariant: True", constraint.ToString());

            Assert.IsTrue(getClassifier("Film").getAllInvariants().Contains(constraint));

            getClassifier("Film").deleteAllConstraintsForSource("test.ocl");
            Assert.IsFalse(getClassifier("Film").getAllInvariants().Contains(constraint));
        }