@@ -668,31 +668,52 @@ public void AddBrushAsResource()
668668 }
669669
670670 [ Test ]
671- public void AddStringAsResource ( )
671+ public void AddNativeTypeAsResource ( object component , string expectedXamlValue )
672672 {
673673 DesignItem textBlock = CreateCanvasContext ( "<TextBlock/>" ) ;
674674 DesignItem canvas = textBlock . Parent ;
675675
676676 DesignItemProperty canvasResources = canvas . Properties . GetProperty ( "Resources" ) ;
677677
678- DesignItem str = canvas . Services . Component . RegisterComponentForDesigner ( "stringresource 1" ) ;
679- str . Key = "str1 " ;
678+ DesignItem componentItem = canvas . Services . Component . RegisterComponentForDesigner ( component ) ;
679+ componentItem . Key = "res1 " ;
680680
681681 Assert . IsTrue ( canvasResources . IsCollection ) ;
682- canvasResources . CollectionElements . Add ( str ) ;
682+ canvasResources . CollectionElements . Add ( componentItem ) ;
683+
684+ DesignItemProperty prop = textBlock . Properties [ TextBlock . TagProperty ] ;
685+ prop . SetValue ( new StaticResourceExtension ( ) ) ;
686+ prop . Value . Properties [ "ResourceKey" ] . SetValue ( "res1" ) ;
683687
684- textBlock . Properties [ TextBlock . TextProperty ] . SetValue ( new StaticResourceExtension ( ) ) ;
685- DesignItemProperty prop = textBlock . Properties [ TextBlock . TextProperty ] ;
686- prop . Value . Properties [ "ResourceKey" ] . SetValue ( "str1" ) ;
688+ string typeName = component . GetType ( ) . Name ;
687689
688690 string expectedXaml = "<Canvas.Resources>\n " +
689- " <Controls0:String x:Key=\" str1 \" >stringresource 1 </Controls0:String >\n " +
691+ " <Controls0:" + typeName + " x:Key=\" res1 \" >" + expectedXamlValue + " </Controls0:" + typeName + " >\n " +
690692 "</Canvas.Resources>\n " +
691- "<TextBlock Text =\" {StaticResource ResourceKey=str1 }\" />" ;
693+ "<TextBlock Tag =\" {StaticResource ResourceKey=res1 }\" />" ;
692694
693695 AssertCanvasDesignerOutput ( expectedXaml , textBlock . Context , "xmlns:Controls0=\" clr-namespace:System;assembly=mscorlib\" " ) ;
694696 AssertLog ( "" ) ;
695697 }
698+
699+ [ Test ]
700+ public void AddStringAsResource ( )
701+ {
702+ AddNativeTypeAsResource ( "stringresource 1" , "stringresource 1" ) ;
703+ }
704+
705+ [ Test ]
706+ public void AddDoubleAsResource ( )
707+ {
708+ AddNativeTypeAsResource ( 0.0123456789d , "0.0123456789" ) ;
709+ }
710+
711+ [ Test ]
712+ public void AddInt32AsResource ( )
713+ {
714+ const int i = 123 ;
715+ AddNativeTypeAsResource ( i , "123" ) ;
716+ }
696717 }
697718
698719 public class MyMultiConverter : IMultiValueConverter
0 commit comments