public async Task ThenIfTheRequestIsValidThenTheRepositoryIsCalled() { //Arrange var request = new VerifyRelationshipCommand { EmployerAccountId = 1, ProviderId = 2, LegalEntityId = "L3", Verified = true }; _validator.Setup(x => x.Validate(It.IsAny <VerifyRelationshipCommand>())).Returns(new ValidationResult()); //Act await _handler.Handle(request); //Assert _repository.Verify(x => x.VerifyRelationship( It.Is <long>(y => y == 1), It.Is <long>(y => y == 2), It.Is <string>(y => y == "L3"), It.Is <bool>(y => y == true)), Times.Once); }
public void ThenVerifiedIsMandatory() { //Arrange var request = new VerifyRelationshipCommand(); //Act var result = _validator.Validate(request); //Assert Assert.IsFalse(result.IsValid); Assert.IsTrue(result.Errors.Any(e => e.PropertyName == "Verified")); }
public void ThenRequestIsValidIfAllFieldsAreProvided() { //Arrange var request = new VerifyRelationshipCommand { EmployerAccountId = 1, ProviderId = 2, LegalEntityId = "L3", UserId = "User", Verified = true }; //Act var result = _validator.Validate(request); //Assert Assert.IsTrue(result.IsValid); }
public void ThenIfTheRequestIsNotValidThenTheRepositoryIsNotCalled() { //Arrange var request = new VerifyRelationshipCommand(); _validator.Setup(x => x.Validate(It.IsAny <VerifyRelationshipCommand>())) .Returns(new ValidationResult { Errors = { new ValidationFailure("Test", "Test Error") } }); //Act & Assert Assert.ThrowsAsync <ValidationException>(() => _handler.Handle(request) ); _repository.Verify(x => x.VerifyRelationship( It.IsAny <long>(), It.IsAny <long>(), It.IsAny <string>(), It.IsAny <bool>()), Times.Never); }