【发布时间】:2013-05-08 12:49:17
【问题描述】:
我有一个 Windows 应用商店应用程序 (C# + XAML),并想为它创建一些单元测试。 我在我的解决方案中为此创建了单元测试项目,默认测试方法工作正常。 然后我将我的项目添加为对单元测试项目的引用,并且测试停止工作:
------ Discover test started ------
========== Discover test finished: 1 found (0:00:00,8748072) ==========
------ Run test started ------
Updating the layout...
Copying files: Total 2 mb to layout...
Registering the application to run from layout...
Deployment complete. Full package name: "58d19822-a649-46ba-b3fd-36c60b2709d7_1.0.0.0_neutral__t4zwj4xd20b1w"
Failed to activate Windows Store app unit test executor. Error: The remote procedure call failed.
========== Run test finished: 0 run (0:00:05,0596667) ==========
我用谷歌搜索了很多,发现一个解释错误的线程可能在 App.xaml 中,实际上我可以追踪到这个 TextBlock:
<TextBlock Grid.ColumnSpan="2" controls:HighLightString.FullText="{Binding Path=FullName}" controls:HighLightString.SelectedText="{Binding DataContext.QueryText, ElementName=resultsPanel}" controls:HighLightString.FgColor="{StaticResource SAPHighlightColor}" Style="{StaticResource TileTitleTextStyle}" Margin="20,0,0,0" TextTrimming="WordEllipsis"/>
如果我将其更改为:
<TextBlock Grid.ColumnSpan="2" Text="{Binding Path=FullName}" Style="{StaticResource TileTitleTextStyle}" Margin="20,0,0,0" TextTrimming="WordEllipsis"/>
测试运行良好,但该文本块上不再有搜索突出显示。
我怎样才能同时拥有 - 搜索突出显示和在我的解决方案中运行单元测试?
【问题讨论】:
-
所以,我实际上在我的项目中遇到了同样的问题。您是否有任何其他具有相同属性名称的附加属性?似乎是“全文”。
-
我通过删除 app.xaml 中的文本块定义并将其放入搜索结果页面 xaml 定义中解决了我的问题。这样 app.xaml 就“干净”了,并且可以执行单元测试。
标签: c# windows xaml windows-store