Maarkis / MeAgendaAi

0 stars 0 forks source link

Change all instantiated mocks to Automock. #4

Closed Maarkis closed 2 years ago

Maarkis commented 2 years ago

Refactor these types of examples:

_mockUserService = new Mock<IUserService>();
_mockPhysicalPersonRepository = new Mock<IPhysicalPersonRepository>();
_notificationContext = new NotificationContext();
_physicalPersonService = new PhysicalPersonService(_mockUserService.Object, _mockPhysicalPersonRepository.Object, _notificationContext);

for use by Moq.AutoMock;

_physicalPersonService = _mocker.CreateInstance<PhysicalPersonService>();

Setup example:

  _mocker.GetMock<IUserService>().Setup(method => method.HasUser(It.Is<string>(prop => prop == request.Email))).ReturnsAsync(false);

Verify example:

_mocker.GetMock<IUserService>().Verify(method => method.HasUser(It.Is<string>(prop => prop == request.Email), Times.Once()));