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