你能在c#中编写一个单元测试程序来测试用VB编写的程序集吗?

时间:2022-09-13 21:07:43

Probably a dumb question, but can you write a unit test project in one language to test against another project in a different language?

可能是一个愚蠢的问题,但是你能用一种语言编写一个单元测试项目来用另一种语言测试另一个项目吗?

I'd like to translate one of our VB assemblies into C#, but want to build unit tests to verify the results. I've tried to set a unit test project up to do this, but I can't seem to access the VB code within a unit test... I can't figure out if I'm just missing/doing something stupid, or it really isn't allowed.

我想将一个VB程序集转换为c#,但是我想构建单元测试来验证结果。我尝试过设置一个单元测试项目来完成这个,但是我似乎无法在单元测试中访问VB代码……我不知道我是在错过/做一些愚蠢的事情,还是真的不允许。

EDIT: I'm going to close this as it seems I've gotten my "Yes, it's possible" answer... I am referencing it, so there's gotta be just something I'm not seeing.

编辑:我要把它关掉,因为看起来我已经得到了“是的,这是可能的”答案……我在引用它,所以肯定有一些我没看到的东西。

2 个解决方案

#1


6  

Once you add a reference to your original project or assembly in your unit test project, you should be able to write a unit test without problems, assuming the members you want to test are public. (You can add an InternalsVisibleTo assembly attribute in the original assembly if you need access to classes marked internal).

如果您在单元测试项目中添加了对原始项目或程序集的引用,那么您应该能够编写一个没有问题的单元测试,假设您想要测试的成员是公共的。(如果需要访问标记为内部的类,可以在原始程序集中添加InternalsVisibleTo程序集属性)。

#2


1  

Reference the vb.net assembly or project in the test project, you'll have access to all public classes and members.

在测试项目中引用vb.net程序集或项目,您将可以访问所有公共类和成员。

#1


6  

Once you add a reference to your original project or assembly in your unit test project, you should be able to write a unit test without problems, assuming the members you want to test are public. (You can add an InternalsVisibleTo assembly attribute in the original assembly if you need access to classes marked internal).

如果您在单元测试项目中添加了对原始项目或程序集的引用,那么您应该能够编写一个没有问题的单元测试,假设您想要测试的成员是公共的。(如果需要访问标记为内部的类,可以在原始程序集中添加InternalsVisibleTo程序集属性)。

#2


1  

Reference the vb.net assembly or project in the test project, you'll have access to all public classes and members.

在测试项目中引用vb.net程序集或项目,您将可以访问所有公共类和成员。