[英]How to Unit Test in F# using dictionary
having problems unable to figure out why I can execute this code in f# unit testing 遇到无法弄清为什么我可以在f#单元测试中执行此代码的问题
// testing the dictionary method
let callStatus = dict[
"busy", "Monday";
"quite", "Tuesday";
"okay", "Friday";
"ok", "Wednesday";
]
Assert.AreEqual(("Wednesday",callStatus.['ok']))
the Error I am getting is Unmatched '[' which does not make sense as the same code in Console application works fine. 我收到的错误是Unmatched'[',这没有意义,因为控制台应用程序中的相同代码可以正常工作。
any support would be appreciated. 任何支持,将不胜感激。
Not sure how but it appears by replacing the '' single quote marks with "" the error disappears 不确定如何,但是通过将“”替换为“”,错误消失了
// testing the dictionary method
let `` testing diction `` () =
let callStatus = dict[
"busy", "Monday";
"quite", "Tuesday";
"okay", "Friday";
"ok", "Wednesday";
]
Assert.AreEqual("Wednesday",callStatus.["ok"])
if someone can double check that I am correct, I would really appreciate this as I am a newbie. 如果有人可以再次确认我是正确的话,那么我将是我的新手,我将不胜感激。
Is this line correct: 这行是正确的:
Assert.AreEqual(("Wednesday",callStatus.['ok']))
Shouldn't it be 不是吗
Assert.AreEqual("Wednesday",callStatus.["ok"])
UPDATE: 更新:
Added double quotes as well. 还添加了双引号。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.