public void Value_Set_AssignableFrom_ReferenceType()
        {
            ParameterInfo           info       = DescriptorWithParameter.Parameters[2];
            ParameterDescriptor     descriptor = new ParameterDescriptor(null, info);
            DescriptorWithParameter service    = new DescriptorWithParameter();

            descriptor.Value = service;
            Assert.Equal(service, descriptor.Value);
        }
Exemple #2
0
        public void Test_Property()
        {
            object impInstance = new DescriptorWithParameter();

            ProxyDescriptor descriptor = new ProxyDescriptor(impInstance, DescriptorWithParameter.Method, typeof(DescriptorWithParameter));

            Assert.Equal(descriptor.ProxyInstance, impInstance);
            Assert.Equal(descriptor.ProxyMethod, DescriptorWithParameter.Method);
            Assert.Equal(descriptor.ProxyType, typeof(DescriptorWithParameter));
        }
        public void Test_Property()
        {
            object impInstance = new DescriptorWithParameter();

            TargetDescriptor descriptor = new TargetDescriptor(impInstance, DescriptorWithParameter.Method, typeof(DescriptorWithParameter), DescriptorWithParameter.Method, typeof(DescriptorWithParameter));

            Assert.Equal(descriptor.ImplementationInstance, impInstance);
            Assert.Equal(descriptor.ServiceMethod, DescriptorWithParameter.Method);
            Assert.Equal(descriptor.ServiceType, typeof(DescriptorWithParameter));
            Assert.Equal(descriptor.ImplementationMethod, DescriptorWithParameter.Method);
            Assert.Equal(descriptor.ImplementationType, typeof(DescriptorWithParameter));
        }
        public void Invoke_Test(object value)
        {
            object impInstance = new DescriptorWithParameter();

            TargetDescriptor descriptor = new TargetDescriptor(impInstance, DescriptorWithParameter.Method, typeof(DescriptorWithParameter), DescriptorWithParameter.InvokeMethod, typeof(DescriptorWithParameter));

            var parameters = new ParameterCollection(new object[] { value }, DescriptorWithParameter.InvokeMethod.GetParameters());

            var result = descriptor.Invoke(parameters);

            Assert.Equal(result, value);
        }