我注意到为了单元测试面向对象代码中的每个单元,我需要将访问修饰符设置为public,即使是应该是protected或private的方法。这样做是否正确?
public class EnforceBusinessRules
{
BusinessState m_state;
public EnforceBusinessRules()
{
m_state = START;
}
public bool isInputcurrentlyFormatted(string input)
{
//code goes here to ensure the input passes formatting test
//modify m_state appropriately
}
public bool InputContainsValidStartAndEndTokens(string input)
{
//code goes here to ensure that the start and end tokens of the input are of the type available in the system
//modify m_state appropriately
}
public bool StartEndCommandisValidAccordingtoCurrentSystemSettings(string input)
{
//code goes here to check the start and End codes match the current start and end codes for the day
//modify m_state appropriately
}
// and so on
}