public void Setup() { var solrConnection = new Mock <ISolrConnection>(); solrConnection.Setup(q => q.Get(new SecurityOptions(), It.IsAny <string>(), It.IsAny <string>())).Returns("json"); var engine = new MockEngine(); engine.Setup(q => q.GetService <ISolrConnection>()).Returns(solrConnection.Object); engine.Setup(q => q.GetService <IOffsetParameter <TestDocument> >()).Returns(new Mock <IOffsetParameter <TestDocument> >().Object); engine.Setup(q => q.GetService <ILimitParameter <TestDocument> >()).Returns(new Mock <ILimitParameter <TestDocument> >().Object); engine.Setup(q => q.GetService <ISystemParameter <TestDocument> >()).Returns(new Mock <ISystemParameter <TestDocument> >().Object); engine.Setup(q => q.GetService <ISearchParameterCollection <TestDocument> >()).Returns(new Mock <ISearchParameterCollection <TestDocument> >().Object); var options = new DocumentCollectionOptions <TestDocument>(); var parameters = new List <ISearchItem>(); for (int i = 0; i < this.ElementsCount; i++) { var parameterMock = new Mock <ISearchParameter>(); parameterMock.Setup(q => q.AllowMultipleInstances).Returns(true); parameters.Add(parameterMock.Object); } _solrSearch = new SolrSearch <TestDocument>(options, engine.Object); parameters.ForEach(item => _solrSearch.Add(item)); }
/// <summary> /// Default constructor of class /// </summary> /// <param name="options">SolrExpress options</param> /// <param name="engine">Services container</param> public SolrSearch(DocumentCollectionOptions <TDocument> options, IEngine engine) { Checker.IsNull(options); Checker.IsNull(engine); this.Options = options; this.Engine = engine; }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { var options = new DocumentCollectionOptions <TechProduct> { CheckAnyParameter = true, FailFast = true }; services.AddSolrExpress <TechProduct>(builder => builder .UseOptions(options) .UseHostAddress("http://localhost:8983/solr/techproducts") .UseSolr5()); services.AddMvc(); }
public void SolrSearch003() { // Arrange var validate = new Mock <IValidation>(); var parameter = validate.As <ISearchParameter>(); var documentCollectionOptions = new DocumentCollectionOptions <TestDocument> { FailFast = false }; var queryable = (ISolrSearch <TestDocument>) new SolrSearch <TestDocument>(documentCollectionOptions, this._engine.Object); bool isValid; string errorMessage; // Act queryable.Add(parameter.Object); // Assert validate.Verify(q => q.Validate(out isValid, out errorMessage), Times.Never); }
/// <summary> /// Default constructor of class /// </summary> public IntegrationTests() { var options = new DocumentCollectionOptions <TechProductDocument> { FailFast = false }; #if NETCORE var serviceCollection = new ServiceCollection(); serviceCollection.AddSolrExpress <TechProductDocument>(builder => builder .UseOptions(options) .UseHostAddress("http://localhost:8983/solr/collection1") .UseSolr4()); this._serviceProvider = serviceCollection.BuildServiceProvider(); #else this._documentCollectionBuilder = new DocumentCollectionBuilder <TechProductDocument>() .AddSolrExpress() .UseOptions(options) .UseHostAddress("http://localhost:8983/solr/collection1") .UseSolr4(); #endif }