xref: /AOO41X/main/testtools/source/bridgetest/cli/cli_cs_bridgetest.cs (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir using System;
29*cdf0e10cSrcweir using System.Diagnostics;
30*cdf0e10cSrcweir using System.Reflection;
31*cdf0e10cSrcweir using uno;
32*cdf0e10cSrcweir using uno.util;
33*cdf0e10cSrcweir using unoidl.com.sun.star.uno;
34*cdf0e10cSrcweir using unoidl.com.sun.star.lang;
35*cdf0e10cSrcweir //using unoidl.com.sun.star.test.bridge;
36*cdf0e10cSrcweir using unoidl.test.testtools.bridgetest;
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir namespace foo
39*cdf0e10cSrcweir {
40*cdf0e10cSrcweir     public interface MyInterface
41*cdf0e10cSrcweir     {
42*cdf0e10cSrcweir     }
43*cdf0e10cSrcweir }
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir namespace cs_testobj
46*cdf0e10cSrcweir {
47*cdf0e10cSrcweir     class ORecursiveCall: WeakBase, XRecursiveCall
48*cdf0e10cSrcweir     {
49*cdf0e10cSrcweir         public void  callRecursivly(XRecursiveCall xCall, int nToCall)
50*cdf0e10cSrcweir 		{
51*cdf0e10cSrcweir 			lock (this)
52*cdf0e10cSrcweir             {
53*cdf0e10cSrcweir                 if (nToCall > 0)
54*cdf0e10cSrcweir                 {
55*cdf0e10cSrcweir                     nToCall --;
56*cdf0e10cSrcweir                     xCall.callRecursivly(this, nToCall);
57*cdf0e10cSrcweir                 }
58*cdf0e10cSrcweir             }
59*cdf0e10cSrcweir         }
60*cdf0e10cSrcweir     };
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir class Constants
63*cdf0e10cSrcweir {
64*cdf0e10cSrcweir    public const string STRING_TEST_CONSTANT = "\" paco\' chorizo\\\' \"\'";
65*cdf0e10cSrcweir }
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir public class BridgeTest : WeakBase, XMain
68*cdf0e10cSrcweir {
69*cdf0e10cSrcweir 	static bool compareData(Object val1, Object val2)
70*cdf0e10cSrcweir 	{
71*cdf0e10cSrcweir 		if (val1 == null && val2 == null || val1 == val2)
72*cdf0e10cSrcweir 			return true;
73*cdf0e10cSrcweir 		if ((val1 == null && val2 != null) ||
74*cdf0e10cSrcweir 			(val1 != null && val2 == null) || val1.GetType() != val2.GetType())
75*cdf0e10cSrcweir 			return false;
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir 		bool ret = false;
78*cdf0e10cSrcweir 		Type t1  = val1.GetType();
79*cdf0e10cSrcweir 			//Sequence
80*cdf0e10cSrcweir 		if (t1.IsArray)
81*cdf0e10cSrcweir 		{
82*cdf0e10cSrcweir 			ret = compareSequence((Array) val1, (Array) val2);
83*cdf0e10cSrcweir 		}
84*cdf0e10cSrcweir 			//String
85*cdf0e10cSrcweir 		else if (t1 == typeof(string))
86*cdf0e10cSrcweir 		{
87*cdf0e10cSrcweir 			ret = (string) val1 == (string) val2;
88*cdf0e10cSrcweir 		}
89*cdf0e10cSrcweir 			// Interface implementation
90*cdf0e10cSrcweir 		else if (t1.GetInterfaces().Length > 0 && ! t1.IsValueType)
91*cdf0e10cSrcweir 		{
92*cdf0e10cSrcweir 			ret = val1 == val2;
93*cdf0e10cSrcweir 		}
94*cdf0e10cSrcweir 			// Struct
95*cdf0e10cSrcweir 		else if ( ! t1.IsValueType)
96*cdf0e10cSrcweir 		{
97*cdf0e10cSrcweir 			ret = compareStruct(val1, val2);
98*cdf0e10cSrcweir 		}
99*cdf0e10cSrcweir 		else if (t1 == typeof(Any))
100*cdf0e10cSrcweir 		{
101*cdf0e10cSrcweir 			Any a1 = (Any) val1;
102*cdf0e10cSrcweir 			Any a2 = (Any) val2;
103*cdf0e10cSrcweir 			ret = a1.Type == a2.Type && compareData(a1.Value, a2.Value);
104*cdf0e10cSrcweir 		}
105*cdf0e10cSrcweir 		else if (t1.IsValueType)
106*cdf0e10cSrcweir 		{
107*cdf0e10cSrcweir 			//Any, enum, int, bool char, float, double etc.
108*cdf0e10cSrcweir 			ret = val1.Equals(val2);
109*cdf0e10cSrcweir 		}
110*cdf0e10cSrcweir 		else
111*cdf0e10cSrcweir 		{
112*cdf0e10cSrcweir 			Debug.Assert(false);
113*cdf0e10cSrcweir 		}
114*cdf0e10cSrcweir 		return ret;
115*cdf0e10cSrcweir 	}
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir 	// Arrays have only one dimension
118*cdf0e10cSrcweir 	static bool compareSequence(Array ar1, Array ar2)
119*cdf0e10cSrcweir 	{
120*cdf0e10cSrcweir 		Debug.Assert(ar1 != null && ar2 != null);
121*cdf0e10cSrcweir 		Type t1 = ar1.GetType();
122*cdf0e10cSrcweir 		Type t2 = ar2.GetType();
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir 		if (!(ar1.Rank == 1 && ar2.Rank == 1
125*cdf0e10cSrcweir 			&& ar1.Length == ar2.Length && t1.GetElementType() == t2.GetElementType()))
126*cdf0e10cSrcweir 			return false;
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir 		//arrays have same rank and size and element type.
129*cdf0e10cSrcweir 		int len  = ar1.Length;
130*cdf0e10cSrcweir 		Type elemType = t1.GetElementType();
131*cdf0e10cSrcweir 		bool ret = true;
132*cdf0e10cSrcweir 		for (int i = 0; i < len; i++)
133*cdf0e10cSrcweir 		{
134*cdf0e10cSrcweir 			if (compareData(ar1.GetValue(i), ar2.GetValue(i)) == false)
135*cdf0e10cSrcweir 			{
136*cdf0e10cSrcweir 				ret = false;
137*cdf0e10cSrcweir 				break;
138*cdf0e10cSrcweir 			}
139*cdf0e10cSrcweir 		}
140*cdf0e10cSrcweir 		return ret;
141*cdf0e10cSrcweir 	}
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir 	static bool compareStruct(Object val1, Object val2)
144*cdf0e10cSrcweir 	{
145*cdf0e10cSrcweir 		Debug.Assert(val1 != null && val2 != null);
146*cdf0e10cSrcweir 		Type t1 = val1.GetType();
147*cdf0e10cSrcweir 		Type t2 = val2.GetType();
148*cdf0e10cSrcweir 		if (t1 != t2)
149*cdf0e10cSrcweir 			return false;
150*cdf0e10cSrcweir 		FieldInfo[] fields = t1.GetFields();
151*cdf0e10cSrcweir 		int cFields = fields.Length;
152*cdf0e10cSrcweir 		bool ret = true;
153*cdf0e10cSrcweir 		for (int i = 0; i < cFields; i++)
154*cdf0e10cSrcweir 		{
155*cdf0e10cSrcweir 			Object fieldVal1 = fields[i].GetValue(val1);
156*cdf0e10cSrcweir 			Object fieldVal2 = fields[i].GetValue(val2);
157*cdf0e10cSrcweir 			if ( ! compareData(fieldVal1, fieldVal2))
158*cdf0e10cSrcweir 			{
159*cdf0e10cSrcweir 				ret = false;
160*cdf0e10cSrcweir 				break;
161*cdf0e10cSrcweir 			}
162*cdf0e10cSrcweir 		}
163*cdf0e10cSrcweir 		return ret;
164*cdf0e10cSrcweir 	}
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir     static bool check( bool b , string message )
167*cdf0e10cSrcweir     {
168*cdf0e10cSrcweir         if ( ! b)
169*cdf0e10cSrcweir         Console.WriteLine("{0} failed\n" , message);
170*cdf0e10cSrcweir         return b;
171*cdf0e10cSrcweir     }
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir     static bool equals(TestElement rData1, TestElement  rData2)
174*cdf0e10cSrcweir     {
175*cdf0e10cSrcweir         check( rData1.Bool == rData2.Bool, "### bool does not match!" );
176*cdf0e10cSrcweir         check( rData1.Char == rData2.Char, "### char does not match!" );
177*cdf0e10cSrcweir         check( rData1.Byte == rData2.Byte, "### byte does not match!" );
178*cdf0e10cSrcweir         check( rData1.Short == rData2.Short, "### short does not match!" );
179*cdf0e10cSrcweir         check( rData1.UShort == rData2.UShort, "### unsigned short does not match!" );
180*cdf0e10cSrcweir         check( rData1.Long == rData2.Long, "### long does not match!" );
181*cdf0e10cSrcweir         check( rData1.ULong == rData2.ULong, "### unsigned long does not match!" );
182*cdf0e10cSrcweir         check( rData1.Hyper == rData2.Hyper, "### hyper does not match!" );
183*cdf0e10cSrcweir         check( rData1.UHyper == rData2.UHyper, "### unsigned hyper does not match!" );
184*cdf0e10cSrcweir         check( rData1.Float == rData2.Float, "### float does not match!" );
185*cdf0e10cSrcweir         check( rData1.Double == rData2.Double, "### double does not match!" );
186*cdf0e10cSrcweir         check( rData1.Enum == rData2.Enum, "### enum does not match!" );
187*cdf0e10cSrcweir         check( rData1.String == rData2.String, "### string does not match!" );
188*cdf0e10cSrcweir         check( rData1.Interface == rData2.Interface, "### interface does not match!" );
189*cdf0e10cSrcweir         check( compareData(rData1.Any, rData2.Any), "### any does not match!" );
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir         return (rData1.Bool == rData2.Bool &&
192*cdf0e10cSrcweir                 rData1.Char == rData2.Char &&
193*cdf0e10cSrcweir                 rData1.Byte == rData2.Byte &&
194*cdf0e10cSrcweir                 rData1.Short == rData2.Short &&
195*cdf0e10cSrcweir                 rData1.UShort == rData2.UShort &&
196*cdf0e10cSrcweir                 rData1.Long == rData2.Long &&
197*cdf0e10cSrcweir                 rData1.ULong == rData2.ULong &&
198*cdf0e10cSrcweir                 rData1.Hyper == rData2.Hyper &&
199*cdf0e10cSrcweir                 rData1.UHyper == rData2.UHyper &&
200*cdf0e10cSrcweir                 rData1.Float == rData2.Float &&
201*cdf0e10cSrcweir                 rData1.Double == rData2.Double &&
202*cdf0e10cSrcweir                 rData1.Enum == rData2.Enum &&
203*cdf0e10cSrcweir                 rData1.String == rData2.String &&
204*cdf0e10cSrcweir                 rData1.Interface == rData2.Interface &&
205*cdf0e10cSrcweir                 compareData(rData1.Any, rData2.Any));
206*cdf0e10cSrcweir     }
207*cdf0e10cSrcweir 
208*cdf0e10cSrcweir static void assign( TestElement rData,
209*cdf0e10cSrcweir 					bool bBool, char cChar, byte nByte,
210*cdf0e10cSrcweir 					short nShort, ushort nUShort,
211*cdf0e10cSrcweir 					int nLong, uint nULong,
212*cdf0e10cSrcweir 					long nHyper, ulong nUHyper,
213*cdf0e10cSrcweir 					float fFloat, double fDouble,
214*cdf0e10cSrcweir 					TestEnum eEnum, string rStr,
215*cdf0e10cSrcweir 					Object xTest,
216*cdf0e10cSrcweir 					Any rAny )
217*cdf0e10cSrcweir {
218*cdf0e10cSrcweir 	rData.Bool = bBool;
219*cdf0e10cSrcweir 	rData.Char = cChar;
220*cdf0e10cSrcweir 	rData.Byte = nByte;
221*cdf0e10cSrcweir 	rData.Short = nShort;
222*cdf0e10cSrcweir 	rData.UShort = nUShort;
223*cdf0e10cSrcweir 	rData.Long = nLong;
224*cdf0e10cSrcweir 	rData.ULong = nULong;
225*cdf0e10cSrcweir 	rData.Hyper = nHyper;
226*cdf0e10cSrcweir 	rData.UHyper = nUHyper;
227*cdf0e10cSrcweir 	rData.Float = fFloat;
228*cdf0e10cSrcweir 	rData.Double = fDouble;
229*cdf0e10cSrcweir 	rData.Enum = eEnum;
230*cdf0e10cSrcweir 	rData.String = rStr;
231*cdf0e10cSrcweir 	rData.Interface = xTest;
232*cdf0e10cSrcweir 	rData.Any = rAny;
233*cdf0e10cSrcweir }
234*cdf0e10cSrcweir 
235*cdf0e10cSrcweir static void assign( TestDataElements rData,
236*cdf0e10cSrcweir 					bool bBool, char cChar, byte nByte,
237*cdf0e10cSrcweir 					short nShort, ushort nUShort,
238*cdf0e10cSrcweir 					int nLong, uint nULong,
239*cdf0e10cSrcweir 					long nHyper, ulong nUHyper,
240*cdf0e10cSrcweir 					float fFloat, double fDouble,
241*cdf0e10cSrcweir 					TestEnum eEnum, string rStr,
242*cdf0e10cSrcweir 					Object xTest,
243*cdf0e10cSrcweir 					Any rAny,
244*cdf0e10cSrcweir 					TestElement[] rSequence)
245*cdf0e10cSrcweir {
246*cdf0e10cSrcweir 	assign( (TestElement) rData,
247*cdf0e10cSrcweir 			bBool, cChar, nByte, nShort, nUShort, nLong, nULong, nHyper, nUHyper, fFloat, fDouble,
248*cdf0e10cSrcweir 			eEnum, rStr, xTest, rAny );
249*cdf0e10cSrcweir 	rData.Sequence = rSequence;
250*cdf0e10cSrcweir }
251*cdf0e10cSrcweir 
252*cdf0e10cSrcweir // template < class type >
253*cdf0e10cSrcweir static bool testAny(Type typ, Object  value, XBridgeTest xLBT )
254*cdf0e10cSrcweir {
255*cdf0e10cSrcweir 	Any any;
256*cdf0e10cSrcweir 	if (typ == null)
257*cdf0e10cSrcweir 		any = new Any(value.GetType(), value);
258*cdf0e10cSrcweir 	else
259*cdf0e10cSrcweir 		any = new Any(typ, value);
260*cdf0e10cSrcweir 
261*cdf0e10cSrcweir 	Any any2 = xLBT.transportAny(any);
262*cdf0e10cSrcweir 	bool ret;
263*cdf0e10cSrcweir 	if( ! (ret= compareData(any, any2)))
264*cdf0e10cSrcweir     {
265*cdf0e10cSrcweir         Console.WriteLine("any is different after roundtrip: in {0}, out {1}\n",
266*cdf0e10cSrcweir                           any.Type.FullName, any2.Type.FullName);
267*cdf0e10cSrcweir     }
268*cdf0e10cSrcweir 	return ret;
269*cdf0e10cSrcweir }
270*cdf0e10cSrcweir 
271*cdf0e10cSrcweir 
272*cdf0e10cSrcweir 
273*cdf0e10cSrcweir static bool performAnyTest(XBridgeTest xLBT,  TestDataElements data)
274*cdf0e10cSrcweir {
275*cdf0e10cSrcweir 	bool bReturn = true;
276*cdf0e10cSrcweir 	bReturn = testAny( null, data.Byte ,xLBT ) && bReturn;
277*cdf0e10cSrcweir 	bReturn = testAny( null, data.Short,xLBT ) && bReturn;
278*cdf0e10cSrcweir 	bReturn = testAny(  null, data.UShort,xLBT ) && bReturn;
279*cdf0e10cSrcweir 	bReturn = testAny(  null, data.Long,xLBT ) && bReturn;
280*cdf0e10cSrcweir 	bReturn = testAny(  null, data.ULong,xLBT ) && bReturn;
281*cdf0e10cSrcweir 	bReturn = testAny(  null, data.Hyper,xLBT ) && bReturn;
282*cdf0e10cSrcweir 	bReturn = testAny(  null,data.UHyper,xLBT ) && bReturn;
283*cdf0e10cSrcweir 	bReturn = testAny( null, data.Float,xLBT ) && bReturn;
284*cdf0e10cSrcweir 	bReturn = testAny( null, data.Double,xLBT ) && bReturn;
285*cdf0e10cSrcweir 	bReturn = testAny( null, data.Enum,xLBT ) && bReturn;
286*cdf0e10cSrcweir 	bReturn = testAny( null, data.String,xLBT ) && bReturn;
287*cdf0e10cSrcweir 	bReturn = testAny(typeof(XWeak), data.Interface,xLBT ) && bReturn;
288*cdf0e10cSrcweir 	bReturn = testAny(null, data, xLBT ) && bReturn;
289*cdf0e10cSrcweir 
290*cdf0e10cSrcweir 	{
291*cdf0e10cSrcweir         Any a1= new Any(true);
292*cdf0e10cSrcweir 		Any a2 = xLBT.transportAny( a1 );
293*cdf0e10cSrcweir 		bReturn = compareData(a2, a1) && bReturn;
294*cdf0e10cSrcweir 	}
295*cdf0e10cSrcweir 
296*cdf0e10cSrcweir 	{
297*cdf0e10cSrcweir         Any a1= new Any('A');
298*cdf0e10cSrcweir 		Any a2 = xLBT.transportAny(a1);
299*cdf0e10cSrcweir 		bReturn = compareData(a2, a1) && bReturn;
300*cdf0e10cSrcweir 	}
301*cdf0e10cSrcweir 	return bReturn;
302*cdf0e10cSrcweir }
303*cdf0e10cSrcweir 
304*cdf0e10cSrcweir static bool performSequenceOfCallTest(XBridgeTest xLBT)
305*cdf0e10cSrcweir {
306*cdf0e10cSrcweir 	int i,nRounds;
307*cdf0e10cSrcweir 	int nGlobalIndex = 0;
308*cdf0e10cSrcweir 	const int nWaitTimeSpanMUSec = 10000;
309*cdf0e10cSrcweir 	for( nRounds = 0 ; nRounds < 10 ; nRounds ++ )
310*cdf0e10cSrcweir 	{
311*cdf0e10cSrcweir 		for( i = 0 ; i < nRounds ; i ++ )
312*cdf0e10cSrcweir 		{
313*cdf0e10cSrcweir 			// fire oneways
314*cdf0e10cSrcweir 			xLBT.callOneway(nGlobalIndex, nWaitTimeSpanMUSec);
315*cdf0e10cSrcweir 			nGlobalIndex++;
316*cdf0e10cSrcweir 		}
317*cdf0e10cSrcweir 
318*cdf0e10cSrcweir 		// call synchron
319*cdf0e10cSrcweir 		xLBT.call(nGlobalIndex, nWaitTimeSpanMUSec);
320*cdf0e10cSrcweir 		nGlobalIndex++;
321*cdf0e10cSrcweir 	}
322*cdf0e10cSrcweir  	return xLBT.sequenceOfCallTestPassed();
323*cdf0e10cSrcweir }
324*cdf0e10cSrcweir 
325*cdf0e10cSrcweir 
326*cdf0e10cSrcweir 
327*cdf0e10cSrcweir 
328*cdf0e10cSrcweir static bool performRecursiveCallTest(XBridgeTest  xLBT)
329*cdf0e10cSrcweir {
330*cdf0e10cSrcweir 	xLBT.startRecursiveCall(new ORecursiveCall(), 50);
331*cdf0e10cSrcweir 	// on failure, the test would lock up or crash
332*cdf0e10cSrcweir 	return true;
333*cdf0e10cSrcweir }
334*cdf0e10cSrcweir 
335*cdf0e10cSrcweir static bool performQueryForUnknownType(XBridgeTest xLBT)
336*cdf0e10cSrcweir {
337*cdf0e10cSrcweir     bool bRet = false;
338*cdf0e10cSrcweir     // test queryInterface for an unknown type
339*cdf0e10cSrcweir     try
340*cdf0e10cSrcweir     {
341*cdf0e10cSrcweir         foo.MyInterface a = (foo.MyInterface) xLBT;
342*cdf0e10cSrcweir     }
343*cdf0e10cSrcweir     catch( System.InvalidCastException)
344*cdf0e10cSrcweir     {
345*cdf0e10cSrcweir         bRet = true;
346*cdf0e10cSrcweir     }
347*cdf0e10cSrcweir 
348*cdf0e10cSrcweir     return bRet;
349*cdf0e10cSrcweir }
350*cdf0e10cSrcweir 
351*cdf0e10cSrcweir // //==================================================================================================
352*cdf0e10cSrcweir bool performTest(XBridgeTest xLBT)
353*cdf0e10cSrcweir {
354*cdf0e10cSrcweir 	check( xLBT != null, "### no test interface!" );
355*cdf0e10cSrcweir     bool bRet = true;
356*cdf0e10cSrcweir 	if (xLBT == null)
357*cdf0e10cSrcweir         return false;
358*cdf0e10cSrcweir 
359*cdf0e10cSrcweir     // this data is never ever granted access to by calls other than equals(), assign()!
360*cdf0e10cSrcweir     TestDataElements aData = new TestDataElements(); // test against this data
361*cdf0e10cSrcweir 
362*cdf0e10cSrcweir     Object xI= new WeakBase();
363*cdf0e10cSrcweir 
364*cdf0e10cSrcweir     Any aAny = new Any( typeof(Object), xI);
365*cdf0e10cSrcweir     assign( (TestElement)aData,
366*cdf0e10cSrcweir             true, '@', 17, 0x1234, 0xfedc, 0x12345678, 0xfedcba98,
367*cdf0e10cSrcweir             0x123456789abcdef0, 0xfedcba9876543210,
368*cdf0e10cSrcweir             17.0815f, 3.1415926359, TestEnum.LOLA,
369*cdf0e10cSrcweir             Constants.STRING_TEST_CONSTANT, xI,
370*cdf0e10cSrcweir             aAny);
371*cdf0e10cSrcweir 
372*cdf0e10cSrcweir     bRet = check( aData.Any.Value == xI, "### unexpected any!" ) && bRet;
373*cdf0e10cSrcweir     bRet = check( !(aData.Any.Value != xI), "### unexpected any!" ) && bRet;
374*cdf0e10cSrcweir 
375*cdf0e10cSrcweir     aData.Sequence = new TestElement[2];
376*cdf0e10cSrcweir     aData.Sequence[0] = new TestElement(
377*cdf0e10cSrcweir         aData.Bool, aData.Char, aData.Byte, aData.Short,
378*cdf0e10cSrcweir         aData.UShort, aData.Long, aData.ULong,
379*cdf0e10cSrcweir         aData.Hyper, aData.UHyper, aData.Float,
380*cdf0e10cSrcweir         aData.Double, aData.Enum, aData.String,
381*cdf0e10cSrcweir         aData.Interface, aData.Any); //(TestElement) aData;
382*cdf0e10cSrcweir     aData.Sequence[1] = new TestElement(); //is empty
383*cdf0e10cSrcweir 
384*cdf0e10cSrcweir     // aData complete
385*cdf0e10cSrcweir     //
386*cdf0e10cSrcweir     // this is a manually copy of aData for first setting...
387*cdf0e10cSrcweir     TestDataElements aSetData = new TestDataElements();
388*cdf0e10cSrcweir     Any aAnySet= new Any(typeof(Object), xI);
389*cdf0e10cSrcweir     assign( (TestElement)aSetData,
390*cdf0e10cSrcweir             aData.Bool, aData.Char, aData.Byte, aData.Short, aData.UShort,
391*cdf0e10cSrcweir             aData.Long, aData.ULong, aData.Hyper, aData.UHyper, aData.Float, aData.Double,
392*cdf0e10cSrcweir             aData.Enum, aData.String, xI,
393*cdf0e10cSrcweir             aAnySet);
394*cdf0e10cSrcweir 
395*cdf0e10cSrcweir     aSetData.Sequence = new TestElement[2];
396*cdf0e10cSrcweir     aSetData.Sequence[0] = new TestElement(
397*cdf0e10cSrcweir         aSetData.Bool, aSetData.Char, aSetData.Byte, aSetData.Short,
398*cdf0e10cSrcweir         aSetData.UShort, aSetData.Long, aSetData.ULong,
399*cdf0e10cSrcweir         aSetData.Hyper, aSetData.UHyper, aSetData.Float,
400*cdf0e10cSrcweir         aSetData.Double, aSetData.Enum, aSetData.String,
401*cdf0e10cSrcweir         aSetData.Interface, aSetData.Any); //TestElement) aSetData;
402*cdf0e10cSrcweir     aSetData.Sequence[1] = new TestElement(); // empty struct
403*cdf0e10cSrcweir 
404*cdf0e10cSrcweir     xLBT.setValues(
405*cdf0e10cSrcweir         aSetData.Bool, aSetData.Char, aSetData.Byte, aSetData.Short, aSetData.UShort,
406*cdf0e10cSrcweir         aSetData.Long, aSetData.ULong, aSetData.Hyper, aSetData.UHyper, aSetData.Float, aSetData.Double,
407*cdf0e10cSrcweir         aSetData.Enum, aSetData.String, aSetData.Interface, aSetData.Any, aSetData.Sequence, aSetData );
408*cdf0e10cSrcweir 
409*cdf0e10cSrcweir     {
410*cdf0e10cSrcweir 		TestDataElements aRet = new TestDataElements();
411*cdf0e10cSrcweir         TestDataElements aRet2 = new TestDataElements();
412*cdf0e10cSrcweir 		xLBT.getValues(
413*cdf0e10cSrcweir 			out aRet.Bool, out aRet.Char, out aRet.Byte, out aRet.Short, out aRet.UShort,
414*cdf0e10cSrcweir 			out aRet.Long, out aRet.ULong, out aRet.Hyper, out aRet.UHyper,
415*cdf0e10cSrcweir             out aRet.Float, out aRet.Double, out aRet.Enum, out aRet.String,
416*cdf0e10cSrcweir             out aRet.Interface, out aRet.Any, out aRet.Sequence, out aRet2 );
417*cdf0e10cSrcweir 
418*cdf0e10cSrcweir 		bRet = check( compareData( aData, aRet ) && compareData( aData, aRet2 ) , "getValues test") && bRet;
419*cdf0e10cSrcweir 
420*cdf0e10cSrcweir 		// set last retrieved values
421*cdf0e10cSrcweir 		TestDataElements aSV2ret = xLBT.setValues2(
422*cdf0e10cSrcweir 			ref aRet.Bool, ref aRet.Char, ref aRet.Byte, ref aRet.Short, ref aRet.UShort,
423*cdf0e10cSrcweir 			ref aRet.Long, ref aRet.ULong, ref aRet.Hyper, ref aRet.UHyper, ref aRet.Float,
424*cdf0e10cSrcweir             ref aRet.Double, ref aRet.Enum, ref aRet.String, ref aRet.Interface, ref aRet.Any,
425*cdf0e10cSrcweir             ref aRet.Sequence, ref aRet2 );
426*cdf0e10cSrcweir 
427*cdf0e10cSrcweir         // check inout sequence order
428*cdf0e10cSrcweir         // => inout sequence parameter was switched by test objects
429*cdf0e10cSrcweir 		TestElement temp = aRet.Sequence[ 0 ];
430*cdf0e10cSrcweir         aRet.Sequence[ 0 ] = aRet.Sequence[ 1 ];
431*cdf0e10cSrcweir         aRet.Sequence[ 1 ] = temp;
432*cdf0e10cSrcweir 
433*cdf0e10cSrcweir 		bRet = check(
434*cdf0e10cSrcweir             compareData( aData, aSV2ret ) && compareData( aData, aRet2 ),
435*cdf0e10cSrcweir             "getValues2 test") && bRet;
436*cdf0e10cSrcweir     }
437*cdf0e10cSrcweir     {
438*cdf0e10cSrcweir 		TestDataElements aRet = new TestDataElements();
439*cdf0e10cSrcweir         TestDataElements aRet2 = new TestDataElements();
440*cdf0e10cSrcweir 		TestDataElements aGVret = xLBT.getValues(
441*cdf0e10cSrcweir 			out aRet.Bool, out aRet.Char, out aRet.Byte, out aRet.Short,
442*cdf0e10cSrcweir             out aRet.UShort, out aRet.Long, out aRet.ULong, out aRet.Hyper,
443*cdf0e10cSrcweir             out aRet.UHyper, out aRet.Float, out aRet.Double, out aRet.Enum,
444*cdf0e10cSrcweir             out aRet.String, out aRet.Interface, out aRet.Any, out aRet.Sequence,
445*cdf0e10cSrcweir             out aRet2 );
446*cdf0e10cSrcweir 
447*cdf0e10cSrcweir 		bRet = check( compareData( aData, aRet ) && compareData( aData, aRet2 ) && compareData( aData, aGVret ), "getValues test" ) && bRet;
448*cdf0e10cSrcweir 
449*cdf0e10cSrcweir 		// set last retrieved values
450*cdf0e10cSrcweir 		xLBT.Bool = aRet.Bool;
451*cdf0e10cSrcweir 		xLBT.Char = aRet.Char;
452*cdf0e10cSrcweir 		xLBT.Byte = aRet.Byte;
453*cdf0e10cSrcweir 		xLBT.Short = aRet.Short;
454*cdf0e10cSrcweir 		xLBT.UShort = aRet.UShort;
455*cdf0e10cSrcweir         xLBT.Long = aRet.Long;
456*cdf0e10cSrcweir 		xLBT.ULong = aRet.ULong;
457*cdf0e10cSrcweir 		xLBT.Hyper = aRet.Hyper;
458*cdf0e10cSrcweir 		xLBT.UHyper = aRet.UHyper;
459*cdf0e10cSrcweir 		xLBT.Float = aRet.Float;
460*cdf0e10cSrcweir 		xLBT.Double = aRet.Double;
461*cdf0e10cSrcweir 		xLBT.Enum = aRet.Enum;
462*cdf0e10cSrcweir 		xLBT.String = aRet.String;
463*cdf0e10cSrcweir 		xLBT.Interface = aRet.Interface;
464*cdf0e10cSrcweir 		xLBT.Any = aRet.Any;
465*cdf0e10cSrcweir 		xLBT.Sequence = aRet.Sequence;
466*cdf0e10cSrcweir 		xLBT.Struct = aRet2;
467*cdf0e10cSrcweir     }
468*cdf0e10cSrcweir     {
469*cdf0e10cSrcweir 		TestDataElements aRet = new TestDataElements();
470*cdf0e10cSrcweir         TestDataElements aRet2 = new TestDataElements();
471*cdf0e10cSrcweir 		aRet.Hyper = xLBT.Hyper;
472*cdf0e10cSrcweir 		aRet.UHyper = xLBT.UHyper;
473*cdf0e10cSrcweir 		aRet.Float = xLBT.Float;
474*cdf0e10cSrcweir 		aRet.Double = xLBT.Double;
475*cdf0e10cSrcweir 		aRet.Byte = xLBT.Byte;
476*cdf0e10cSrcweir 		aRet.Char = xLBT.Char;
477*cdf0e10cSrcweir 		aRet.Bool = xLBT.Bool;
478*cdf0e10cSrcweir 		aRet.Short = xLBT.Short;
479*cdf0e10cSrcweir 		aRet.UShort = xLBT.UShort;
480*cdf0e10cSrcweir 		aRet.Long = xLBT.Long;
481*cdf0e10cSrcweir 		aRet.ULong = xLBT.ULong;
482*cdf0e10cSrcweir 		aRet.Enum = xLBT.Enum;
483*cdf0e10cSrcweir 		aRet.String = xLBT.String;
484*cdf0e10cSrcweir 		aRet.Interface = xLBT.Interface;
485*cdf0e10cSrcweir 		aRet.Any = xLBT.Any;
486*cdf0e10cSrcweir 		aRet.Sequence = xLBT.Sequence;
487*cdf0e10cSrcweir 		aRet2 = xLBT.Struct;
488*cdf0e10cSrcweir 
489*cdf0e10cSrcweir 		bRet = check( compareData( aData, aRet ) && compareData( aData, aRet2 ) , "struct comparison test") && bRet;
490*cdf0e10cSrcweir 
491*cdf0e10cSrcweir 		bRet = check(performSequenceTest(xLBT), "sequence test") && bRet;
492*cdf0e10cSrcweir 
493*cdf0e10cSrcweir 		// any test
494*cdf0e10cSrcweir 		bRet = check( performAnyTest( xLBT , aData ) , "any test" ) && bRet;
495*cdf0e10cSrcweir 
496*cdf0e10cSrcweir 		// sequence of call test
497*cdf0e10cSrcweir 		bRet = check( performSequenceOfCallTest( xLBT ) , "sequence of call test" ) && bRet;
498*cdf0e10cSrcweir 
499*cdf0e10cSrcweir 		// recursive call test
500*cdf0e10cSrcweir 		bRet = check( performRecursiveCallTest( xLBT ) , "recursive test" ) && bRet;
501*cdf0e10cSrcweir 
502*cdf0e10cSrcweir 		bRet = (compareData( aData, aRet ) && compareData( aData, aRet2 )) && bRet ;
503*cdf0e10cSrcweir 
504*cdf0e10cSrcweir         // check setting of null reference
505*cdf0e10cSrcweir         xLBT.Interface = null;
506*cdf0e10cSrcweir         aRet.Interface = xLBT.Interface;
507*cdf0e10cSrcweir         bRet = (aRet.Interface == null) && bRet;
508*cdf0e10cSrcweir 
509*cdf0e10cSrcweir     }
510*cdf0e10cSrcweir         // Test extended attributes that raise exceptions:
511*cdf0e10cSrcweir     try {
512*cdf0e10cSrcweir         int i = xLBT.RaiseAttr1;
513*cdf0e10cSrcweir             bRet &= check(false, "getRaiseAttr1 did not throw");
514*cdf0e10cSrcweir     } catch (RuntimeException )
515*cdf0e10cSrcweir     {
516*cdf0e10cSrcweir     }
517*cdf0e10cSrcweir     catch (System.Exception) {
518*cdf0e10cSrcweir         bRet &= check(false, "getRaiseAttr1 threw wrong type");
519*cdf0e10cSrcweir     }
520*cdf0e10cSrcweir     try {
521*cdf0e10cSrcweir         xLBT.RaiseAttr1 = 0;
522*cdf0e10cSrcweir         bRet &= check(false, "setRaiseAttr1 did not throw");
523*cdf0e10cSrcweir     } catch (IllegalArgumentException) {
524*cdf0e10cSrcweir     } catch (System.Exception) {
525*cdf0e10cSrcweir         bRet &= check(false, "setRaiseAttr1 threw wrong type");
526*cdf0e10cSrcweir     }
527*cdf0e10cSrcweir     try {
528*cdf0e10cSrcweir         int i = xLBT.RaiseAttr2;
529*cdf0e10cSrcweir         bRet &= check(false, "getRaiseAttr2 did not throw");
530*cdf0e10cSrcweir     } catch (IllegalArgumentException ) {
531*cdf0e10cSrcweir     } catch (System.Exception) {
532*cdf0e10cSrcweir         bRet &= check(false, "getRaiseAttr2 threw wrong type");
533*cdf0e10cSrcweir     }
534*cdf0e10cSrcweir 
535*cdf0e10cSrcweir        // Test instantiated polymorphic struct types:
536*cdf0e10cSrcweir     {
537*cdf0e10cSrcweir         TestPolyStruct poly = new TestPolyStruct(true);
538*cdf0e10cSrcweir         bRet &= check(
539*cdf0e10cSrcweir             (bool) xLBT.transportPolyBoolean(poly).member,
540*cdf0e10cSrcweir             "transportPolyBoolean");
541*cdf0e10cSrcweir         poly = new TestPolyStruct(12345L);
542*cdf0e10cSrcweir         xLBT.transportPolyHyper(ref poly);
543*cdf0e10cSrcweir         bRet &= check((long)poly.member == 12345L, "transportPolyUnsignedHyper");
544*cdf0e10cSrcweir 
545*cdf0e10cSrcweir         Any[] seq = {  new Any(33), new Any("ABC")};
546*cdf0e10cSrcweir         poly = new TestPolyStruct(seq);
547*cdf0e10cSrcweir         TestPolyStruct poly2;
548*cdf0e10cSrcweir         xLBT.transportPolySequence(poly, out poly2);
549*cdf0e10cSrcweir         try {
550*cdf0e10cSrcweir             Any[] ar = (Any[]) poly2.member;
551*cdf0e10cSrcweir             bRet &= check(
552*cdf0e10cSrcweir             ar.Length == 2, "transportPolySequence, length");
553*cdf0e10cSrcweir 
554*cdf0e10cSrcweir             int v0;
555*cdf0e10cSrcweir             v0 = (int) ar[0].Value;
556*cdf0e10cSrcweir             bRet &= check(v0 == 33, "transportPolySequence, element 0");
557*cdf0e10cSrcweir 
558*cdf0e10cSrcweir             string v1 = (string) ar[1].Value;
559*cdf0e10cSrcweir             bRet &= check(
560*cdf0e10cSrcweir             v1.Equals("ABC"),
561*cdf0e10cSrcweir             "transportPolySequence, element 1");
562*cdf0e10cSrcweir         } catch (InvalidCastException )
563*cdf0e10cSrcweir         {
564*cdf0e10cSrcweir             bRet &= check(false, "transportPolySequence");
565*cdf0e10cSrcweir         }
566*cdf0e10cSrcweir 
567*cdf0e10cSrcweir         try {
568*cdf0e10cSrcweir             //When the test object is a cli object then them member is null
569*cdf0e10cSrcweir             //otherwise the bridge has provided a default value.
570*cdf0e10cSrcweir             TestPolyStruct s =  xLBT.getNullPolyLong();
571*cdf0e10cSrcweir             if (s.member != null)
572*cdf0e10cSrcweir                 bRet &= check(((int) s.member) == 0, "getNullPolyLong");
573*cdf0e10cSrcweir 
574*cdf0e10cSrcweir             s = xLBT.getNullPolyString();
575*cdf0e10cSrcweir             if (s.member != null)
576*cdf0e10cSrcweir                 bRet &= check(((string) s.member).Length == 0,
577*cdf0e10cSrcweir                               "getNullPolyString");
578*cdf0e10cSrcweir             s = xLBT.getNullPolyType();
579*cdf0e10cSrcweir             if (s.member != null)
580*cdf0e10cSrcweir                 bRet &= check(((Type) s.member) == typeof(void),
581*cdf0e10cSrcweir                               "getNullPolyType");
582*cdf0e10cSrcweir             s = xLBT.getNullPolyAny();
583*cdf0e10cSrcweir             if (s.member != null)
584*cdf0e10cSrcweir             {
585*cdf0e10cSrcweir                 Any nullAny = (Any) s.member;
586*cdf0e10cSrcweir                 //???
587*cdf0e10cSrcweir                 bRet &= check(nullAny.Type == typeof(void),
588*cdf0e10cSrcweir                     "getNullPolyAny");
589*cdf0e10cSrcweir             }
590*cdf0e10cSrcweir             s = xLBT.getNullPolySequence();
591*cdf0e10cSrcweir             if (s.member != null)
592*cdf0e10cSrcweir                 bRet &= check(((bool[]) s.member).Length == 0,
593*cdf0e10cSrcweir                               "getNullPolySequence");
594*cdf0e10cSrcweir             s = xLBT.getNullPolyEnum();
595*cdf0e10cSrcweir             if (s.member != null)
596*cdf0e10cSrcweir                 bRet &= check(((TestEnum) s.member) == TestEnum.TEST,
597*cdf0e10cSrcweir                               "getNullPolyEnum");
598*cdf0e10cSrcweir             s = xLBT.getNullPolyStruct();
599*cdf0e10cSrcweir             if (s.member != null)
600*cdf0e10cSrcweir                 bRet &= check(((TestStruct) s.member).member == 0,
601*cdf0e10cSrcweir                               "getNullPolyStruct");
602*cdf0e10cSrcweir             s = xLBT.getNullPolyInterface();
603*cdf0e10cSrcweir                 bRet &= check(s.member == null, "getNullPolyInterface");
604*cdf0e10cSrcweir 
605*cdf0e10cSrcweir             s = xLBT.getNullPolyBadEnum();
606*cdf0e10cSrcweir             bRet &= check(((TestBadEnum)s.member) == TestBadEnum.M, "getNullPolyBadEnum");
607*cdf0e10cSrcweir 
608*cdf0e10cSrcweir         } catch(InvalidCastException)
609*cdf0e10cSrcweir         {
610*cdf0e10cSrcweir             bRet &= check(false, "getNullPolyXXX, InvalidCastException");
611*cdf0e10cSrcweir         }
612*cdf0e10cSrcweir 
613*cdf0e10cSrcweir         }
614*cdf0e10cSrcweir 
615*cdf0e10cSrcweir     XBridgeTest2 xBT2 = xLBT as XBridgeTest2;
616*cdf0e10cSrcweir     if (xBT2 != null) {
617*cdf0e10cSrcweir         try {
618*cdf0e10cSrcweir             xBT2.testConstructorsService(m_xContext);
619*cdf0e10cSrcweir         } catch (BadConstructorArguments) {
620*cdf0e10cSrcweir             bRet = false;
621*cdf0e10cSrcweir         }
622*cdf0e10cSrcweir     }
623*cdf0e10cSrcweir 
624*cdf0e10cSrcweir     return bRet;
625*cdf0e10cSrcweir }
626*cdf0e10cSrcweir static bool performSequenceTest(XBridgeTest xBT)
627*cdf0e10cSrcweir {
628*cdf0e10cSrcweir     bool bRet = true;
629*cdf0e10cSrcweir     XBridgeTest2  xBT2 = xBT as XBridgeTest2;
630*cdf0e10cSrcweir     if ( xBT2 == null)
631*cdf0e10cSrcweir         return false;
632*cdf0e10cSrcweir 
633*cdf0e10cSrcweir     // perform sequence tests (XBridgeTest2)
634*cdf0e10cSrcweir     // create the sequence which are compared with the results
635*cdf0e10cSrcweir     bool[] arBool = {true, false, true};
636*cdf0e10cSrcweir     char[] arChar = {'A','B','C'};
637*cdf0e10cSrcweir     byte[] arByte = { 1,  2,  0xff};
638*cdf0e10cSrcweir     short[] arShort = {Int16.MinValue, 1,  Int16.MaxValue};
639*cdf0e10cSrcweir     UInt16[] arUShort = {UInt16.MinValue , 1, UInt16.MaxValue};
640*cdf0e10cSrcweir     int[] arLong = {Int32.MinValue, 1, Int32.MaxValue};
641*cdf0e10cSrcweir     UInt32[] arULong = {UInt32.MinValue, 1, UInt32.MaxValue};
642*cdf0e10cSrcweir     long[] arHyper = {Int64.MinValue, 1, Int64.MaxValue};
643*cdf0e10cSrcweir     UInt64[] arUHyper = {UInt64.MinValue, 1, UInt64.MaxValue};
644*cdf0e10cSrcweir     float[] arFloat = {1.1f, 2.2f, 3.3f};
645*cdf0e10cSrcweir     double[] arDouble = {1.11, 2.22, 3.33};
646*cdf0e10cSrcweir     string[] arString = {"String 1", "String 2", "String 3"};
647*cdf0e10cSrcweir 
648*cdf0e10cSrcweir     Any[] arAny = {new Any(true), new Any(11111), new Any(3.14)};
649*cdf0e10cSrcweir     Object[] arObject = {new WeakBase(), new WeakBase(), new WeakBase()};
650*cdf0e10cSrcweir     TestEnum[] arEnum = {TestEnum.ONE, TestEnum.TWO, TestEnum.CHECK};
651*cdf0e10cSrcweir 
652*cdf0e10cSrcweir     TestElement[] arStruct = {new TestElement(), new TestElement(),
653*cdf0e10cSrcweir                                new TestElement()};
654*cdf0e10cSrcweir     assign( arStruct[0], true, '@', 17, 0x1234, 0xfedc, 0x12345678, 0xfedcba98,
655*cdf0e10cSrcweir  			0x123456789abcdef0, 0xfedcba9876543210, 17.0815f, 3.1415926359,
656*cdf0e10cSrcweir             TestEnum.LOLA, Constants.STRING_TEST_CONSTANT, arObject[0],
657*cdf0e10cSrcweir             new Any( typeof(Object),  arObject[0]) );
658*cdf0e10cSrcweir     assign( arStruct[1], true, 'A', 17, 0x1234, 0xfedc, 0x12345678, 0xfedcba98,
659*cdf0e10cSrcweir 			0x123456789abcdef0, 0xfedcba9876543210, 17.0815f, 3.1415926359,
660*cdf0e10cSrcweir             TestEnum.TWO, Constants.STRING_TEST_CONSTANT, arObject[1],
661*cdf0e10cSrcweir             new Any( typeof(Object), arObject[1]) );
662*cdf0e10cSrcweir     assign( arStruct[2], true, 'B', 17, 0x1234, 0xfedc, 0x12345678, 0xfedcba98,
663*cdf0e10cSrcweir 			0x123456789abcdef0, 0xfedcba9876543210, 17.0815f, 3.1415926359,
664*cdf0e10cSrcweir             TestEnum.CHECK, Constants.STRING_TEST_CONSTANT, arObject[2],
665*cdf0e10cSrcweir             new Any( typeof(Object), arObject[2] ) );
666*cdf0e10cSrcweir 
667*cdf0e10cSrcweir 
668*cdf0e10cSrcweir     int[][][] arLong3 = new int[][][]{
669*cdf0e10cSrcweir         new int[][]{new int[]{1,2,3},new int[]{4,5,6}, new int[]{7,8,9} },
670*cdf0e10cSrcweir         new int [][]{new int[]{1,2,3},new int[]{4,5,6}, new int[]{7,8,9}},
671*cdf0e10cSrcweir         new int[][]{new int[]{1,2,3},new int[]{4,5,6}, new int[]{7,8,9}}};
672*cdf0e10cSrcweir 
673*cdf0e10cSrcweir     {
674*cdf0e10cSrcweir     int[][] seqSeqRet = xBT2.setDim2(arLong3[0]);
675*cdf0e10cSrcweir     bRet = check( compareData(seqSeqRet, arLong3[0]), "sequence test") && bRet;
676*cdf0e10cSrcweir     int[][][] seqSeqRet2 = xBT2.setDim3(arLong3);
677*cdf0e10cSrcweir     bRet = check( compareData(seqSeqRet2, arLong3), "sequence test") && bRet;
678*cdf0e10cSrcweir     Any[] seqAnyRet = xBT2.setSequenceAny(arAny);
679*cdf0e10cSrcweir     bRet = check( compareData(seqAnyRet, arAny), "sequence test") && bRet;
680*cdf0e10cSrcweir     bool[] seqBoolRet = xBT2.setSequenceBool(arBool);
681*cdf0e10cSrcweir     bRet = check( compareData(seqBoolRet, arBool), "sequence test") && bRet;
682*cdf0e10cSrcweir     byte[] seqByteRet = xBT2.setSequenceByte(arByte);
683*cdf0e10cSrcweir     bRet = check( compareData(seqByteRet, arByte), "sequence test") && bRet;
684*cdf0e10cSrcweir     char[] seqCharRet = xBT2.setSequenceChar(arChar);
685*cdf0e10cSrcweir     bRet = check( compareData(seqCharRet, arChar), "sequence test") && bRet;
686*cdf0e10cSrcweir     short[] seqShortRet = xBT2.setSequenceShort(arShort);
687*cdf0e10cSrcweir     bRet = check( compareData(seqShortRet, arShort), "sequence test") && bRet;
688*cdf0e10cSrcweir     int[] seqLongRet = xBT2.setSequenceLong(arLong);
689*cdf0e10cSrcweir     bRet = check( compareData(seqLongRet, arLong), "sequence test") && bRet;
690*cdf0e10cSrcweir     long[] seqHyperRet = xBT2.setSequenceHyper(arHyper);
691*cdf0e10cSrcweir     bRet = check( compareData(seqHyperRet,arHyper), "sequence test") && bRet;
692*cdf0e10cSrcweir     float[] seqFloatRet = xBT2.setSequenceFloat(arFloat);
693*cdf0e10cSrcweir     bRet = check( compareData(seqFloatRet, arFloat), "sequence test") && bRet;
694*cdf0e10cSrcweir     double[] seqDoubleRet = xBT2.setSequenceDouble(arDouble);
695*cdf0e10cSrcweir     bRet = check( compareData(seqDoubleRet, arDouble), "sequence test") && bRet;
696*cdf0e10cSrcweir     TestEnum[] seqEnumRet = xBT2.setSequenceEnum(arEnum);
697*cdf0e10cSrcweir     bRet = check( compareData(seqEnumRet, arEnum), "sequence test") && bRet;
698*cdf0e10cSrcweir     UInt16[] seqUShortRet = xBT2.setSequenceUShort(arUShort);
699*cdf0e10cSrcweir     bRet = check( compareData(seqUShortRet, arUShort), "sequence test") && bRet;
700*cdf0e10cSrcweir     UInt32[] seqULongRet = xBT2.setSequenceULong(arULong);
701*cdf0e10cSrcweir     bRet = check( compareData(seqULongRet, arULong), "sequence test") && bRet;
702*cdf0e10cSrcweir     UInt64[] seqUHyperRet = xBT2.setSequenceUHyper(arUHyper);
703*cdf0e10cSrcweir     bRet = check( compareData(seqUHyperRet, arUHyper), "sequence test") && bRet;
704*cdf0e10cSrcweir     Object[] seqObjectRet = xBT2.setSequenceXInterface(arObject);
705*cdf0e10cSrcweir     bRet = check( compareData(seqObjectRet, arObject), "sequence test") && bRet;
706*cdf0e10cSrcweir     string[] seqStringRet = xBT2.setSequenceString(arString);
707*cdf0e10cSrcweir     bRet = check( compareData(seqStringRet, arString), "sequence test") && bRet;
708*cdf0e10cSrcweir     TestElement[] seqStructRet = xBT2.setSequenceStruct(arStruct);
709*cdf0e10cSrcweir     bRet = check( compareData(seqStructRet, arStruct), "sequence test") && bRet;
710*cdf0e10cSrcweir     }
711*cdf0e10cSrcweir     {
712*cdf0e10cSrcweir     bool[] arBoolTemp = (bool[]) arBool.Clone();
713*cdf0e10cSrcweir     char[] arCharTemp = (char[]) arChar.Clone();
714*cdf0e10cSrcweir     byte[] arByteTemp = (byte[]) arByte.Clone();
715*cdf0e10cSrcweir     short[] arShortTemp = (short[]) arShort.Clone();
716*cdf0e10cSrcweir     UInt16[] arUShortTemp = (UInt16[]) arUShort.Clone();
717*cdf0e10cSrcweir     int[] arLongTemp = (int[]) arLong.Clone();
718*cdf0e10cSrcweir     UInt32[] arULongTemp = (UInt32[]) arULong.Clone();
719*cdf0e10cSrcweir     long[] arHyperTemp = (long[]) arHyper.Clone();
720*cdf0e10cSrcweir     UInt64[] arUHyperTemp = (UInt64[]) arUHyper.Clone();
721*cdf0e10cSrcweir     float[] arFloatTemp = (float[]) arFloat.Clone();
722*cdf0e10cSrcweir     double[] arDoubleTemp = (double[]) arDouble.Clone();
723*cdf0e10cSrcweir     TestEnum[] arEnumTemp = (TestEnum[]) arEnum.Clone();
724*cdf0e10cSrcweir     string[] arStringTemp = (string[]) arString.Clone();
725*cdf0e10cSrcweir     Object[] arObjectTemp = (Object[]) arObject.Clone();
726*cdf0e10cSrcweir     Any[] arAnyTemp = (Any[]) arAny.Clone();
727*cdf0e10cSrcweir     // make sure this are has the same contents as arLong3[0]
728*cdf0e10cSrcweir     int[][] arLong2Temp = new int[][]{new int[]{1,2,3},new int[]{4,5,6}, new int[]{7,8,9} };
729*cdf0e10cSrcweir     // make sure this are has the same contents as arLong3
730*cdf0e10cSrcweir     int[][][] arLong3Temp = new int[][][]{
731*cdf0e10cSrcweir         new int[][]{new int[]{1,2,3},new int[]{4,5,6}, new int[]{7,8,9} },
732*cdf0e10cSrcweir         new int [][]{new int[]{1,2,3},new int[]{4,5,6}, new int[]{7,8,9}},
733*cdf0e10cSrcweir         new int[][]{new int[]{1,2,3},new int[]{4,5,6}, new int[]{7,8,9}}};
734*cdf0e10cSrcweir 
735*cdf0e10cSrcweir     xBT2.setSequencesInOut(ref arBoolTemp, ref arCharTemp, ref arByteTemp,
736*cdf0e10cSrcweir                            ref arShortTemp, ref arUShortTemp, ref arLongTemp,
737*cdf0e10cSrcweir                            ref arULongTemp,ref arHyperTemp, ref arUHyperTemp,
738*cdf0e10cSrcweir                            ref arFloatTemp,ref arDoubleTemp, ref arEnumTemp,
739*cdf0e10cSrcweir                            ref arStringTemp, ref  arObjectTemp,
740*cdf0e10cSrcweir                            ref arAnyTemp, ref arLong2Temp, ref arLong3Temp);
741*cdf0e10cSrcweir     bRet = check(
742*cdf0e10cSrcweir         compareData(arBoolTemp, arBool) &&
743*cdf0e10cSrcweir         compareData(arCharTemp , arChar) &&
744*cdf0e10cSrcweir         compareData(arByteTemp , arByte) &&
745*cdf0e10cSrcweir         compareData(arShortTemp , arShort) &&
746*cdf0e10cSrcweir         compareData(arUShortTemp , arUShort) &&
747*cdf0e10cSrcweir         compareData(arLongTemp , arLong) &&
748*cdf0e10cSrcweir         compareData(arULongTemp , arULong) &&
749*cdf0e10cSrcweir         compareData(arHyperTemp , arHyper) &&
750*cdf0e10cSrcweir         compareData(arUHyperTemp , arUHyper) &&
751*cdf0e10cSrcweir         compareData(arFloatTemp , arFloat) &&
752*cdf0e10cSrcweir         compareData(arDoubleTemp , arDouble) &&
753*cdf0e10cSrcweir         compareData(arEnumTemp , arEnum) &&
754*cdf0e10cSrcweir         compareData(arStringTemp , arString) &&
755*cdf0e10cSrcweir         compareData(arObjectTemp , arObject) &&
756*cdf0e10cSrcweir         compareData(arAnyTemp , arAny) &&
757*cdf0e10cSrcweir         compareData(arLong2Temp , arLong3[0]) &&
758*cdf0e10cSrcweir         compareData(arLong3Temp , arLong3), "sequence test") && bRet;
759*cdf0e10cSrcweir 
760*cdf0e10cSrcweir     bool[] arBoolOut;
761*cdf0e10cSrcweir     char[] arCharOut;
762*cdf0e10cSrcweir     byte[] arByteOut;
763*cdf0e10cSrcweir     short[] arShortOut;
764*cdf0e10cSrcweir     UInt16[] arUShortOut;
765*cdf0e10cSrcweir     int[] arLongOut;
766*cdf0e10cSrcweir     UInt32[] arULongOut;
767*cdf0e10cSrcweir     long[] arHyperOut;
768*cdf0e10cSrcweir     UInt64[] arUHyperOut;
769*cdf0e10cSrcweir     float[] arFloatOut;
770*cdf0e10cSrcweir     double[] arDoubleOut;
771*cdf0e10cSrcweir     TestEnum[] arEnumOut;
772*cdf0e10cSrcweir     string[] arStringOut;
773*cdf0e10cSrcweir     Object[] arObjectOut;
774*cdf0e10cSrcweir     Any[] arAnyOut;
775*cdf0e10cSrcweir     int[][] arLong2Out;
776*cdf0e10cSrcweir     int[][][] arLong3Out;
777*cdf0e10cSrcweir 
778*cdf0e10cSrcweir     xBT2.setSequencesOut(out arBoolOut, out arCharOut, out arByteOut,
779*cdf0e10cSrcweir                          out arShortOut, out arUShortOut, out arLongOut,
780*cdf0e10cSrcweir                          out arULongOut, out arHyperOut, out arUHyperOut,
781*cdf0e10cSrcweir                          out arFloatOut, out arDoubleOut, out arEnumOut,
782*cdf0e10cSrcweir                          out arStringOut, out arObjectOut, out arAnyOut,
783*cdf0e10cSrcweir                          out arLong2Out, out arLong3Out);
784*cdf0e10cSrcweir     bRet = check(
785*cdf0e10cSrcweir         compareData(arBoolOut, arBool) &&
786*cdf0e10cSrcweir         compareData(arCharOut, arChar) &&
787*cdf0e10cSrcweir         compareData(arByteOut, arByte) &&
788*cdf0e10cSrcweir         compareData(arShortOut, arShort) &&
789*cdf0e10cSrcweir         compareData(arUShortOut, arUShort) &&
790*cdf0e10cSrcweir         compareData(arLongOut, arLong) &&
791*cdf0e10cSrcweir         compareData(arULongOut, arULong) &&
792*cdf0e10cSrcweir         compareData(arHyperOut, arHyper) &&
793*cdf0e10cSrcweir         compareData(arUHyperOut, arUHyper) &&
794*cdf0e10cSrcweir         compareData(arFloatOut, arFloat) &&
795*cdf0e10cSrcweir         compareData(arDoubleOut, arDouble) &&
796*cdf0e10cSrcweir         compareData(arEnumOut, arEnum) &&
797*cdf0e10cSrcweir         compareData(arStringOut, arString) &&
798*cdf0e10cSrcweir         compareData(arObjectOut, arObject) &&
799*cdf0e10cSrcweir         compareData(arAnyOut, arAny) &&
800*cdf0e10cSrcweir         compareData(arLong2Out, arLong3[0]) &&
801*cdf0e10cSrcweir         compareData(arLong3Out, arLong3), "sequence test") && bRet;
802*cdf0e10cSrcweir     }
803*cdf0e10cSrcweir     {
804*cdf0e10cSrcweir     //test with empty sequences
805*cdf0e10cSrcweir     int[][] _arLong2 = new int[0][];
806*cdf0e10cSrcweir     int[][] seqSeqRet = xBT2.setDim2(_arLong2);
807*cdf0e10cSrcweir     bRet = check( compareData(seqSeqRet, _arLong2), "sequence test") && bRet;
808*cdf0e10cSrcweir     int[][][] _arLong3 = new int[0][][];
809*cdf0e10cSrcweir     int[][][] seqSeqRet2 = xBT2.setDim3(_arLong3);
810*cdf0e10cSrcweir     bRet = check( compareData(seqSeqRet2, _arLong3), "sequence test") && bRet;
811*cdf0e10cSrcweir     Any[] _arAny = new Any[0];
812*cdf0e10cSrcweir     Any[] seqAnyRet = xBT2.setSequenceAny(_arAny);
813*cdf0e10cSrcweir     bRet = check( compareData(seqAnyRet, _arAny), "sequence test") && bRet;
814*cdf0e10cSrcweir     bool[] _arBool = new bool[0];
815*cdf0e10cSrcweir     bool[] seqBoolRet = xBT2.setSequenceBool(_arBool);
816*cdf0e10cSrcweir     bRet = check( compareData(seqBoolRet, _arBool), "sequence test") && bRet;
817*cdf0e10cSrcweir     byte[] _arByte = new byte[0];
818*cdf0e10cSrcweir     byte[] seqByteRet = xBT2.setSequenceByte(_arByte);
819*cdf0e10cSrcweir     bRet = check( compareData(seqByteRet, _arByte), "sequence test") && bRet;
820*cdf0e10cSrcweir     char[] _arChar = new char[0];
821*cdf0e10cSrcweir     char[] seqCharRet = xBT2.setSequenceChar(_arChar);
822*cdf0e10cSrcweir     bRet = check( compareData(seqCharRet, _arChar), "sequence test") && bRet;
823*cdf0e10cSrcweir     short[] _arShort = new short[0];
824*cdf0e10cSrcweir     short[] seqShortRet = xBT2.setSequenceShort(_arShort);
825*cdf0e10cSrcweir     bRet = check( compareData(seqShortRet, _arShort), "sequence test") && bRet;
826*cdf0e10cSrcweir     int[] _arLong = new int[0];
827*cdf0e10cSrcweir     int[] seqLongRet = xBT2.setSequenceLong(_arLong);
828*cdf0e10cSrcweir     bRet = check( compareData(seqLongRet, _arLong), "sequence test") && bRet;
829*cdf0e10cSrcweir     long[] _arHyper = new long[0];
830*cdf0e10cSrcweir     long[] seqHyperRet = xBT2.setSequenceHyper(_arHyper);
831*cdf0e10cSrcweir     bRet = check( compareData(seqHyperRet, _arHyper), "sequence test") && bRet;
832*cdf0e10cSrcweir     float[] _arFloat = new float[0];
833*cdf0e10cSrcweir     float[] seqFloatRet = xBT2.setSequenceFloat(_arFloat);
834*cdf0e10cSrcweir     bRet = check( compareData(seqFloatRet, _arFloat), "sequence test") && bRet;
835*cdf0e10cSrcweir     double[] _arDouble = new double[0];
836*cdf0e10cSrcweir     double[] seqDoubleRet = xBT2.setSequenceDouble(_arDouble);
837*cdf0e10cSrcweir     bRet = check( compareData(seqDoubleRet, _arDouble), "sequence test") && bRet;
838*cdf0e10cSrcweir     TestEnum[] _arEnum = new TestEnum[0];
839*cdf0e10cSrcweir     TestEnum[] seqEnumRet = xBT2.setSequenceEnum(_arEnum);
840*cdf0e10cSrcweir     bRet = check( compareData(seqEnumRet, _arEnum), "sequence test") && bRet;
841*cdf0e10cSrcweir     UInt16[] _arUShort = new UInt16[0];
842*cdf0e10cSrcweir     UInt16[] seqUShortRet = xBT2.setSequenceUShort(_arUShort);
843*cdf0e10cSrcweir     bRet = check( compareData(seqUShortRet, _arUShort), "sequence test") && bRet;
844*cdf0e10cSrcweir     UInt32[] _arULong = new UInt32[0];
845*cdf0e10cSrcweir     UInt32[] seqULongRet = xBT2.setSequenceULong(_arULong);
846*cdf0e10cSrcweir     bRet = check( compareData(seqULongRet, _arULong), "sequence test") && bRet;
847*cdf0e10cSrcweir     UInt64[] _arUHyper = new UInt64[0];
848*cdf0e10cSrcweir     UInt64[] seqUHyperRet = xBT2.setSequenceUHyper(_arUHyper);
849*cdf0e10cSrcweir     bRet = check( compareData(seqUHyperRet, _arUHyper), "sequence test") && bRet;
850*cdf0e10cSrcweir     Object[] _arObject = new Object[0];
851*cdf0e10cSrcweir     Object[] seqObjectRet = xBT2.setSequenceXInterface(_arObject);
852*cdf0e10cSrcweir     bRet = check( compareData(seqObjectRet, _arObject), "sequence test") && bRet;
853*cdf0e10cSrcweir     string[] _arString = new string[0];
854*cdf0e10cSrcweir     string[] seqStringRet = xBT2.setSequenceString(_arString);
855*cdf0e10cSrcweir     bRet = check( compareData(seqStringRet, _arString), "sequence test") && bRet;
856*cdf0e10cSrcweir     TestElement[] _arStruct = new TestElement[0];
857*cdf0e10cSrcweir     TestElement[] seqStructRet = xBT2.setSequenceStruct(_arStruct);
858*cdf0e10cSrcweir     bRet = check( compareData(seqStructRet, _arStruct), "sequence test") && bRet;
859*cdf0e10cSrcweir 
860*cdf0e10cSrcweir     }
861*cdf0e10cSrcweir 
862*cdf0e10cSrcweir 
863*cdf0e10cSrcweir     return bRet;
864*cdf0e10cSrcweir }
865*cdf0e10cSrcweir /** Test the System::Object method on the proxy object
866*cdf0e10cSrcweir  */
867*cdf0e10cSrcweir static bool testObjectMethodsImplemention(XBridgeTest xLBT)
868*cdf0e10cSrcweir {
869*cdf0e10cSrcweir     bool ret = false;
870*cdf0e10cSrcweir     Object obj = new Object();
871*cdf0e10cSrcweir 	Object xInt = (Object) xLBT;
872*cdf0e10cSrcweir 	XBridgeTestBase xBase = xLBT as XBridgeTestBase;
873*cdf0e10cSrcweir 	if (xBase == null)
874*cdf0e10cSrcweir 		return false;
875*cdf0e10cSrcweir 	// Object.Equals
876*cdf0e10cSrcweir 	ret = xLBT.Equals(obj) == false;
877*cdf0e10cSrcweir 	ret = xLBT.Equals(xLBT) && ret;
878*cdf0e10cSrcweir 	ret = Object.Equals(obj, obj) && ret;
879*cdf0e10cSrcweir 	ret = Object.Equals(xLBT, xBase) && ret;
880*cdf0e10cSrcweir 	//Object.GetHashCode
881*cdf0e10cSrcweir 	// Don't know how to verify this. Currently it is not possible to get the object id from a proxy
882*cdf0e10cSrcweir 	int nHash = xLBT.GetHashCode();
883*cdf0e10cSrcweir 	ret = nHash == xBase.GetHashCode() && ret;
884*cdf0e10cSrcweir 
885*cdf0e10cSrcweir 	//Object.ToString
886*cdf0e10cSrcweir     // Don't know how to verify this automatically.
887*cdf0e10cSrcweir 	string s = xLBT.ToString();
888*cdf0e10cSrcweir     ret = (s.Length > 0) && ret;
889*cdf0e10cSrcweir     return ret;
890*cdf0e10cSrcweir }
891*cdf0e10cSrcweir 
892*cdf0e10cSrcweir 
893*cdf0e10cSrcweir static bool raiseOnewayException(XBridgeTest xLBT)
894*cdf0e10cSrcweir {
895*cdf0e10cSrcweir     bool bReturn = true;
896*cdf0e10cSrcweir 	string sCompare = Constants.STRING_TEST_CONSTANT;
897*cdf0e10cSrcweir 	try
898*cdf0e10cSrcweir 	{
899*cdf0e10cSrcweir 		// Note : the exception may fly or not (e.g. remote scenario).
900*cdf0e10cSrcweir 		//        When it flies, it must contain the correct elements.
901*cdf0e10cSrcweir 		xLBT.raiseRuntimeExceptionOneway(sCompare, xLBT.Interface );
902*cdf0e10cSrcweir 	}
903*cdf0e10cSrcweir 	catch (RuntimeException  e )
904*cdf0e10cSrcweir 	{
905*cdf0e10cSrcweir 		bReturn = ( xLBT.Interface == e.Context );
906*cdf0e10cSrcweir 	}
907*cdf0e10cSrcweir     return bReturn;
908*cdf0e10cSrcweir }
909*cdf0e10cSrcweir 
910*cdf0e10cSrcweir // //==================================================================================================
911*cdf0e10cSrcweir static bool raiseException(XBridgeTest xLBT )
912*cdf0e10cSrcweir {
913*cdf0e10cSrcweir 	int nCount = 0;
914*cdf0e10cSrcweir 	try
915*cdf0e10cSrcweir 	{
916*cdf0e10cSrcweir 		try
917*cdf0e10cSrcweir 		{
918*cdf0e10cSrcweir 			try
919*cdf0e10cSrcweir 			{
920*cdf0e10cSrcweir 				TestDataElements aRet = new TestDataElements();
921*cdf0e10cSrcweir                 TestDataElements aRet2 = new TestDataElements();
922*cdf0e10cSrcweir 				xLBT.raiseException(
923*cdf0e10cSrcweir 					5, Constants.STRING_TEST_CONSTANT, xLBT.Interface );
924*cdf0e10cSrcweir 			}
925*cdf0e10cSrcweir 			catch (unoidl.com.sun.star.lang.IllegalArgumentException aExc)
926*cdf0e10cSrcweir 			{
927*cdf0e10cSrcweir 				if (aExc.ArgumentPosition == 5 &&
928*cdf0e10cSrcweir                     aExc.Context == xLBT.Interface)
929*cdf0e10cSrcweir 				{
930*cdf0e10cSrcweir 					++nCount;
931*cdf0e10cSrcweir 				}
932*cdf0e10cSrcweir 				else
933*cdf0e10cSrcweir 				{
934*cdf0e10cSrcweir 					check( false, "### unexpected exception content!" );
935*cdf0e10cSrcweir 				}
936*cdf0e10cSrcweir 
937*cdf0e10cSrcweir 				/** it is certain, that the RuntimeException testing will fail,
938*cdf0e10cSrcweir                     if no */
939*cdf0e10cSrcweir 				xLBT.RuntimeException = 0;
940*cdf0e10cSrcweir 			}
941*cdf0e10cSrcweir 		}
942*cdf0e10cSrcweir 		catch (unoidl.com.sun.star.uno.RuntimeException rExc)
943*cdf0e10cSrcweir 		{
944*cdf0e10cSrcweir 			if (rExc.Context == xLBT.Interface )
945*cdf0e10cSrcweir 			{
946*cdf0e10cSrcweir 				++nCount;
947*cdf0e10cSrcweir 			}
948*cdf0e10cSrcweir 			else
949*cdf0e10cSrcweir 			{
950*cdf0e10cSrcweir 				check( false, "### unexpected exception content!" );
951*cdf0e10cSrcweir 			}
952*cdf0e10cSrcweir 
953*cdf0e10cSrcweir 			/** it is certain, that the RuntimeException testing will fail, if no */
954*cdf0e10cSrcweir             unchecked
955*cdf0e10cSrcweir              {
956*cdf0e10cSrcweir                  xLBT.RuntimeException = (int) 0xcafebabe;
957*cdf0e10cSrcweir              }
958*cdf0e10cSrcweir 		}
959*cdf0e10cSrcweir 	}
960*cdf0e10cSrcweir 	catch (unoidl.com.sun.star.uno.Exception  rExc)
961*cdf0e10cSrcweir 	{
962*cdf0e10cSrcweir 		if (rExc.Context == xLBT.Interface)
963*cdf0e10cSrcweir 		{
964*cdf0e10cSrcweir 			++nCount;
965*cdf0e10cSrcweir 		}
966*cdf0e10cSrcweir 		else
967*cdf0e10cSrcweir 
968*cdf0e10cSrcweir 		{
969*cdf0e10cSrcweir 			check( false, "### unexpected exception content!" );
970*cdf0e10cSrcweir 		}
971*cdf0e10cSrcweir 		return (nCount == 3);
972*cdf0e10cSrcweir 	}
973*cdf0e10cSrcweir     return false;
974*cdf0e10cSrcweir }
975*cdf0e10cSrcweir 
976*cdf0e10cSrcweir     private void perform_test( XBridgeTest xLBT )
977*cdf0e10cSrcweir     {
978*cdf0e10cSrcweir         bool bRet= true;;
979*cdf0e10cSrcweir        bRet = check( performTest( xLBT ), "standard test" ) && bRet;
980*cdf0e10cSrcweir        bRet = check( raiseException( xLBT ) , "exception test" )&& bRet;
981*cdf0e10cSrcweir        bRet = check( raiseOnewayException( xLBT ), "oneway exception test" ) && bRet;
982*cdf0e10cSrcweir        bRet = check( testObjectMethodsImplemention(xLBT), "object methods test") && bRet;
983*cdf0e10cSrcweir        bRet = performQueryForUnknownType( xLBT ) && bRet;
984*cdf0e10cSrcweir         if ( ! bRet)
985*cdf0e10cSrcweir         {
986*cdf0e10cSrcweir             throw new unoidl.com.sun.star.uno.RuntimeException( "error (cli_cs_bridgetest.cs): test failed!", null);
987*cdf0e10cSrcweir         }
988*cdf0e10cSrcweir     }
989*cdf0e10cSrcweir 
990*cdf0e10cSrcweir     public BridgeTest( XComponentContext xContext )
991*cdf0e10cSrcweir     {
992*cdf0e10cSrcweir         m_xContext = xContext;
993*cdf0e10cSrcweir     }
994*cdf0e10cSrcweir 
995*cdf0e10cSrcweir     private XComponentContext m_xContext;
996*cdf0e10cSrcweir 
997*cdf0e10cSrcweir 	public int run( String [] args )
998*cdf0e10cSrcweir 	{
999*cdf0e10cSrcweir 		Debug.AutoFlush = true;
1000*cdf0e10cSrcweir //		System.Diagnostics.Debugger.Launch();
1001*cdf0e10cSrcweir 		try
1002*cdf0e10cSrcweir 		{
1003*cdf0e10cSrcweir 			if (args.Length < 1)
1004*cdf0e10cSrcweir 			{
1005*cdf0e10cSrcweir 				throw new RuntimeException(
1006*cdf0e10cSrcweir 					"missing argument for bridgetest!", this );
1007*cdf0e10cSrcweir 			}
1008*cdf0e10cSrcweir 			Object test_obj =
1009*cdf0e10cSrcweir 				m_xContext.getServiceManager().createInstanceWithContext(
1010*cdf0e10cSrcweir 				args[ 0 ], m_xContext );
1011*cdf0e10cSrcweir 
1012*cdf0e10cSrcweir 			Debug.WriteLine(
1013*cdf0e10cSrcweir 				"Calling object: {0}", test_obj.ToString() );
1014*cdf0e10cSrcweir 
1015*cdf0e10cSrcweir 			XBridgeTest xTest = (XBridgeTest) test_obj ;
1016*cdf0e10cSrcweir 			perform_test( xTest );
1017*cdf0e10cSrcweir 			Console.WriteLine( "\n### cli_uno C# bridgetest succeeded." );
1018*cdf0e10cSrcweir 			return 0;
1019*cdf0e10cSrcweir 		}
1020*cdf0e10cSrcweir 		catch (unoidl.com.sun.star.uno.RuntimeException)
1021*cdf0e10cSrcweir 		{
1022*cdf0e10cSrcweir 			throw;
1023*cdf0e10cSrcweir 		}
1024*cdf0e10cSrcweir 		catch (System.Exception exc)
1025*cdf0e10cSrcweir 		{
1026*cdf0e10cSrcweir 			throw new unoidl.com.sun.star.uno.RuntimeException(
1027*cdf0e10cSrcweir 				"cli_cs_bridgetest.cs: unexpected exception occured in XMain::run. Original exception: " +
1028*cdf0e10cSrcweir 				exc.GetType().Name + "\n Message: " + exc.Message , null);
1029*cdf0e10cSrcweir 		}
1030*cdf0e10cSrcweir     }
1031*cdf0e10cSrcweir }
1032*cdf0e10cSrcweir 
1033*cdf0e10cSrcweir }
1034