조롱 I MOQ에 대해 다음 설정이 있습니다MOQ -하여 Dictionary <문자열 두 번> 객체
... other code to setup bigMoq object ...
var innerMoq = new Mock<IDictionary<string, double>>();
innerMoq.SetupGet(d => d["COMPLEX"]).Returns(6d);
innerMoq.SetupGet(d => d["MEDIUM"]).Returns(8d);
innerMoq.SetupGet(d => d["SIMPLE"]).Returns(10d);
bigMoq.SetupGet(d => d.ComplexityWeights).Returns(x.Object);
시험 방법을 실행, 나는 아규먼트로 bigMoq 전달합니다.
다음 작품 :
bigMoqVar.ComplexityWeights["COMPLEX"] // correctly returns 6
그러나이하지 않는 :
bigMoqVar.ComplexityWeights.ContainsKey("COMPLEX") // returns false instead of true
innerMoq에 ContainsKey을 지원하기 위해 권장되는 방법은 무엇입니까?
'Dictionary'을 사용하지 않는 이유는 무엇입니까? –
driis