【发布时间】:2015-04-22 02:28:57
【问题描述】:
public class CoffeeStrengthEstimator
{
/// <summary>
/// Estimates the strength of the coffee (how many beans to use) depending on the button pressed
/// </summary>
/// <param name="buttonPressed"> The numeral position of the button pressed</param>
/// <returns>An enum value indicating the estimated coffee strength</returns>
public CoffeeStrength EstimateCoffeeStrength(int buttonPressed)
{
if (buttonPressed == 1)
{
return CoffeeStrength.Light;
}
else if (buttonPressed == 2)
{
return CoffeeStrength.Medium;
}
else if (buttonPressed == 3)
{
return CoffeeStrength.Strong;
}
else
{
throw new ArgumentException ("Invalid Button press, please try again");
}
}
}
public enum CoffeeStrength
{
Light,
Medium,
Strong
}
===> 写个单元测试来测试上面的方法可以吗;并使用仅采用 2 个参数的方法创建 CoffeeMaker 类的新对象和 Coffee 类的对象?
【问题讨论】:
-
你的问题到底是什么?
标签: c# unit-testing