문제

Using JustMock, can I arrange a mock to return something based on the input parameter?

For example, say a method takes in an int, I want to return that value + 1
I want the output to always be mocked as input+1 but I don't know the input at design time.

My real usage for this is with an object parameter and I need to mock to always return a new object having some of the same properties... but I do not know how to reference the parameters in the .Returns() section.

EDIT: More details:

Three types:
IMoneyConverter
Money
Currency

A Money object has two properties: decimal valueAmount and Currency valueCurrency

IMoneyConverter exposes:

.Convert(Money valueFrom, Currency currencyTo, DateTime asOfDate)

This method returns the converted Money object, in the new Currency (currencyTo) as of the specified date.

My intent is to mock the IMoneyConverter so that its .Convert method returns a new Money object having the amount of the Money (valueFrom) parameter and the Currency of the currencyTo parameter.

올바른 솔루션이 없습니다

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top