Skip to content

Commit 1bef9d9

Browse files
committed
test: add test code for issue #1152
1 parent 66f71e4 commit 1bef9d9

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

Fluent.Ribbon.Showcase/TestContent.xaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3588,6 +3588,9 @@
35883588
</GroupBox>
35893589
<GroupBox Header="Issue repros">
35903590
<WrapPanel>
3591+
<WrapPanel.Resources>
3592+
<Fluent:ObjectToImageConverter x:Key="StringToImageConvert"/>
3593+
</WrapPanel.Resources>
35913594
<Fluent:Button x:Name="SleepButton"
35923595
VerticalAlignment="Top"
35933596
Click="SleepButton_OnClick"
@@ -3602,6 +3605,13 @@
36023605
Change theme from thread
36033606
</Fluent:Button>
36043607

3608+
<Fluent:Button VerticalAlignment="Top"
3609+
Tag="/Images/Blue.png"
3610+
Icon="{Binding Path=Tag,RelativeSource={RelativeSource Self},Converter={StaticResource StringToImageConvert}}"
3611+
Size="Middle">
3612+
ObjectToImageConverter for issue #1152
3613+
</Fluent:Button>
3614+
36053615
<GroupBox Header="KeyTip issues #254">
36063616
<StackPanel Orientation="Vertical">
36073617
<formsInterop:WindowsFormsHost>

Fluent.Ribbon.Tests/Converters/ObjectToImageConverterTests.cs

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,35 @@ public void TestDynamicResource()
4141
Assert.That(drawingGroup.Children.Cast<GeometryDrawing>().Select(x => x.Geometry.ToString()),
4242
Is.EquivalentTo(((DrawingGroup)((DrawingImage)Application.Current.FindResource(fluentRibbonImagesApplicationmenuResourceKey)).Drawing).Children.Cast<GeometryDrawing>().Select(x => x.Geometry.ToString())));
4343
}
44-
}
44+
45+
private class DummyProvider : IServiceProvider
46+
{
47+
object IServiceProvider.GetService(Type serviceType)
48+
{
49+
return null;
50+
}
51+
}
52+
53+
[Test]
54+
public void TestStaticResourceSequnece()
55+
{
56+
var fluentRibbonImagesApplicationmenuResourceKey = (object)"Fluent.Ribbon.Images.ApplicationMenu";
57+
58+
var expressionType = typeof(ResourceReferenceExpressionConverter).Assembly.GetType("System.Windows.ResourceReferenceExpression");
59+
60+
var expression = Activator.CreateInstance(expressionType, fluentRibbonImagesApplicationmenuResourceKey);
61+
62+
var converter = new ObjectToImageConverter();
63+
64+
converter.ProvideValue(new DummyProvider());
65+
66+
var convertedValue = StaticConverters.ObjectToImageConverter.Convert(new object[]
67+
{
68+
expression, // value to convert
69+
new ApplicationMenu() // target visual
70+
}, null, null, null);
71+
72+
Assert.That(convertedValue, Is.Not.Null);
73+
Assert.That(convertedValue, Is.InstanceOf<Image>());
74+
}
75+
}

0 commit comments

Comments
 (0)