Esempio n. 1
0
        public void IterationsTest()
        {
            OclOrderedSet source = TestUtils.CreateIntOrderedSet(1, 2, 3);

            TestUtils.AreEqual(TestUtils.CreateIntOrderedSet(2, 3), source.select <OclInteger>(x => x >= (OclInteger)2));
            TestUtils.AreEqual(TestUtils.CreateIntOrderedSet(1), source.reject <OclInteger>(x => x >= (OclInteger)2));
            TestUtils.AreEqual(TestUtils.CreateIntSequence(0, 1, 1), source.collectNested <OclInteger, OclInteger>(OclInteger.Type, x => x.div((OclInteger)2)));
            TestUtils.AreEqual(TestUtils.CreateIntOrderedSet(3, 2, 1), source.sortedBy <OclInteger, OclInteger>(x => - x));

            TestUtils.AreEqual((OclInteger)1, source.any <OclInteger>(x => x < (OclInteger)2));
            TestUtils.AreEqual(OclBoolean.True, source.one <OclInteger>(x => x < (OclInteger)2));
            TestUtils.AreEqual(OclBoolean.False, source.one <OclInteger>(x => x < (OclInteger)3));
            TestUtils.AreEqual(OclBoolean.True, source.exists <OclInteger>(x => x < (OclInteger)2));
            TestUtils.AreEqual(OclBoolean.False, source.exists <OclInteger>(x => x < (OclInteger)1));
            TestUtils.AreEqual(OclBoolean.False, source.forAll <OclInteger>(x => x < (OclInteger)2));
            TestUtils.AreEqual(OclBoolean.True, source.forAll <OclInteger>(x => x < (OclInteger)4));
            TestUtils.AreEqual(OclBoolean.True, source.isUnique <OclInteger, OclReal>(x => x / (OclInteger)2));
            TestUtils.AreEqual(OclBoolean.False, source.isUnique <OclInteger, OclReal>(x => x.div((OclInteger)2)));
        }