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

// Sequence.cs: Represents OCL testing for the Sequence 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 Sequence expressions

       class SequenceTests

       {

             

              OCL

              [

                     "context SequenceTests::_s1 : Sequence(Integer)"

                     "init: Sequence {1, 2, 3}.union(Sequence { 1, 2 })"

              ]

              private Sequence _s1;

             

             

              OCL

              [

                     "context SequenceTests::_s2 : Boolean"

                     "init: Sequence { 1, 2} = Sequence {1, 2 }"

              ]

              private bool _s2;

             

              OCL

              [

                     "context SequenceTests::_s3 : Boolean"

                     "init: Sequence { 1, 2} = Sequence {1, 2, 1}"

              ]

              private bool _s3;

             

              OCL

              [

                     "context SequenceTests::_s2a : Boolean"

                     "init: Sequence { 1, 2}.=(Sequence {1, 2 })"

              ]

              private bool _s2a;

             

              OCL

              [

                     "context SequenceTests::_s3a : Boolean"

                     "init: Sequence { 1, 2}.=(Sequence {1, 2, 1})"

              ]

              private bool _s3a;

             

              OCL

              [

                     "context SequenceTests::_s4 : Boolean"

                     "init: Sequence { 1, 2} <> Sequence {1, 2 }"

              ]

              private bool _s4;

             

              OCL

              [

                     "context SequenceTests::_s5 : Boolean"

                     "init: Sequence { 1, 2} <> Sequence {1, 2, 1}"

              ]

              private bool _s5;

             

              OCL

              [

                     "context SequenceTests::_s4a : Boolean"

                     "init: Sequence { 1, 2}.<>(Sequence {1, 2 })"

              ]

              private bool _s4a;

             

              OCL

              [

                     "context SequenceTests::_s5a : Boolean"

                     "init: Sequence { 1, 2}.<>(Sequence {1, 2, 4})"

              ]

              private bool _s5a;

             

              OCL

              [

                     "context SequenceTests::_s6 : Sequence(Integer)"

                     "init: Sequence {1, 2, 3}.including(1)"

              ]

              private Sequence _s6;

             

              OCL

              [

                     "context SequenceTests::_s7 : Sequence(Integer)"

                     "init: Sequence {1, 2, 1, 1, 2, 3}.excluding(1)"

              ]

              private Sequence _s7;

             

              OCL

              [

                     "context SequenceTests::_s8 : Integer"

                     "init: Sequence { 1, 2, 1, 1, 2, 4}.count(1)"

              ]

              private int _s8;

             

              OCL

              [

                     "context SequenceTests::_s9 : Integer"

                     "init: Sequence { 1, 1, 2, 4}.count(5)"

              ]

              private int _s9;

             

              OCL

              [

                     "context SequenceTests::_s10 : Sequence(Integer)"

                     "init: Sequence { Bag { 1, 2, 4}, Bag {1, 2, 4, 3, 8, 11} }.flatten()"

              ]

              private Sequence _s10;

             

              OCL

              [

                     "context SequenceTests::_s11 : Set(Integer)"

                     "init: Sequence { 1, 2,  1, 2, 3, 4 }.asSet()"

              ]

              private Set _s11;

             

              OCL

              [

                     "context SequenceTests::_s12 : OrderedSet(Integer)"

                     "init: Sequence { 1, 2, 1, 2, 3, 4 }.asOrderedSet()"

              ]

              private OrderedSet _s12;

             

              OCL

              [

                     "context SequenceTests::_s13 : Sequence(Integer)"

                     "init: Sequence { 1, 2, 1, 2, 3, 4 }.asSequence()"

              ]

              private Sequence _s13;

             

              OCL

              [

                     "context SequenceTests::_s14 : Bag(Integer)"

                     "init: Sequence { 1, 2, 1, 2, 3, 4 }.asBag()"

              ]

              private Bag _s14;

             

              OCL

              [

                     "context SequenceTests::_s15 : Sequence(Integer)"

                     "init: Sequence {1, 2, 3}.append(4)"

              ]

              private Sequence _s15;

             

              OCL

              [

                     "context SequenceTests::_s16 : Sequence(Integer)"

                     "init: Sequence {1, 2, 3}.prepend(0)"

              ]

              private Sequence _s16;

             

              OCL

              [

                     "context SequenceTests::_s17 : Sequence(Integer)"

                     "init: Sequence {1, 2, 3}.insertAt(1, 0)"

              ]

              private Sequence _s17;

             

              OCL

              [

                     "context SequenceTests::_s18 : Sequence(Integer)"

                     "init: Sequence {1, 2, 3}.subSequence(1, 2)"

              ]

              private Sequence _s18;

             

              OCL

              [

                     "context SequenceTests::_s19 : Integer"

                     "init: Sequence {1, 2, 3}.at(2)"

              ]

              private int _s19;

             

              OCL

              [

                     "context SequenceTests::_s20 : Integer"

                     "init: Sequence {1, 2, 3}.indexOf(2)"

              ]

              private int _s20;

             

              OCL

              [

                     "context SequenceTests::_s21 : Integer"

                     "init: Sequence {1, 2, 3}.first()"

              ]

              private int _s21;

             

              OCL

              [

                     "context SequenceTests::_s22 : Integer"

                     "init: Sequence {1, 2, 3}.last()"

              ]

              private int _s22;

             

             

 

              public void RunTests()

              {

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

                     Console.WriteLine("S1 (Sequence {{ 1, 2, 3}}.union(Sequence {{ 1, 2 }})): {0}", _s1);

                     Console.WriteLine("S2 (Sequence {{1, 2 }} = Sequence {{1, 2}}): {0}", _s2);

                     Console.WriteLine("S3 (Sequence {{1, 2 }} = Sequence {{2, 1}}): {0}", _s3);

                     Console.WriteLine("S2a (Sequence {{1, 2 }}.=(Sequence {{1, 2}})): {0}", _s2a);

                     Console.WriteLine("S3a (Sequence {{1, 2 }}.=(Sequence {{2, 1}})): {0}", _s3a);

                     Console.WriteLine("S4 (Sequence {{1, 2 }} <> Sequence {{1, 2}}): {0}", _s4);

                     Console.WriteLine("S5 (Sequence {{1, 2 }} <> Sequence {{2, 1}}): {0}", _s5);

                     Console.WriteLine("S4a (Sequence {{1, 2 }}.<>(Sequence {{1, 2}})): {0}", _s4a);

                     Console.WriteLine("S5a (Sequence {{1, 2 }}.<>(Sequence {{2, 1}})): {0}", _s5a);

                     Console.WriteLine("S6 (Sequence {{1, 2, 3}}.including(1)): {0}", _s6);

                     Console.WriteLine("S7 (Sequence {{1, 2, 1, 1, 2, 3}}.excluding(1)): {0}", _s7);

                     Console.WriteLine("S8 (Sequence {{1, 2, 1, 1, 2, 4}}.count(1)): {0}", _s8);

                     Console.WriteLine("S9 (Sequence {{1, 1, 2, 4}}.count(5)): {0}", _s9);

                     Console.WriteLine("S10 (Sequence {{ Bag {{ 1, 2, 4 }}, Bag {{ 1, 2, 4, 3, 8, 11 }} }}.flatten()): {0}", _s10);

                     Console.WriteLine("S11 (Sequence {{ 1, 2, 1, 2, 3, 4}}.asSet()): {0}", _s11);

                     Console.WriteLine("S12 (Sequence {{ 1, 2, 1, 2, 3, 4}}.asOrderedSet()): {0}", _s12);

                     Console.WriteLine("S13 (Sequence {{ 1, 2, 1, 2, 3, 4}}.asSequence()): {0}", _s13);

                     Console.WriteLine("S14 (Sequence {{ 1, 2, 1, 2, 3, 4}}.asBag()): {0}", _s14);

                     Console.WriteLine("S15 (Sequence {{ 1, 2, 3}}.append(4)): {0}", _s15);

                     Console.WriteLine("S16 (Sequence {{ 1, 2, 3}}.prepend(0)): {0}", _s16);

                     Console.WriteLine("S17 (Sequence {{ 1, 2, 3}}.insertAt(1, 0)): {0}", _s17);

                     Console.WriteLine("S18 (Sequence {{ 1, 2, 3}}.subSequence(1, 2)): {0}", _s18);

                     Console.WriteLine("S19 (Sequence {{ 1, 2, 3}}.at(2)): {0}", _s19);

                     Console.WriteLine("S20 (Sequence {{ 1, 2, 3}}.indexOf(2)): {0}", _s20);

                     Console.WriteLine("S21 (Sequence {{1, 2, 3}}.first()): {0}", _s21);

                     Console.WriteLine("S22 (Sequence {{1, 2, 3}}.last()): {0}", _s22);                Console.WriteLine("------------ SEQUENCE TESTS COMPLETE ------------");

              }

       }

}

 

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

// EOF