Frank:
Hi everyone, I wonder if anyone can help me with this. (I am a newbie in this list. If my problem is inappropriate, please forgive me .)
In shortTest-firstHow should we handle enumeration variables?
Since we should not meetRed TestWrite anyCode, What should I do in the following example?
Drink drink = new drink (drinktype. Cocktail );
Next, I should write the test and verification constructor:
[Test]
Public void test_constructor ()
{
Drink d = new drink (drinktype. Cocktail );
Assert. isnotnull (d );
}
However, should I write a test to test this enumeration parameter? What should I do?
Charlie:
You seem to have done something too fast. In fact, if it is me, I will first write a constructor like this:
Drink d = new drink ();
Of course, after a while, I may want to know the type of the drink, so I will write a test:
Assert. areequal ("Cocktail", D. drinktype );OrAssert. areequal (drinktype. Cocktail, D. drinktype );
This test obviously cannot pass compilation. I will write a little bit of code to let it pass:
Public String drinktype
{
Get {return "Cocktail ";}
}
The constructor is needed only when I encounter a new type of beverage.
As for testing the enumeration type, the enumeration type is only a declaration and does not contain real code. Therefore, you do not need to test it.