Exemple #1
0
        public void Post()
        {
            //Condition number smaller three will be checked AFTER method call addOne()
            var ocls = "context HowToUseIt::addOne() post NumberLowerThree: self.number < 3";

            OclTestProvider.AddConstraints(new[] { "HowTo" }, ocls, false, false);

            var program = new Program();

            Assert.IsTrue(program.countToTen());
        }
Exemple #2
0
        public void ValuesTypes()
        {
            //Checking the value of the integer variable number from class HowToUseIt
            var ocls = "context HowToUseIt::addOne() post NumberLowerThree: self.number < 3";

            OclTestProvider.AddConstraints(new[] { "HowTo" }, ocls, false, false);

            var program = new Program();

            Assert.IsTrue(program.countToTen());
        }
Exemple #3
0
        public void Debugger()
        {
            var ocls = "context HowToUseIt::addOne() post NumberLowerThree: self.number < 3";

            //For calling the debugger the third parameter from AddConstraints(...) has to be true
            //and UnitTest has to run in debug
            OclTestProvider.AddConstraints(new[] { "HowTo" }, ocls, true, false);

            var program = new Program();

            Assert.IsTrue(program.countToTen());
        }
Exemple #4
0
        public void Lists2()
        {
            //Checking each student is older than 10
            var ocls = "context ResearchProject::amountStudents() pre OlderThan10: self.Students->forAll(s | s.Age > 10)";

            OclTestProvider.AddConstraints(new[] { "HowTo" }, ocls, false, false);

            var program = new Program();

            program.addStudentsToProject();
            Assert.IsTrue(program.singleObjectTest());
        }
Exemple #5
0
        public void Lists()
        {
            //Checking if there is an object in a list of objects thats age is greater than 20
            var ocls = "context ResearchProject::amountStudents() pre OlderThan20: self.Students->exists(s | s.Age > 20)";

            OclTestProvider.AddConstraints(new[] { "HowTo" }, ocls, false, false);

            var program = new Program();

            program.addStudentsToProject();
            Assert.IsTrue(program.singleObjectTest());
        }
Exemple #6
0
        public void Objects()
        {
            //Checking if the value of an variable from an object is greater 40
            var ocls = "context ResearchProject::amountStudents() pre responsibleProf: self.Responsible.Age <= 40";

            OclTestProvider.AddConstraints(new[] { "HowTo" }, ocls, false, false);

            var program = new Program();

            program.addStudentsToProject();
            Assert.IsTrue(program.singleObjectTest());
        }
Exemple #7
0
        public void OwnErrorMessage()
        {
            var ocls = "context HowToUseIt::addOne() post NumberLowerThree: self.number < 3";

            //For a custom error message the fourth parameter from AddConstraints(...) has to be true
            //and in CodeGenerator.cs the custom code has to be added into this if-condition: if (" + _customMethod + @")
            OclTestProvider.AddConstraints(new[] { "HowTo" }, ocls, false, true);

            var program = new Program();

            Assert.IsTrue(program.countToTen());
        }
Exemple #8
0
        // [Fact]
        private static void RunAspectTests()
        {
            const string ocls = @"

context Machine::set_Capacity()
         pre CapacityBigger10: self.Capacity.Max(10) > 10

";

            OclTestProvider.AddConstraints(new[] { "Designer" }, ocls);

            Console.WriteLine("Execute Planning program...");
            var planner = new Planner();

            planner.Plan();
        }