public void ConvertFrom_Uses_Selector_TargetType() { var target = new AvaloniaPropertyTypeConverter(); var style = new Style(x => x.OfType<Class1>()); var context = CreateContext(style); var result = target.ConvertFrom(context, null, "Foo"); Assert.Equal(Class1.FooProperty, result); }
private IValueContext CreateContext(Style style = null) { var context = new Mock<IValueContext>(); var topDownValueContext = new Mock<ITopDownValueContext>(); var typeRepository = new Mock<ITypeRepository>(); var featureProvider = new Mock<ITypeFeatureProvider>(); var class1XamlType = new XamlType(typeof(Class1), typeRepository.Object, null, featureProvider.Object); var attachedOwnerXamlType = new XamlType(typeof(AttachedOwner), typeRepository.Object, null, featureProvider.Object); context.Setup(x => x.TopDownValueContext).Returns(topDownValueContext.Object); context.Setup(x => x.TypeRepository).Returns(typeRepository.Object); topDownValueContext.Setup(x => x.GetLastInstance(It.IsAny<XamlType>())).Returns(style); typeRepository.Setup(x => x.GetByQualifiedName("Class1")).Returns(class1XamlType); typeRepository.Setup(x => x.GetByQualifiedName("AttachedOwner")).Returns(attachedOwnerXamlType); return context.Object; }