public async void SumAsync() { var handWritten = new HandWritten(); var proxy = Proxy.CreateProxy <IHandWritten>(handWritten, async invocation => { var value = (int)await invocation.Proceed(); return(value + 3); }); var result = await proxy.SumAsync(1, 2); Assert.AreEqual(6, result); }
public void GetString() { var handWritten = new HandWritten(); var proxy = Proxy.CreateProxy <IHandWritten>(handWritten, async invocation => { var returnValue = await invocation.Proceed(); return((string)returnValue + "test"); }); var result = proxy.GetString(); Assert.AreEqual(HandWritten.GetStringReturnValue + "test", result); }
public void GetString() { var handWritten = new HandWritten(); var proxy = new HandWrittenProxy(handWritten, new InvocationHandler(async invocation => { var returnValue = await invocation.Proceed(); return((string)returnValue + "test"); })); var result = proxy.GetString(); Assert.AreEqual(HandWritten.GetStringReturnValue + "test", result); }
public void DoSomething() { var handWritten = new HandWritten(); var proxy = Proxy.CreateProxy <IHandWritten>(handWritten, async invocation => { await invocation.Proceed(); return(null); }); proxy.DoSomething(); Assert.IsTrue(handWritten.DoSomethingCalled); }
public async void SumAsync() { var handWritten = new HandWritten(); var proxy = new HandWrittenProxy(handWritten, new InvocationHandler(async invocation => { var value = (int)await invocation.Proceed(); return(value + 3); })); var result = await proxy.SumAsync(1, 2); Assert.AreEqual(6, result); }
public void DoSomething() { var handWritten = new HandWritten(); var proxy = new HandWrittenProxy(handWritten, new InvocationHandler(async invocation => { await invocation.Proceed(); return(null); })); proxy.DoSomething(); Assert.IsTrue(handWritten.DoSomethingCalled); }
public void StringPropertySet() { var handWritten = new HandWritten(); var proxy = Proxy.CreateProxy <IHandWritten>(handWritten, async invocation => { invocation.Arguments[0] = "AStringValue" + invocation.Arguments[0]; await invocation.Proceed(); return(null); }); proxy.StringProperty = "test"; Assert.AreEqual("AStringValue" + "test", handWritten.StringProperty); }
public async void GetStringAsync() { var handWritten = new HandWritten(); var proxy = Proxy.CreateProxy(handWritten, async invocation => { await Task.Delay(1); var returnValue = await invocation.Proceed(); return((string)returnValue + "test"); }); var result = await proxy.GetStringAsync(); Assert.AreEqual(HandWritten.GetStringAsyncReturnValue + "test", result); }
public async void DoSomethingAsync() { var handWritten = new HandWritten(); var proxy = Proxy.CreateProxy(handWritten, async invocation => { await Task.Delay(1); await invocation.Proceed(); return(null); }); await proxy.DoSomethingAsync(); Assert.IsTrue(handWritten.DoSomethingAsyncCalled); }
public void StringPropertyGet() { var handWritten = new HandWritten(); handWritten.StringProperty = "AStringProperty"; var proxy = Proxy.CreateProxy <IHandWritten>(handWritten, async invocation => { var returnValue = await invocation.Proceed(); return((string)returnValue + "test"); }); var result = proxy.StringProperty; Assert.AreEqual("AStringProperty" + "test", result); }
public void StringPropertyPropertyInfo() { var handWritten = new HandWritten(); PropertyInfo property = null; var proxy = new HandWrittenProxy(handWritten, new InvocationHandler(async invocation => { var returnValue = await invocation.Proceed(); property = invocation.Property; return((string)returnValue + "test"); })); // ReSharper disable once UnusedVariable (We are trying to invoke the accessor, but only to set the property variable above) var result = proxy.StringProperty; Assert.AreEqual(nameof(HandWritten.StringProperty), property.Name); }
public void GetStringThrowsExcpetionIfAsync() { var handWritten = new HandWritten(); var proxy = Proxy.CreateProxy <IHandWritten>(handWritten, async invocation => { await Task.Delay(1); var returnValue = await invocation.Proceed(); return((string)returnValue + "test"); }); try { proxy.GetString(); Assert.Fail("Should have thrown an InvalidAsyncException"); } catch (InvalidAsyncException) { } }