3
การปลอมตัวเป็นส่วนหนึ่งของชั้นเรียนภายใต้การทดสอบหรือไม่?
สมมติว่าฉันมีชั้นเรียน (ยกโทษให้ตัวอย่างที่ออกแบบและการออกแบบที่ไม่ดีของมัน): class MyProfit { public decimal GetNewYorkRevenue(); public decimal GetNewYorkExpenses(); public decimal GetNewYorkProfit(); public decimal GetMiamiRevenue(); public decimal GetMiamiExpenses(); public decimal GetMiamiProfit(); public bool BothCitiesProfitable(); } (หมายเหตุเมธอด GetxxxRevenue () และ GetxxxExpenses () มีการขึ้นต่อกันที่ถูกสตับออก) ตอนนี้ฉันกำลังทดสอบหน่วย BothCitiesProfitable () ซึ่งขึ้นอยู่กับ GetNewYorkProfit () และ GetMiamiProfit () การรับ GetNewYorkProfit () และ GetMiamiProfit () ดีไหม …