Summary
This post contains notes on how to verify a method was not called or called with Moq.
Overview
To verify that a method was not called with Moq.
1 2 3 4 5 6 | Mock<SomeRepository> _someRepository;
_someRepository = new Mock<ISomeRepository>();
TestContainer.RegisterInstance(_someRepository.Object);
_someRepository.Verify(s => s.SomeMethod(), Times.Never());
|
To verify that a method was called once with Moq.
1 2 3 4 5 6 | Mock<SomeRepository> _someRepository;
_someRepository = new Mock<ISomeRepository>();
TestContainer.RegisterInstance(_someRepository.Object);
_someRepository.Verify(s => s.SomeMethod(), Times.Once());
|
No comments:
Post a Comment