public void RetrieveIntProperty_NoInheritance() { var interfaceApplierFactory = new ReflectionInterfaceApplierFactory("InterfaceApplierFactoryTests", ComVisibilityOptions.NotVisible); var interfaceApplier = interfaceApplierFactory.GenerateInterfaceApplier <IAgedInt32ReadOnly>( new ActionlessReadValueConverter() ); var src = new ReadOnlyAgedInt32Class1(29); var srcWrapped = interfaceApplier.Apply(src); Assert.Equal(29, srcWrapped.Age); }
public void RetrieveInt32ValueAsInt16PropertyWillFail() { var interfaceApplierFactory = new ReflectionInterfaceApplierFactory("InterfaceApplierFactoryTests", ComVisibilityOptions.NotVisible); var interfaceApplier = interfaceApplierFactory.GenerateInterfaceApplier <IAgedInt16ReadOnly>( new ActionlessReadValueConverter() ); var src = new ReadOnlyAgedInt32Class1(29); var srcWrapped = interfaceApplier.Apply(src); Assert.Throws <InvalidCastException>(() => { Console.WriteLine(srcWrapped.Age); }); }