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