eX0*_*du5 3 c# windows xaml windows-store
我有一个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) ==========
Run Code Online (Sandbox Code Playgroud)
我google了很多,发现一个解释错误的线程可能在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"/>
Run Code Online (Sandbox Code Playgroud)
如果我将其更改为:
<TextBlock Grid.ColumnSpan="2" Text="{Binding Path=FullName}" Style="{StaticResource TileTitleTextStyle}" Margin="20,0,0,0" TextTrimming="WordEllipsis"/>
Run Code Online (Sandbox Code Playgroud)
测试运行正常但我不再在该文本块上有搜索突出显示.
我怎样才能同时拥有 - 我的解决方案中的搜索亮点和运行单元测试?
这可能与https://connect.microsoft.com/VisualStudio/feedback/details/790477/winrt-mstest-runner-fails-when-using-ilist-t-properties-of-custom-types-from-xaml有关
据我所知,在Xaml中使用一些自定义类型与WinRT单元测试运行器不兼容,因为在某些情况下,它不提供正确的IXamlType接口实现.
因此,您正在使用的这些可附加属性可能会导致测试运行器为它们提供不正确的元数据.(无法确定您的HighLightString课程,但很难确定.但您可以通过打开单元测试项目的混合模式调试并调试测试来验证是否是这种情况.配置Visual Studio以打破所有CLR异常抛出(并且不仅仅是在未处理的情况下),并且如果你最终NotImplementedException在一个叫做的类型中遇到(可能在其他一些例外之后),RunTimeXamlSystemBaseType那么这就是你遇到的问题.)
我过去曾经通过避免将相关类型放入我的工作中来解决这个问题App.xaml.如果您尝试加载相关的Xaml,则只会遇到此问题.(如果你真的需要这些东西当然在全球范围内,那就没什么用了.)
| 归档时间: |
|
| 查看次数: |
1504 次 |
| 最近记录: |