当我尝试进行单元测试时,
我最终错误地声明'System.UriFormatException:无效的URI:指定的端口无效。' 显示错误的代码是
public Dictionary<SensorMode, Uri> ImageSrc = new Dictionary<SensorMode, Uri>()
{
{SensorMode.f, new Uri("pack://application:,,,/Resources/TS.png") },//towards to sensor image
{SensorMode.b, new Uri("pack://application:,,,/Resources/AS.png") },//away from the sensor image
{SensorMode.c, new Uri("pack://application:,,,/Resources/F.png") },//fast moving image
{SensorMode.p, new Uri("pack://application:,,,/Resources/S.png") },//slow moving image
{SensorMode.x, new Uri("pack://application:,,,/Resources/fail.png")}//fail image
};
任何人都可以帮我解决这个问题。
答案 0 :(得分:2)
那是因为您在pack://方案尚未注册时执行此代码。创建Application对象时会注册此方案。您可以在测试夹具的设置中添加此代码:
[SetUp]
public void OnTestInitialize()
{
UriParser.Register(new GenericUriParser(
GenericUriParserOptions.GenericAuthority), "pack", -1);
}