Skip to content
This repository
Fetching contributors…

Cannot retrieve contributors at this time

file 70 lines (60 sloc) 2.435 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
using System.Configuration;
using MbUnit.Framework;
using Microsoft.Practices.Unity;
using SolrNet;
using Unity.SolrNetIntegration.Config;

namespace Unity.SolrNetIntegration.Tests {
[TestFixture]
    public class MultiCoreTests {
        private IUnityContainer container;

[SetUp]
        public void SetUp() {
            var solrConfig = (SolrConfigurationSection) ConfigurationManager.GetSection("solr");

            container = new UnityContainer();
            new SolrNetContainerConfiguration().ConfigureContainer(solrConfig.SolrServers, container);
        }

[TearDown]
        public void Teardown() {
            container.Dispose();
        }

[Test]
        public void Get_SolrOperations_for_Entity() {
            var solrOperations = container.Resolve<ISolrOperations<Entity>>();
            Assert.IsNotNull(solrOperations);
        }

[Test]
        public void Get_SolrOperations_for_Entity2() {
            var solrOperations2 = container.Resolve<ISolrOperations<Entity2>>();
            Assert.IsNotNull(solrOperations2);
        }

[Test]
        public void Get_named_SolrOperations_for_Entity() {
            var solrOperations = container.Resolve<ISolrOperations<Entity>>("entity");
            Assert.IsNotNull(solrOperations);
        }

[Test]
        public void Get_named_SolrOperations_for_Entity2() {
            var solrOperations2 = container.Resolve<ISolrOperations<Entity2>>("entity2");
            Assert.IsNotNull(solrOperations2);
        }

[Test]
        public void Same_document_type_different_core_url() {
            var cores = new SolrServers {
                new SolrServerElement {
                    Id = "core1",
                    DocumentType = typeof (Entity).AssemblyQualifiedName,
                    Url = "http://localhost:8983/solr/entity1",
                },
                new SolrServerElement {
                    Id = "core2",
                    DocumentType = typeof (Entity).AssemblyQualifiedName,
                    Url = "http://localhost:8983/solr/entity2",
                }
            };

            container = new UnityContainer();
            new SolrNetContainerConfiguration().ConfigureContainer(cores, container);
            var core1 = container.Resolve<ISolrOperations<Entity>>("core1");
            var core2 = container.Resolve<ISolrOperations<Entity>>("core2");
        }
    }
}
Something went wrong with that request. Please try again.