Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | Related Pages

csLibTestFbg.cs

Go to the documentation of this file.
00001 /*
00002  *  csharpFreiburg - src/CSharpFreiburg/src/CsLibTestFbg/csLibTestFbg.cs
00003  *  
00004  *  (C) 2004 - Freiburg - Project - Group
00005  *  ------------------------------------------------------
00006  *  EMail: freiburg AT compiler-factory DOT de
00007  *  ------------------------------------------------------
00008  *  all rights reserved
00009  */
00010 
00011 using System;
00012 using System.Text;
00013 using System.Reflection;
00014 
00015 [assembly:AssemblyVersionAttribute("2.0.0.0")]
00016 
00018 public class TestFbg : Freiburg.Msgque
00019 {
00020     public int timeout = 10;
00021     private const string appname = "TestFbg";
00022     private const string server = "testFbg20.srv";
00023 
00024     public TestFbg(params string[] argv) : base(null, appname, server, argv) {
00025     }
00026     public TestFbg(Freiburg.Msgque parent, params string[] argv) : base(parent, appname, server, argv) {
00027     }
00028     ~TestFbg() {
00029     }
00030 
00031     /*****************************************************************************/
00032     /*                                                                           */
00033     /*                          constatant variables                             */
00034     /*                                                                           */
00035     /*****************************************************************************/
00036 
00037     public Object Test (params object[] val) {
00038         return (object) CallService("TEST", timeout, new Object[1] {val})[0];
00039     }
00040 
00041     public Object EchoU (object val) {
00042         return (object) CallService("ECOU", timeout, val)[0];
00043     }
00044 
00045     public short Echo2 (object val) {
00046         return (short) CallService("ECO2", timeout, val)[0];
00047     }
00048 
00049     public int Echo4 (object val) {
00050         return (int) CallService("ECO4", timeout, val)[0];
00051     }
00052 
00053     public long Echo8 (object val) {
00054         return (long) CallService("ECO8", timeout, val)[0];
00055     }
00056 
00057     public float EchoF (object val) {
00058         return (float) CallService("ECOF", timeout, val)[0];
00059     }
00060 
00061     public double EchoD (object val) {
00062         return (double) CallService("ECOD", timeout, val)[0];
00063     }
00064 
00065     public int EchoP (object val) {
00066         return (int) CallService("ECOD", timeout, val)[0];
00067     }
00068 
00069     public string EchoS (object val) {
00070         return (string) CallService("ECOS", timeout, val)[0];
00071     }
00072 
00073     public Object[] EchoL (params object[] val) {
00074         return (Object[]) CallService("ECOL", timeout, new Object[1] {val})[0];
00075     }
00076 
00077     public Object[] Option (params object[] val) {
00078         return (Object[]) CallService("ECOL", timeout, val);
00079     }
00080 
00081     public Object[] Param () {
00082         return CallService("MSQT", timeout, null);
00083     }
00084 
00085     public string Err1 () {
00086         try {
00087             CallService("ERR1", timeout);
00088         }
00089         catch(ApplicationException e) {
00090             return e.Message;
00091         }
00092         return "OK";
00093     }
00094 
00095     public string Err2 () {
00096         try {
00097             CallService("ERR2", timeout);
00098         }
00099         catch(ApplicationException e) {
00100             return e.Message;
00101         }
00102         return "OK";
00103     }
00104 
00105     public string War2 () {
00106         return (string) CallService("WAR1", timeout)[0];
00107     }
00108 
00109     public string EchoSleep (int val) {
00110         return (string) CallService("SLEP", timeout, val)[0];
00111     }
00112 
00113     public string EchoUSleep (int val) {
00114         return (string) CallService("USLP", timeout, val)[0];
00115     }
00116 
00117     /*****************************************************************************/
00118     /*                                                                           */
00119     /*                             test procedures                               */
00120     /*                                                                           */
00121     /*****************************************************************************/
00122 
00123     private static string pObjArrayToString (object[] objA) {
00124         StringBuilder str = new StringBuilder();
00125         foreach (object obj in objA) {
00126             str.Append(',');
00127             str.Append(obj);
00128         }
00129         return str.ToString();
00130     }
00131 
00132     protected static void MakeTest (string name, object[] objA, params object[] resA)
00133     {   
00134         Console.Write("TEST: {0} -> ",name);
00135         int i=0;
00136         bool error = false;
00137         object obj;
00138         foreach (object res in resA) {
00139             obj = objA[i];
00140             if (obj.GetType() != res.GetType() || !Object.Equals(obj,res)) {
00141                 if (!error) {
00142                     if (objA.Length != resA.Length) {
00143                         Console.WriteLine("ERROR ({0} != {1})", objA.Length, resA.Length);
00144                     } else {
00145                         Console.WriteLine("ERROR");
00146                     }
00147                     error = true;
00148                 }
00149                 Console.WriteLine(" [{0,2}]  o: {1,-10} - {2,15}    !=    r: {3,-10} - {4,15}",
00150                     i, obj, obj.GetType(), res, res.GetType());
00151             }
00152             i++;
00153         }
00154         if (error) return;
00155         Console.WriteLine("OK");
00156     }
00157 
00158     protected static void MakeTest (string name, object obj, object res)
00159     {
00160         Console.Write("TEST: {0} -> ",name);
00161         if (obj.GetType() != res.GetType() || !Object.Equals(obj,res)) {
00162             Console.WriteLine("ERROR");
00163             Console.WriteLine("     o: {0,-10} - {1,15}    !=    r: {2,-10} - {3,15}",
00164                 obj, obj.GetType(), res, res.GetType());
00165             return;
00166         }
00167         Console.WriteLine("OK");
00168     }
00169 }
00170 

Generated on Tue Nov 23 16:15:58 2004 for csharpFreiburg by  doxygen 1.3.8-20040928