c#中可读的良好可读名称

Nil*_*ils 3 c# f# unit-testing naming

我在FsUnit中读到以下是F#中有效的方法/类名:

[<TestFixture>] 
type ``Given a LightBulb that has had its state set to true`` ()=
   let lightBulb = new LightBulb(true)

   [<Test>] member test.
    ``when I ask whether it is On it answers true.`` ()=
       lightBulb.On |> should be True
Run Code Online (Sandbox Code Playgroud)

有没有办法在c#中使用这样的方法或类名?

dri*_*iis 6

不,您不能在C#方法名称中包含空格或标点符号.你可以做:

[TestMethod]
public void When_Asked_Whether_It_Is_On_It_Answers_True() {}
Run Code Online (Sandbox Code Playgroud)

  • 为什么没有测试报告工具通过用空格替换下划线来显示测试名称? (2认同)