public DeferredConstructorInterceptorTests() { _events = new ConcurrentQueue <string>(); _decorator = _generator.CreateInterfaceProxyWithoutTarget <ISomeMethods>( new DeferredConstructorInterceptor <ISomeMethods>( async() => await SomeMethods.Create(_events))); }
// 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); }
// 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); }
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 } }
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 } }