I am new to using Mock test in .Net.
I am testing out a financial transaction which is of the following nature:
int amt =20;
//sets all the props and func and returns a FinaceAccount.
//Note I did not SetUp the amt of the account.
var account =GetFinanceAccount()
//service layer to be tested
_financeService.tranx(account,amt);
//checks if the amt was added to the account.amt
//here the amt comes out same as that set in GetFinanceAccount.
Assert.AreEqual(account.amt ,amt)
I know that the function tranx works correctly but there is an issue with the test.
Are there any GOOD reference material on Mocking in .Net
This happens because, when you do SetupGet, you are essentially saying “When invoking this property, always return this value”. What you want to do is probably “SetupProperty”, which makes all properties on the mocked object behave as normal properties with get/set behaviour.