forked from SolrNet/SolrNet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add netstandard 2.0 support to Autofac intregration
- Loading branch information
Showing
14 changed files
with
221 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using Autofac; | ||
using Microsoft.Extensions.Configuration; | ||
using SolrNet; | ||
using SolrNet.Impl; | ||
using Xunit; | ||
|
||
namespace AutofacContrib.SolrNet.Tests | ||
{ | ||
public class AutofacConfigFixture | ||
{ | ||
|
||
[Fact] | ||
public void RegistersSolrConnectionWithCoresJsonServerUrl() | ||
{ | ||
var configuration = new ConfigurationBuilder() | ||
.SetBasePath(Directory.GetParent("../../../").FullName) | ||
.AddJsonFile("cores.json") | ||
.Build() | ||
.GetSection("solr:servers"); | ||
|
||
var builder = new ContainerBuilder(); | ||
builder.RegisterModule(new SolrNetModule(configuration.Get<List<SolrServer>>())); | ||
var container = builder.Build(); | ||
var solrConnection = (SolrConnection)container.ResolveNamed<ISolrConnection>("entitySolrNet.Impl.SolrConnection"); | ||
|
||
Assert.Equal("http://localhost:8983/solr/collection1", solrConnection.ServerURL); | ||
} | ||
|
||
|
||
[Fact] | ||
public void CheckParseJsonConfiguration() | ||
{ | ||
var configuration = new ConfigurationBuilder() | ||
.SetBasePath(Directory.GetParent("../../../").FullName) | ||
.AddJsonFile("cores.json") | ||
.Build() | ||
.GetSection("solr:servers"); | ||
|
||
var servers = configuration.Get<List<SolrServer>>(); | ||
|
||
Assert.Equal(3, servers.Count); | ||
Assert.Equal("entity", servers.First().Id); | ||
Assert.Equal("http://localhost:8983/solr/collection1", servers.First().Url); | ||
Assert.Equal("AutofacContrib.SolrNet.Tests.Entity, AutofacContrib.SolrNet.Tests", servers.First().DocumentType); | ||
|
||
Assert.Equal("entity3", servers.Last().Id); | ||
Assert.Equal("http://localhost:8983/solr/core1", servers.Last().Url); | ||
Assert.Equal("AutofacContrib.SolrNet.Tests.Entity2, AutofacContrib.SolrNet.Tests", servers.Last().DocumentType); | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"solr": { | ||
"servers": [ | ||
{ | ||
"id": "entity", | ||
"url": "http://localhost:8983/solr/collection1", | ||
"documentType": "AutofacContrib.SolrNet.Tests.Entity, AutofacContrib.SolrNet.Tests" | ||
}, | ||
{ | ||
"id": "entity2", | ||
"url": "http://localhost:8983/solr/core0", | ||
"documentType": "AutofacContrib.SolrNet.Tests.Entity2, AutofacContrib.SolrNet.Tests" | ||
}, | ||
{ | ||
"id": "entity3", | ||
"url": "http://localhost:8983/solr/core1", | ||
"documentType": "AutofacContrib.SolrNet.Tests.Entity2, AutofacContrib.SolrNet.Tests" | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,4 @@ public SolrServers SolrServers | |
get { return (SolrServers)base[""]; } | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace AutofacContrib.SolrNet | ||
{ | ||
public interface ISolrServer | ||
{ | ||
string Id { get; set; } | ||
string Url { get; set; } | ||
string DocumentType { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace AutofacContrib.SolrNet | ||
{ | ||
public class RegistrationException : ApplicationException | ||
{ | ||
public RegistrationException(string message, Exception innerException) : base(message, innerException) { } | ||
public RegistrationException(string message) : base(message) {} | ||
} | ||
} |
Oops, something went wrong.