Inheritance: ITestInterfaceWithImplementation, ITestInterfaceWithoutAttribute
Ejemplo n.º 1
0
        public async Task GenericTask_WithImplementation_AwaitDelay()
        {
            var instance = new TestImplementation();
            var proxy = CreateForImplementation(instance);

            var task = proxy.InvokeGenericTaskWithAwaitDelay();
            await task;

            Assert.True(instance.IsCompleted);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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()));
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
 private ITestInterfaceWithoutAttribute CreateForNoAttribute(TestImplementation instance)
 {
     var generator = new ProxyGenerator();
     return (ITestInterfaceWithoutAttribute)generator.CreateInterfaceProxyWithTarget(typeof(ITestInterfaceWithoutAttribute), instance, new CommandInterceptor());
 }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
        public void Void_WithImplementation()
        {
            var instance = new TestImplementation();
            var proxy = CreateForImplementation(instance);

            proxy.InvokeVoid();

            Assert.True(instance.IsCompleted);
        }