public async Task GivenRepositoryResponse_WhenGetPayerInvoked_ThenCorrectPayerPayeeModelReturned() { var name = "name"; var externalId = "externalId"; var payerPayeeId = Guid.NewGuid(); var userId = Guid.NewGuid().ToString(); var expectedPayer = new PayerPayeeViewModel { ExternalId = externalId, PayerPayeeId = payerPayeeId, PayerPayeeName = name }; _mockCurrentUserContext.SetupGet(context => context.UserId).Returns(userId); _mockRepository.Setup(repository => repository.GetPayer(userId, payerPayeeId)) .ReturnsAsync(() => new PayerPayee { ExternalId = externalId, UserId = userId, PayerPayeeId = payerPayeeId.ToString(), PayerPayeeName = name }); var service = new PayerPayeeService(_mockCurrentUserContext.Object, _mockRepository.Object); var actualPayer = await service.GetPayer(payerPayeeId); Assert.Equal(expectedPayer, actualPayer); }
public async Task GivenValidIdAndUserContext_WhenGetPayerInvoked_ThenRepositoryCalledWithCorrectArguments() { var payerPayeeId = Guid.NewGuid(); var userId = Guid.NewGuid().ToString(); _mockRepository.Setup(repository => repository.GetPayer(userId, payerPayeeId)) .ReturnsAsync(() => new PayerPayee { ExternalId = "externalId", PayerPayeeId = Guid.NewGuid().ToString(), PayerPayeeName = "name" }); _mockCurrentUserContext.SetupGet(context => context.UserId).Returns(userId); var service = new PayerPayeeService(_mockCurrentUserContext.Object, _mockRepository.Object); await service.GetPayer(payerPayeeId); _mockRepository.Verify(repository => repository.GetPayer(userId, payerPayeeId)); }