<commit_before>using System.Collections.Generic;
using System.Linq;
using NSubstitute;
using SIM.Sitecore9Installer.Tasks;
using SIM.Sitecore9Installer.Validation;
using SIM.Sitecore9Installer.Validation.Validators;
using Xunit;

namespace SIM.Sitecore9Installer.Tests.Validation.Validators
{
  public class SolrServiceValidatorTests
  {
    [Theory]
    [ClassData(typeof(ValidatorTestSetup))]
    public void ServiceIsStopped(IEnumerable<Task> tasks)
    {
      foreach (Task t in tasks)
      {
        t.LocalParams.AddOrUpdateParam("SolrUrl", "https://localhost:8983/solr", InstallParamType.String);
      }

      SolrServiceValidator val = Substitute.ForPartsOf<SolrServiceValidator>();
      val.Data["Solr"] = "SolrUrl";
      val.Data["Versions"] = "8.4.*";
      SolrStateResolver solrStateResolver = Substitute.ForPartsOf<SolrStateResolver>();
      solrStateResolver.GetServiceState(Arg.Any<string>()).ReturnsForAnyArgs(SolrState.CurrentState.Stopped);
      val.SolrStateResolver.Returns(solrStateResolver);
      IEnumerable<ValidationResult> res = val.Evaluate(tasks);
      Assert.Equal(2, res.Count(r => r.State == ValidatorState.Error));
    }

    [Theory]
    [ClassData(typeof(ValidatorTestSetup))]
    public void ServiceIsRunning(IEnumerable<Task> tasks)
    {
      foreach (Task t in tasks)
      {
        t.LocalParams.AddOrUpdateParam("SolrUrl", "https://localhost:8983/solr", InstallParamType.String);
      }

      SolrServiceValidator val = Substitute.ForPartsOf<SolrServiceValidator>();
      val.Data["Solr"] = "SolrUrl";
      val.Data["Versions"] = "8.1.*";
      SolrStateResolver solrStateResolver = Substitute.ForPartsOf<SolrStateResolver>();
      solrStateResolver.GetServiceState(Arg.Any<string>()).ReturnsForAnyArgs(SolrState.CurrentState.Running);
      val.SolrStateResolver.Returns(solrStateResolver);
      IEnumerable<ValidationResult> res = val.Evaluate(tasks);
      Assert.Equal(0, res.Count(r => r.State == ValidatorState.Error));
    }
  }<commit_msg>#645 Remove unnecessary code from SolrServiceValidatorTests<commit_after>using System.Collections.Generic;
using System.Linq;
using NSubstitute;
using SIM.Sitecore9Installer.Tasks;
using SIM.Sitecore9Installer.Validation;
using SIM.Sitecore9Installer.Validation.Validators;
using Xunit;

namespace SIM.Sitecore9Installer.Tests.Validation.Validators
{
  public class SolrServiceValidatorTests
  {
    [Theory]
    [ClassData(typeof(ValidatorTestSetup))]
    public void ServiceIsStopped(IEnumerable<Task> tasks)
    {
      foreach (Task t in tasks)
      {
        t.LocalParams.AddOrUpdateParam("SolrUrl", "https://localhost:8983/solr", InstallParamType.String);
      }

      SolrServiceValidator val = Substitute.ForPartsOf<SolrServiceValidator>();
      SolrStateResolver solrStateResolver = Substitute.ForPartsOf<SolrStateResolver>();
      solrStateResolver.GetServiceState(Arg.Any<string>()).ReturnsForAnyArgs(SolrState.CurrentState.Stopped);
      val.SolrStateResolver.Returns(solrStateResolver);
      IEnumerable<ValidationResult> res = val.Evaluate(tasks);
      Assert.Equal(2, res.Count(r => r.State == ValidatorState.Error));
    }

    [Theory]
    [ClassData(typeof(ValidatorTestSetup))]
    public void ServiceIsRunning(IEnumerable<Task> tasks)
    {
      foreach (Task t in tasks)
      {
        t.LocalParams.AddOrUpdateParam("SolrUrl", "https://localhost:8983/solr", InstallParamType.String);
      }

      SolrServiceValidator val = Substitute.ForPartsOf<SolrServiceValidator>();
      SolrStateResolver solrStateResolver = Substitute.ForPartsOf<SolrStateResolver>();
      solrStateResolver.GetServiceState(Arg.Any<string>()).ReturnsForAnyArgs(SolrState.CurrentState.Running);
      val.SolrStateResolver.Returns(solrStateResolver);
      IEnumerable<ValidationResult> res = val.Evaluate(tasks);
      Assert.Equal(0, res.Count(r => r.State == ValidatorState.Error));
    }
  }
{'fraction_non_alphanumeric': 0.11585677749360614, 'fraction_numerical': 0.008951406649616368, 'mean_word_length': 4.587142857142857, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 27, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3232278', 'n_tokens_mistral': 1225, 'n_tokens_neox': 1163, 'n_words': 167}