單元測試是確保代碼質量的核心手段,通過隔離測試目標代碼(System Under Test, SUT),驗證其邏輯正確性。結合Mock框架(如Moq)可以模擬外部依賴,使測試更可控、更高效。 1. xUnit/NUnit基礎:單元測試框架 1.1 xUnit與NUnit對比
題目 Given a 2D arrayA, each cell is 0 (representing sea) or 1 (representing land) A move consists of walking from one land square 4-directionally to another land square, or off the bound