안녕하세요 저는 단위 테스트에서 새로운 오전 및이 지역화 단위 테스트 메서드를 작성하고 있지만 예상 된 값이 될지 잘 모르겠습니다.단위 테스트에서 예상되는 값은 무엇입니까
public void GetStringResourceTest()
{
string language = "English"; // TODO: Initialize to an appropriate value
string name = "John Smith"; // TODO: Initialize to an appropriate value
string expected = language; // TODO:" Initialize to an appropriate value
string actual;
actual = Localization.GetStringResource(language, name);
Assert.AreEqual(expected, actual);
}
: 여기
public override object GetValue(string section, string entry)
{
VerifyAndAdjustSection(ref section);
VerifyAndAdjustEntry(ref entry);
try
{
//XmlDocument doc = GetXmlDocument();
XmlElement root = doc.DocumentElement;
XmlNode entryNode = root.SelectSingleNode(GetSectionsPath(section) + "/" + GetEntryPath(entry));
return entryNode.InnerText;
}
catch { return null; }
}
내 미완성 시험 방법 : 여기
public static string GetStringResource(string language, string name)
{
Localization cfg = GetInstance();
try
{
if (cfg != null && cfg._config != null)
return cfg._config.GetValue(language, name).ToString();
return string.Empty;
}
catch { return string.Format("Localization Error: '{0}:{1}' Not Found.", language, name); }
}
은을 getValue 함수이다 : 여기
테스트 할 기능이며
먼저 언어는 무엇입니까? 둘째,이 코드 블록의 동작을 모르는 경우 전체 낯선 사람이 왜 기대할 수 있습니까? 단위 테스트를 작성하는 것은 특정 입력에 대한 테스트 동작에 관한 것입니다. – Makoto