title: Unit tests with FluentValidation. How to mock ValidationResult
body: <p>I'm using TDD approach with xUnit 2, NSubstitute, AutoFixture, FluentAssertions for my unit tests. </p>
  
  <p>I want test my service method which using FluentValidation. </p>
  
  <p>Simple example:</p>
  
  <p>Validator:</p>
  
  
  
  <pre class="lang-cs prettyprint-override"><code>RuleSet("Nulls", () =&gt;
          {
              RuleFor(viewModel =&gt; viewModel).NotNull();
          });
  </code></pre>
  
  <p>My service(under test): </p>
  
  <pre class="lang-cs prettyprint-override"><code>if(Validate(viewModel, "Nulls"))
  //....
  private bool Validate(AddMerchantViewModel viewModel, string option)
  {
      var result = _merchantValidator.Validate(viewModel, ruleSet: options);
      return result.IsValid;
  }
  </code></pre>
  
  <p>And my unit test:</p>
  
  <p>I don't know how to mock the <code>merchantValidator.Validate</code> result.</p>
  
  <pre class="lang-cs prettyprint-override"><code>[Theory, AutoNSubstituteData]
  public void Add_ViewModelAsNull_ShouldThrowArgumentNullException(
      AbstractValidator&lt;AddMerchantViewModel&gt; merchValidator,
      MerchantsService service)
  {
      // Arrange
  
  
      //here I don't know how to mock result of Validate. It is always null.
      merchantValidator.Validate(Arg.Any&lt;AddMerchantViewModel&gt;(), ruleSet: Arg.Any&lt;string&gt;()).Return(new ValidationResult()); 
  
  
  
      // Act
      Action action = () =&gt; service.Add(null);
  
      // Assert
      action.ShouldThrow&lt;ArgumentNullException&gt;();
  } 
  </code></pre>