我有以下代码,我是单元测试。
public static void Log(string appName, string message)
{
Log(appName, message, string.Empty);
}
public static void Log(string Name, string Message, string Source)
{
if (!baselogger.Initialize) return;
TryInitialize();
Count++;
foreach (ILogging logger in loggers)
{
logWrite(1000);
logger.WriteError(Name, Message, Source);
}
string message = string.Format(CultureInfo.InvariantCulture, "{0}: {1}: {2}", Name, Message, Source);
System.Diagnostics.Trace.WriteLine(message);
}
我在下面写了一些测试方法来测试它。
[TestMethod]
public void LogWith2Params()
{
Logging.Log("Host","Control not found.");
}
[TestMethod]
public void LogWith3Params()
{
Logging.Log("Host","Control not found.","ManageAccounts");
}
上述两项测试是否足够,还是需要编写新的测试用例?或者我应该通过传递3个参数来编写另一个测试方法,并为logger.initialize属性,TryInitialize方法调用,logWrite方法调用,logger.WriteError方法调用和Trace.Writeline方法调用执行shim?