TDD와 관련하여이 자습서 http://blogs.telerik.com/justteam/posts/13-10-25/30-days-of-tdd-day-17-specifying-order-of-execution-in-mocks을 진행할 것입니다. Moq에 JustMock 문을 적용하려고합니다. 테스트가 실행되면다음 설정이 일치하지 않았습니다 - JustMock을 Moq로 변환
enter code here [Test]
public void testname()
{
var customerId = Guid.NewGuid();
var customerToReturn = new Customer { Id = customerId};
//JustCode
Mock _customerService = Mock.Create<ICustomerService>();
Mock.Arrange(() => _customerService.GetCustomer(customerId)).Returns(customer).OccursOnce();
//Moq
Mock<ICustomerService> _customerService = new Mock <ICustomerService>();
_customerService.Setup(os => os.GetCustomer(customerId)).Returns(customerToReturn);
_customerService.VerifyAll();
}
, 나는이 예외 얻을 : 나는 .Verify()에 .VerifyAll()를 변경하는 경우
Moq.MockVerificationException : The following setups were not matched:ICustomerService os => os.GetCustomer(a1a0d25c-e14a-4c68-ade9-bc3d7dd5c2bc)
이 테스트를 통과,하지만이 맞다면 내가 불확실 해요 .
질문 :이 코드를 적용하는 적절한 방법은 무엇입니까? .VerifyAll()은 .OccursOnce()와 유사하지 않습니까?
아래 답변이 도움이됩니까? – Spock
예, 두 가지 사례에 감사드립니다. – derguy