我有以下方法,我想對其執行單元測試。可以對方法簽名進行更改:如何使用C#測試此方法
public void PrintNumber()
{
Enumerable.Range(1, 100).ToList().ForEach(x =>
{
if (x % 3 == 0 && x % 5 == 0)
Console.WriteLine("[35]");
else if (x % 3 == 0)
Console.WriteLine("[3]");
else if (x % 5 == 0)
Console.WriteLine("[5]");
else
Console.WriteLine(x.ToString());
});
}
我有我自己的解決方案,但我想知道我的版本是否最好。
謝謝!
你想讓我們爲你寫測試嗎?你有什麼嘗試? – Amy
因爲它已經寫好了,所以你不能真的TDD這個方法;在TDD中,你先寫測試。然而你可以爲它編寫一個單元測試。 –
你是什麼意思,TDD測試? –