Exemple #1
0
        public void CollectionTest()
        {
            TypesTable             typesTable = new TypesTable();
            StandardLibraryCreator sl         = new StandardLibraryCreator();

            sl.CreateStandardLibrary(typesTable);

            Classifier integerType = typesTable.Library.Integer;
            Classifier realType    = typesTable.Library.Real;
            Classifier anyType     = typesTable.Library.Any;

            CollectionType bagInteger  = typesTable.Library.CreateCollection(Exolutio.Model.OCL.CollectionKind.Bag, integerType);
            CollectionType bagReal     = typesTable.Library.CreateCollection(Exolutio.Model.OCL.CollectionKind.Bag, realType);
            CollectionType setType     = typesTable.Library.CreateCollection(Exolutio.Model.OCL.CollectionKind.Set, integerType);
            CollectionType seqType     = typesTable.Library.CreateCollection(Exolutio.Model.OCL.CollectionKind.Sequence, integerType);;
            CollectionType ordType     = typesTable.Library.CreateCollection(Exolutio.Model.OCL.CollectionKind.OrderedSet, integerType);
            CollectionType collInteger = typesTable.Library.CreateCollection(Exolutio.Model.OCL.CollectionKind.Collection, integerType);

            Assert.IsTrue(bagInteger.ConformsTo(bagReal));
            Assert.IsTrue(bagInteger.ConformsTo(collInteger));

            Assert.IsFalse(bagReal.ConformsTo(collInteger));
            Assert.IsFalse(bagInteger.ConformsTo(seqType));
            Assert.IsFalse(bagInteger.ConformsTo(setType));
            Assert.IsFalse(bagInteger.ConformsTo(ordType));

            Assert.IsFalse(seqType.ConformsTo(bagInteger));
            Assert.IsFalse(seqType.ConformsTo(setType));
            Assert.IsFalse(seqType.ConformsTo(ordType));

            Assert.IsFalse(ordType.ConformsTo(bagInteger));
            Assert.IsFalse(ordType.ConformsTo(setType));
            Assert.IsFalse(ordType.ConformsTo(seqType));

            Assert.IsFalse(setType.ConformsTo(bagInteger));
            Assert.IsFalse(setType.ConformsTo(ordType));
            Assert.IsFalse(setType.ConformsTo(seqType));

            Assert.IsTrue(bagInteger.CollectionKind == Exolutio.Model.OCL.CollectionKind.Bag);
            Assert.IsTrue(collInteger.CollectionKind == Exolutio.Model.OCL.CollectionKind.Collection);
            Assert.IsTrue(setType.CollectionKind == Exolutio.Model.OCL.CollectionKind.Set);
            Assert.IsTrue(seqType.CollectionKind == Exolutio.Model.OCL.CollectionKind.Sequence);
            Assert.IsTrue(ordType.CollectionKind == Exolutio.Model.OCL.CollectionKind.OrderedSet);



            Assert.AreEqual(bagInteger.Name, "Bag(" + integerType.QualifiedName + ")");
            Assert.AreEqual(collInteger.Name, "Collection(" + integerType.QualifiedName + ")");
            Assert.AreEqual(setType.Name, "Set(" + integerType.QualifiedName + ")");
            Assert.AreEqual(ordType.Name, "OrderedSet(" + integerType.QualifiedName + ")");
            Assert.AreEqual(seqType.Name, "Sequence(" + integerType.QualifiedName + ")");

            Assert.IsTrue(bagInteger == typesTable.Library.CreateCollection(Exolutio.Model.OCL.CollectionKind.Bag, integerType));
            Assert.IsFalse(bagInteger == null);
            Assert.IsFalse(bagInteger == bagReal);
            Assert.IsFalse(bagInteger.Equals(null));


            Assert.IsTrue(bagInteger.ConformsTo(anyType));
        }
Exemple #2
0
        public void ReflexivityConformsToTest()
        {
            TypesTable             typesTable = new TypesTable();
            StandardLibraryCreator sl         = new StandardLibraryCreator();

            sl.CreateStandardLibrary(typesTable);

            Classifier integerType = typesTable.Library.Integer;

            Assert.IsTrue(integerType.ConformsTo(integerType));

            Classifier realType = typesTable.Library.Real;

            Assert.IsTrue(realType.ConformsTo(realType));

            CollectionType collType  = typesTable.Library.CreateCollection(Exolutio.Model.OCL.CollectionKind.Bag, integerType);
            CollectionType collType2 = typesTable.Library.CreateCollection(Exolutio.Model.OCL.CollectionKind.Bag, integerType);

            typesTable.RegisterType(collType);
            typesTable.RegisterType(collType2);

            Assert.IsTrue(collType.ConformsTo(collType));
            Assert.IsTrue(collType.ConformsTo(collType2));

            List <Property> tupleParts1 = new List <Property>();

            tupleParts1.Add(new Property("ahoj", PropertyType.One, integerType));
            TupleType tuple = new TupleType(typesTable, tupleParts1);

            typesTable.RegisterType(tuple);

            List <Property> tupleParts2 = new List <Property>();

            tupleParts2.Add(new Property("ahoj", PropertyType.One, integerType));
            TupleType tuple2 = new TupleType(typesTable, tupleParts2);

            typesTable.RegisterType(tuple2);

            Assert.IsTrue(tuple.ConformsTo(tuple));
            Assert.IsTrue(tuple.ConformsTo(tuple2));

            CollectionType bagType  = typesTable.Library.CreateCollection(Exolutio.Model.OCL.CollectionKind.Bag, integerType);
            CollectionType bagType2 = typesTable.Library.CreateCollection(Exolutio.Model.OCL.CollectionKind.Bag, integerType);

            Assert.IsTrue(bagType.ConformsTo(bagType));
            Assert.IsTrue(bagType.ConformsTo(bagType2));


            CollectionType setType  = typesTable.Library.CreateCollection(Exolutio.Model.OCL.CollectionKind.Set, integerType);
            CollectionType setType2 = typesTable.Library.CreateCollection(Exolutio.Model.OCL.CollectionKind.Set, integerType);

            Assert.IsTrue(setType.ConformsTo(setType));
            Assert.IsTrue(setType.ConformsTo(setType2));

            Classifier voidType = typesTable.Library.Void;

            typesTable.RegisterType(voidType);
            Assert.IsTrue(voidType.ConformsTo(voidType));

            Classifier anyType = typesTable.Library.Any;

            typesTable.RegisterType(anyType);
            Assert.IsTrue(anyType.ConformsTo(anyType));

            Classifier invalidType = typesTable.Library.Invalid;

            typesTable.RegisterType(invalidType);
            Assert.IsTrue(invalidType.ConformsTo(invalidType));
            //pridat class
        }