public async Task GenericTask_WithImplementation_AwaitDelay() { var instance = new TestImplementation(); var proxy = CreateForImplementation(instance); var task = proxy.InvokeGenericTaskWithAwaitDelay(); await task; Assert.True(instance.IsCompleted); }
public void String_WithImplementation() { var instance = new TestImplementation(); var proxy = CreateForImplementation(instance); var result = proxy.InvokeString(); Assert.True(instance.IsCompleted); Assert.Equal("Non-task string", result); }
public async Task GenericTask_WithImplementation() { var instance = new TestImplementation(); var proxy = CreateForImplementation(instance); var task = proxy.InvokeGenericTask(); var result = await task; Assert.True(instance.IsCompleted); Assert.Equal("Generic task string", result); }
private ITestInterfaceWithoutAttribute CreateForNoAttribute(TestImplementation instance) { var generator = new ProxyGenerator(); return((ITestInterfaceWithoutAttribute)generator.CreateInterfaceProxyWithTarget(typeof(ITestInterfaceWithoutAttribute), instance, new CommandInterceptor())); }
public async Task UntypedTask_WithImplementation_Throws() { var instance = new TestImplementation(); var proxy = CreateForImplementation(instance); Assert.Throws<NotSupportedException>(() => { proxy.InvokeUntypedTask(); }); //Assert.True(task != null); //Assert.True(task is Task); //Assert.False(task.GetType().IsGenericType); //await task; //Assert.True(instance.IsCompleted); }
private ITestInterfaceWithoutAttribute CreateForNoAttribute(TestImplementation instance) { var generator = new ProxyGenerator(); return (ITestInterfaceWithoutAttribute)generator.CreateInterfaceProxyWithTarget(typeof(ITestInterfaceWithoutAttribute), instance, new CommandInterceptor()); }
public void InterfaceMissingAttribute_Throws() { var instance = new TestImplementation(); var proxy = CreateForNoAttribute(instance); var ex = Assert.Throws<TargetInvocationException>(() => { proxy.InvokeGenericTask(); }); Assert.Equal("Interface does not have [CommandAttribute]", ex.InnerException.Message); }
public void Void_WithImplementation() { var instance = new TestImplementation(); var proxy = CreateForImplementation(instance); proxy.InvokeVoid(); Assert.True(instance.IsCompleted); }