I read in FsUnit that the following are valid method/classnames in 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
Is there a way to have method or classnames like this in c#?
No, you cannot have spaces or punctuation in a C# method name. You can do:
[TestMethod]
public void When_Asked_Whether_It_Is_On_It_Answers_True() {}
My preferred method of naming tests does not include underscores at all.
For example,
[Test]
public void SomeMethodShouldCallServiceManagerWithTheCorrectParameters()
With that said, consistency is key. There is no penalty for having a method name as long as you want it. So if you prefer to separate words with underscores, then go for it.
Ian
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With