.Net에서 모의 테스트를 처음 사용했습니다.
나는 다음과 같은 성격 인 금융 거래 밖으로 테스트입니다 : 내가 아는
모의 객체 속성이 변경되지 않음
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)
를이 제대로 작동하지만 테스트에 문제가 tranx 기능. 은 거기에 당신이 SetupGet을 수행 할 때 "이 속성, 항상 반환이 값을 호출 할 때"당신은 본질적으로 말하는 때문에 닷넷
어떻게 조롱합니까? 그리고 어떤 프레임 워크를 사용합니까? – driis
어떤 프레임 워크를 사용하고 있습니까? 그리고 모의 설치 코드를 포함시킬 수 있습니까? –
조롱을 위해 Moq.Mock을 사용하고 있습니다. 모의 설치 코드는 다음과 같습니다. var financeAccount = new 모의(); financeAccount.SetupGet (x => x.Id). 반환 (id); financeAccount.SetupGet (x => x.Name). 반품 ("A"); financeAccount.Setup (x => x.Validate()). 반환 (true); 꽤 많은 param 설정이 있지만 GetFinanceAccount() 설정 방법에 amt 속성이 설정되어 있지 않습니다.
– frictionlesspulley