执行单元测试时,我在模拟方法时犯了一个错误。我试图根据要输入的参数返回不同的结果,否则返回默认答案。问题是我总是收到默认答案。
_commonFunctionsMock.Expects.AtLeastOne.Method(x => x.GetFeePrice("", false, null))
.WithAnyArguments().WillReturn(-1);
_commonFunctionsMock.Expects.AtLeastOne.Method(x => x.GetFeePrice("",false,null))
.With("BAG1", true, FamilyFaresType.Optima).WillReturn(0);
_commonFunctionsMock.Expects.AtLeastOne.Method(x => x.GetFeePrice("", false, null))
.With("BAG2", true, FamilyFaresType.Optima).WillReturn(87);
_commonFunctionsMock.Expects.AtLeastOne.Method(x => x.GetFeePrice("", false, null))
.With("BAG3", true, FamilyFaresType.Optima).WillReturn(139);