をモック私は、部品番号のための次のセットアップを持っている:テストメソッドを実行している場合MOQ - 辞書<文字列、ダブル>オブジェクト
... 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);
、私はarguementとしてbigMoqに渡します。
次作品:
bigMoqVar.ComplexityWeights["COMPLEX"] // correctly returns 6
しかし、これにはない:
bigMoqVar.ComplexityWeights.ContainsKey("COMPLEX") // returns false instead of true
innerMoq上にContainsKeyを支援するための推奨方法は何ですか?
「Dictionary」を使用してみませんか? –
driis