示例#1
0
 public DeferredConstructorInterceptorTests()
 {
     _events    = new ConcurrentQueue <string>();
     _decorator = _generator.CreateInterfaceProxyWithoutTarget <ISomeMethods>(
         new DeferredConstructorInterceptor <ISomeMethods>(
             async() => await SomeMethods.Create(_events)));
 }
示例#2
0
文件: TestEmit.cs 项目: ForNeVeR/pnet
    // Test SomeMethods using interface-access, Run
    public void TestSomeMethodsRun()
    {
        Type t = CreateSomeMethods(false);

        // Create instance
        object       io = Activator.CreateInstance(t);
        ISomeMethods i  = (ISomeMethods)io;

        // Test the generated code...
        VerifySomeMethods(i);
    }
示例#3
0
文件: TestEmit.cs 项目: ForNeVeR/pnet
    // Test SomeMethods using interface-access, Save
    public void TestSomeMethodsSave()
    {
        // Create for save
        CreateSomeMethods(true);

        // Save the assembly
        assemblybuilder.Save("SomeMethods.dll");

        // OK! Built the assembly, let's use it...
        Assembly SomeAsm = Assembly.LoadFrom("SomeMethods.dll");
        Type     t       = SomeAsm.GetType("SomeMethods");

        // Make an instance...
        ISomeMethods i = (ISomeMethods)(SomeAsm.CreateInstance("SomeMethods"));

        // Test the generated code...
        VerifySomeMethods(i);
    }
示例#4
0
文件: TestEmit.cs 项目: ForNeVeR/pnet
    private void VerifySomeMethods(ISomeMethods ism)
    {
        ism.nop();

        AssertEquals("inc(0) => 1", 1, ism.inc(0));
        AssertEquals("dec(1) => 0", 0, ism.dec(1));

        ism.SetTag("Hello");
        AssertEquals("GetTag() => 'Hello'", "Hello", ism.GetTag());

        ism.ThrowMe(false);

        try
        {
            ism.ThrowMe(true);
            Fail("ThrowMe(true) EXPECTED Exception!");
        }
        catch (Exception)
        {
            //OK
        }
    }
示例#5
0
	private void VerifySomeMethods( ISomeMethods ism )
	{
		ism.nop();

		AssertEquals( "inc(0) => 1", 1, ism.inc(0) );
		AssertEquals( "dec(1) => 0", 0, ism.dec(1) );

		ism.SetTag("Hello");
		AssertEquals("GetTag() => 'Hello'", "Hello", ism.GetTag() );

		ism.ThrowMe( false );

		try
		{
			ism.ThrowMe( true );
			Fail("ThrowMe(true) EXPECTED Exception!");
		}
		catch( Exception )
		{
			//OK
		}
	}