如何允许组件(单元测​​试一个)访问另一个组件的内部属性?组件、单元、属性

由网友(Mario 【马里奥】)分享简介:我想我的核心组件不会暴露一定的阶级,我仍然希望能够对其进行测试。我该怎么办呢?I would like my Core assembly to not expose a certain class and I would still like to be able to test it. How can I do t...

我想我的核心组件不会暴露一定的阶级,我仍然希望能够对其进行测试。我该怎么办呢?

I would like my Core assembly to not expose a certain class and I would still like to be able to test it. How can I do that ?

推荐答案

InternalsVisibleTo属性来救援!

再补充:

[assembly:InternalsVisibleToAttribute("UnitTestAssemblyName")]

你的核心类AssemblyInfo.cs文件

to your Core classes AssemblyInfo.cs file

请参阅朋友组件(C#编程指南)的最佳做法。

阅读全文

相关推荐

最新文章