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

// If.cs: Represents OCL testing for If expressions

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

// 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 If expressions

       class IfTests

       {

      

              OCL

              [

                     "context IfTests::Name(age : Integer) : String"

                     "post: if age > 18 then result = 'Adult' else result = 'Child' endif"

              ]

              public string Name(int age)

              {

                     return (age > 18) ? "Adult" : "Child";

              }

             

             

              public void RunTests()

              {

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

                     Console.WriteLine("IF1 (Name(18)): {0}", Name(18));

                     Console.WriteLine("IF2 (Name(3)): {0}", Name(3));

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

              }

       }

}

 

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

// EOF