Tôi có dưới đây TestMethod
Tôi đang thử nghiệm với VS 2013 và tôi đang sử dụng Microsoft Fakes.Cách phân tích XMLDocument trong VS 2013 bằng Microsoft Fakes
[TestMethod]
public void ConstructorTestForCMAClass()
{
XmlDocument doc = new XmlDocument();
doc.LoadXml("<add name=\"console\" type=\"System.Diagnostics.DefaultTraceCMA\" value=\"Error\"/>");
XmlAttributeCollection attrColl = doc.DocumentElement.Attributes;
CMATracer cMATracer = new CMATracer(attrColl);
}
Đối với trên TestMethod
Nếu tôi phải sử dụng Stub, làm thế nào nó nên được modfied và đó sẽ là một thực hành tốt để sử dụng stub thay vì XMLDocument
?
Tôi đã thử điều này nhưng không chắc chắn nếu điều này là đủ hay không.
StubXmlDocument stubXmlDocument = new StubXmlDocument();
stubXmlDocument.LoadXml("<add name=\"console\" type=\"System.Diagnostics.DefaultTraceCMA\" value=\"Error\"/>");
//create a stub attribute collection
XmlAttributeCollection attrCollection = stubXmlDocument.DocumentElement.Attributes;
CMATracer cMATracer = new CMATracer(attrColl);
Có vẻ như lớp học của bạn đang được kiểm tra (CMATracer) sử dụng XmlAttributeCollection để bạn bị nhạo nhầm. xin vui lòng thêm việc thực hiện C'tor của CMATracer. –