enum
を取得してに変換するSilverlightValueConverterがありBrush
ます。この単純化された例のようなもの:
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var brush = new SolidColorBrush(Colors.Blue);
var entryType = (EntryType)value;
if (entryType == EntryType.Hour)
brush.Color = Colors.Red;
return (brush);
}
これを単体テストしたい場合は、機能しません。この例外が発生します:
System.TypeInitializationException : The type initializer for 'MS.Internal.JoltHelper' threw an exception.
----> System.IO.FileNotFoundException : Could not load file or assembly 'System.Xml, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies.
at MS.Internal.JoltHelper.get_ThreadID()
at MS.Internal.XcpImports.CheckThread()
at System.Windows.DependencyObject..ctor(UInt32 nativeTypeIndex, IntPtr constructDO)
...
これは、(NUnit)単体テストで、Silverlightアプリケーションを実行するときとは異なるCLRが読み込まれるためです。単体テストでUIをテストするべきではないことはわかっていますが、これはValueConverterをテストしているだけなので、有効なテストだと思います。
誰かがこれがテスト可能かどうか、そしてどのようにテスト可能か知っていますか?