예제 #1
0
		public void ProxyForRefAndOutClassWithEnumTypeParams()
		{
			LogInvokeInterceptor interceptor = new LogInvokeInterceptor();

			RefAndOutClass proxy = (RefAndOutClass)
				_generator.CreateClassProxy(
				typeof(RefAndOutClass), interceptor);

			Assert.IsNotNull(proxy);

			SByteEnum value1 = SByteEnum.One;
			proxy.RefSByteEnum(ref value1);
			Assert.AreEqual(SByteEnum.Two, value1);

			SByteEnum value2;
			proxy.OutSByteEnum(out value2);
			Assert.AreEqual(SByteEnum.Two, value2);

			Assert.AreEqual("RefSByteEnum OutSByteEnum ", interceptor.LogContents);
		}
예제 #2
0
		public void ProxyForRefAndOutClassWithReferenceTypeParams()
		{
			LogInvokeInterceptor interceptor = new LogInvokeInterceptor();

			RefAndOutClass proxy = (RefAndOutClass)
				_generator.CreateClassProxy(
				typeof(RefAndOutClass), interceptor);

			Assert.IsNotNull(proxy);

			string string1 = "foobar";
			proxy.RefString(ref string1);
			Assert.AreEqual("foobar_string", string1);

			string string2;
			proxy.OutString(out string2);
			Assert.AreEqual("string", string2);

			Assert.AreEqual("RefString OutString ", interceptor.LogContents);
		}
예제 #3
0
		public void ProxyForRefAndOutClassWithStructTypeParams()
		{
			LogInvokeInterceptor interceptor = new LogInvokeInterceptor();

			RefAndOutClass proxy = (RefAndOutClass)
				_generator.CreateClassProxy(
				typeof(RefAndOutClass), interceptor);

			Assert.IsNotNull(proxy);

			DateTime dt1 = new DateTime(1999, 1, 1);
			proxy.RefDateTime(ref dt1);
			Assert.AreEqual(new DateTime(2000, 1, 1), dt1);

			DateTime dt2;
			proxy.OutDateTime(out dt2);
			Assert.AreEqual(new DateTime(2005, 1, 1), dt2);

			Assert.AreEqual("RefDateTime OutDateTime ", interceptor.LogContents);
		}
예제 #4
0
		public void ProxyForRefAndOutClassWithPrimitiveTypeParams()
		{
			LogInvokeInterceptor interceptor = new LogInvokeInterceptor();

			RefAndOutClass proxy = (RefAndOutClass) 
				_generator.CreateClassProxy(
				typeof(RefAndOutClass), interceptor);

			Assert.IsNotNull(proxy);

			int int1 = -3;
			proxy.RefInt(ref int1);
			Assert.AreEqual(-2, int1);
			
			char c = 'z';
			proxy.RefChar(ref c);
			Assert.AreEqual('a', c);
			
			c = 'z';
			proxy.OutChar(out c);
			Assert.AreEqual('b', c);

			int int2;
			proxy.OutInt(out int2);
			Assert.AreEqual(2, int2);

			Assert.AreEqual("RefInt RefChar OutChar OutInt ", interceptor.LogContents);
		}