27
我試着寫了下面的TestCase一個NUnit測試寫在VB.net:如何將雙引號作爲參數轉義爲NUnit TestCase?
<TestCase("FirstNode", "<node id=\"FirstNode\">")>
Public Sub GetNode_GivenSomeNodeId_ReturnCorrectNode(ByVal nodeId as String,
ByVal expectedXml as String)
(Call the method under test and request the xmlNode with the provided id...)
Assert.AreEqual(expectedXml, returnedXml)
End Sub
的第二個參數的測試用例傳遞的XML節點無效但是,因爲這顯然是不正確的方法逃避雙引號。我相信我可以找到一種解決方法,以檢查待測試的方法是否返回了預期的XML節點,但我很好奇:
是否有一些聰明的方法來傳遞字符串,如this,它包含double引號,作爲一個NUnit測試的參數?
啊,就這麼簡單!衛生署! :) – Kjartan
我發現這實際上很奇怪,當在引號之間加一個+時的差別顯然很大,這樣做似乎不合邏輯,但是再次,vb.net中的更多東西不是邏輯的 –
或者使用Chr(34)如此: Chr(34)「)> –
Fuzzybear