// ------------------------------------------------------------------

// Tuple.cs: Represents OCL testing for the Tuple STL type

// ------------------------------------------------------------------

// Project: C# and OCL Compiler

// Module:  Testing

// Author:  Dave Arnold

// Version: 1.0

// ------------------------------------------------------------------

 

// ------------------------------------------------------------------

// Imports

// ------------------------------------------------------------------

using System;

using System.Collections;

// ------------------------------------------------------------------

 

// ------------------------------------------------------------------

// DaveArnold.OCLTesting Namespace

// ------------------------------------------------------------------

namespace DaveArnold.OCLTesting

{

       // A Class to test the Tuple expressions

       class TupleTests

       {

             

              OCL

              [

                     "context TupleTests::_t1 : TupleType(name: String, age: Integer)"

                     "init: Tuple{name = 'Dave', age = 24}"

              ]

              private Tuple _t1;

             

              OCL

              [

                     "context TupleTests::_t2 : TupleType(valid: Boolean, data: Set(Bag(Integer)))"

                     "init: Tuple{valid = true, data = Set { Bag {1..4 }, Bag {5, 8 }, Bag { 10..15 } } }"

              ]

              private Tuple _t2;

             

              OCL

              [

                     "context TupleTests::_t3 : Boolean"

                     "init: Tuple { name = 'Dave', age = 24} = Tuple { name = 'Dave', age = 24}"

              ]

              private bool _t3;

             

              OCL

              [

                     "context TupleTests::_t4 : Boolean"

                     "init: Tuple { name = 'Dave', age = 24} = Tuple { name = 'Dave', age = 25}"

              ]

              private bool _t4;

             

              OCL

              [

                     "context TupleTests::_t3a : Boolean"

                     "init: Tuple { name = 'Dave', age = 24}.=(Tuple { name = 'Dave', age = 24})"

              ]

              private bool _t3a;

             

              OCL

              [

                     "context TupleTests::_t4a : Boolean"

                     "init: Tuple { name = 'Dave', age = 24}.=(Tuple { name = 'Dave', age = 25})"

              ]

              private bool _t4a;

             

              OCL

              [

                     "context TupleTests::_t5 : Boolean"

                     "init: Tuple { name = 'Dave', age = 24} <> Tuple { name = 'Dave', age = 24}"

              ]

              private bool _t5;

             

              OCL

              [

                     "context TupleTests::_t6 : Boolean"

                     "init: Tuple { name = 'Dave', age = 24} <> Tuple { name = 'Dave', age = 25}"

              ]

              private bool _t6;

             

              OCL

              [

                     "context TupleTests::_t5a : Boolean"

                     "init: Tuple { name = 'Dave', age = 24}.<>(Tuple { name = 'Dave', age = 24})"

              ]

              private bool _t5a;

             

              OCL

              [

                     "context TupleTests::_t6a : Boolean"

                     "init: Tuple { name = 'Dave', age = 24}.<>(Tuple { name = 'Dave', age = 25})"

              ]

              private bool _t6a;

             

              OCL

              [

                     "context TupleTests::_t7 : Integer"

                     "init: Tuple { name = 'Dave', age = 24}.age"

              ]

              private int _t7;

             

              OCL

              [

                     "context TupleTests::_t8 : String"

                     "init: Tuple { name = 'Dave', age = 24}.name"

              ]

              private string _t8;

             

      

              public void RunTests()

              {

                     Console.WriteLine("---------------- TUPLE TESTS -----------------");

                    

                     Console.WriteLine("T1 (Tuple(name: String, age: Integer): {0}", _t1);

                     Console.WriteLine("T2 (Tuple(valid: Boolean, data: Set(Bag(Integer))): {0}", _t2);

                     Console.WriteLine("T3 (Tuple {{name = 'Dave', age = 24 }} = Tuple {{name = 'Dave', age = 24}}): {0}", _t3);

                     Console.WriteLine("T4 (Tuple {{name = 'Dave', age = 24 }} = Tuple {{name = 'Dave', age = 25}}): {0}", _t4);

                     Console.WriteLine("T3A (Tuple {{name = 'Dave', age = 24 }}.=(Tuple {{name = 'Dave', age = 24}})): {0}", _t3a);

                     Console.WriteLine("T4A (Tuple {{name = 'Dave', age = 24 }}.=(Tuple {{name = 'Dave', age = 25}})): {0}", _t4a);

                     Console.WriteLine("T5 (Tuple {{name = 'Dave', age = 24 }} <> Tuple {{name = 'Dave', age = 24}}): {0}", _t5);

                     Console.WriteLine("T6 (Tuple {{name = 'Dave', age = 24 }} <> Tuple {{name = 'Dave', age = 25}}): {0}", _t6);

                     Console.WriteLine("T5A (Tuple {{name = 'Dave', age = 24 }}.<>(Tuple {{name = 'Dave', age = 24}})): {0}", _t5a);

                     Console.WriteLine("T6A (Tuple {{name = 'Dave', age = 24 }}.<>(Tuple {{name = 'Dave', age = 25}})): {0}", _t6a);

                    

                     Console.WriteLine("T7 (Tuple {{name= 'Dave', age = 24 }}.age): {0}", _t7);

                     Console.WriteLine("T8 (Tuple {{name= 'Dave', age = 24 }}.name): {0}", _t8);

                     Console.WriteLine("------------ TUPLE TESTS COMPLETE ------------");

              }

       }

}

 

// ------------------------------------------------------------------

// EOF