1

I have written the following code as my first test in nUnit.

Public Class Tests

    <TestFixture()>
      Private Class TranslationTest

          <Test()>
          Private Sub LanguageTest()
            Dim stringToTest As String = "Tower Count"

            strLanguageText(stringToTest, LanguageIDs.English, 0)
            Assert.Equals("Tower Count")


          End Sub
      End Class
    End Class

Intellisense is saying that both the strLanguageText method and the LanguageIDs.Enlish enum are "not accessible in this context because it is 'Public'". I can understand something not being accessible because its modifier is Private, but why would having a modifier of Public prevent it from being accessible by the test?

4

1 回答 1

2

尽管当我查看正在测试的方法时错误显示为“公共”,但它的修饰符是 Friend。当我将我的测试分配到与正在测试的方法相同的命名空间时,它起作用了。

更新:根据 O'Reilly 的C# & VB.NET Conversion Pocket Reference,“IL 级别的外部类只有两个可能的范围:私有或公共。”

我的猜测是,这就是错误报告为“公共”的原因。

于 2016-02-11T20:38:42.617 回答