Skip to content

Commit

Permalink
Moved SolrNet integration tests to separate project.
Browse files Browse the repository at this point in the history
Moved integration tests for each IOC component into their own classes.
Consistent naming of test fixtures.
  • Loading branch information
Stephen Pope committed Dec 26, 2012
1 parent 27ccc49 commit 25f6dc5
Show file tree
Hide file tree
Showing 25 changed files with 776 additions and 565 deletions.
159 changes: 80 additions & 79 deletions AutofacContrib.SolrNet.Tests/AutofacContrib.SolrNet.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,86 +1,87 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{77E47E7C-2CEE-406A-B344-9699DA0F1851}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>AutofacContrib.SolrNet.Tests</RootNamespace>
<AssemblyName>AutofacContrib.SolrNet.Tests</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup Condition="$(TargetFrameworkVersion)=='v4.0'">
<Reference Include="Autofac">
<HintPath>..\lib\NET-4.0\Autofac.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup Condition="$(TargetFrameworkVersion)!='v4.0'">
<Reference Include="Autofac">
<HintPath>..\lib\Autofac.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Reference Include="Gallio, Version=3.3.0.0, Culture=neutral, PublicKeyToken=eb9cfa67ee6ab36e, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\lib\Gallio.dll</HintPath>
</Reference>
<Reference Include="MbUnit, Version=3.3.0.0, Culture=neutral, PublicKeyToken=eb9cfa67ee6ab36e, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\lib\MbUnit.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.configuration" />
</ItemGroup>
<ItemGroup>
<Compile Include="AutofacMulticoreTests.cs" />
<Compile Include="AutofacTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AutofacContrib.SolrNet\AutofacContrib.SolrNet.csproj">
<Project>{931CEB14-556F-4893-A8D9-C7C6DACA444F}</Project>
<Name>AutofacContrib.SolrNet</Name>
</ProjectReference>
<ProjectReference Include="..\SolrNet.Tests\SolrNet.Tests.csproj">
<Project>{F3FE6EF5-CF5C-4461-8691-4A498A463FD5}</Project>
<Name>SolrNet.Tests</Name>
</ProjectReference>
<ProjectReference Include="..\SolrNet\SolrNet.csproj">
<Project>{CEEB8690-3E08-4440-B647-787A58E71CFA}</Project>
<Name>SolrNet</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{77E47E7C-2CEE-406A-B344-9699DA0F1851}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>AutofacContrib.SolrNet.Tests</RootNamespace>
<AssemblyName>AutofacContrib.SolrNet.Tests</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup Condition="$(TargetFrameworkVersion)=='v4.0'">
<Reference Include="Autofac">
<HintPath>..\lib\NET-4.0\Autofac.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup Condition="$(TargetFrameworkVersion)!='v4.0'">
<Reference Include="Autofac">
<HintPath>..\lib\Autofac.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Reference Include="Gallio, Version=3.3.0.0, Culture=neutral, PublicKeyToken=eb9cfa67ee6ab36e, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\lib\Gallio.dll</HintPath>
</Reference>
<Reference Include="MbUnit, Version=3.3.0.0, Culture=neutral, PublicKeyToken=eb9cfa67ee6ab36e, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\lib\MbUnit.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.configuration" />
</ItemGroup>
<ItemGroup>
<Compile Include="AutofacIntegrationFixture.cs" />
<Compile Include="AutofacMulticoreFixture.cs" />
<Compile Include="AutofacFixture.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AutofacContrib.SolrNet\AutofacContrib.SolrNet.csproj">
<Project>{931CEB14-556F-4893-A8D9-C7C6DACA444F}</Project>
<Name>AutofacContrib.SolrNet</Name>
</ProjectReference>
<ProjectReference Include="..\SolrNet.Tests\SolrNet.Tests.csproj">
<Project>{F3FE6EF5-CF5C-4461-8691-4A498A463FD5}</Project>
<Name>SolrNet.Tests</Name>
</ProjectReference>
<ProjectReference Include="..\SolrNet\SolrNet.csproj">
<Project>{CEEB8690-3E08-4440-B647-787A58E71CFA}</Project>
<Name>SolrNet</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
-->
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,7 @@

namespace AutofacContrib.SolrNet.Tests {
[TestFixture]
public class AutofacTests {
[Test]
[Category("Integration")]
public void Ping_And_Query() {
var builder = new ContainerBuilder();
builder.RegisterModule(new SolrNetModule("http://localhost:8983/solr"));
var container = builder.Build();
var solr = container.Resolve<ISolrOperations<Entity>>();
solr.Ping();
Console.WriteLine(solr.Query(SolrQuery.All).Count);
}

public class AutofacFixture {
[Test]
public void ReplaceMapper() {
var builder = new ContainerBuilder();
Expand Down Expand Up @@ -97,40 +86,6 @@ public void DictionaryDocument_Serializer()
Assert.IsInstanceOfType<SolrDictionarySerializer>(serializer);
}

[Test]
[Category("Integration")]
public void DictionaryDocument()
{
var builder = new ContainerBuilder();
builder.RegisterModule(new SolrNetModule("http://localhost:8983/solr"));
var container = builder.Build();
var solr = container.Resolve<ISolrOperations<Dictionary<string, object>>>();
var results = solr.Query(SolrQuery.All);
Assert.GreaterThan(results.Count, 0);
foreach (var d in results)
{
Assert.GreaterThan(d.Count, 0);
foreach (var kv in d)
Console.WriteLine("{0}: {1}", kv.Key, kv.Value);
}
}

[Test]
[Category("Integration")]
public void DictionaryDocument_add()
{
var builder = new ContainerBuilder();
builder.RegisterModule(new SolrNetModule("http://localhost:8983/solr"));
var container = builder.Build();
var solr = container.Resolve<ISolrOperations<Dictionary<string, object>>>();
solr.Add(new Dictionary<string, object> {
{"id", "ababa"},
{"manu", "who knows"},
{"popularity", 55},
{"timestamp", DateTime.UtcNow},
});
}

public class Entity {}
}
}
56 changes: 56 additions & 0 deletions AutofacContrib.SolrNet.Tests/AutofacIntegrationFixture.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
//

using System;
using System.Collections.Generic;
using Autofac;
using MbUnit.Framework;
using SolrNet;

namespace AutofacContrib.SolrNet.Tests {
[TestFixture]
[Category("Integration")]
public class AutofacIntegrationFixture {
[Test]
public void Ping_And_Query()
{
var builder = new ContainerBuilder();
builder.RegisterModule(new SolrNetModule("http://localhost:8983/solr"));
var container = builder.Build();
var solr = container.Resolve<ISolrOperations<AutofacFixture.Entity>>();
solr.Ping();
Console.WriteLine(solr.Query(SolrQuery.All).Count);
}

[Test]
public void DictionaryDocument()
{
var builder = new ContainerBuilder();
builder.RegisterModule(new SolrNetModule("http://localhost:8983/solr"));
var container = builder.Build();
var solr = container.Resolve<ISolrOperations<Dictionary<string, object>>>();
var results = solr.Query(SolrQuery.All);
Assert.GreaterThan(results.Count, 0);
foreach (var d in results)
{
Assert.GreaterThan(d.Count, 0);
foreach (var kv in d)
Console.WriteLine("{0}: {1}", kv.Key, kv.Value);
}
}

[Test]
public void DictionaryDocument_add()
{
var builder = new ContainerBuilder();
builder.RegisterModule(new SolrNetModule("http://localhost:8983/solr"));
var container = builder.Build();
var solr = container.Resolve<ISolrOperations<Dictionary<string, object>>>();
solr.Add(new Dictionary<string, object> {
{"id", "ababa"},
{"manu", "who knows"},
{"popularity", 55},
{"timestamp", DateTime.UtcNow},
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
namespace AutofacContrib.SolrNet.Tests
{
[TestFixture]
public class AutofacMulticoreTests
public class AutofacMulticoreFixture
{
[Test]
public void ResolveSolrOperations()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Tests.cs" />
<Compile Include="CastleIntegrationFixture.cs" />
<Compile Include="CastleFixture.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

namespace Castle.Facilities.SolrNetIntegration.Tests {
[TestFixture]
public class Tests {
public class CastleFixture {
[Test]
[ExpectedException(typeof(FacilityException))]
public void NoConfig_throws() {
Expand Down Expand Up @@ -62,21 +62,6 @@ public void InvalidProtocol_throws() {
new WindsorContainer(configStore);
}

[Test]
[Category("Integration")]
public void Ping_Query() {
var configStore = new DefaultConfigurationStore();
var configuration = new MutableConfiguration("facility");
configuration.Attribute("type", typeof(SolrNetFacility).AssemblyQualifiedName);
configuration.CreateChild("solrURL", "http://localhost:8983/solr");
configStore.AddFacilityConfiguration(typeof(SolrNetFacility).FullName, configuration);
var container = new WindsorContainer(configStore);

var solr = container.Resolve<ISolrOperations<Document>>();
solr.Ping();
Console.WriteLine(solr.Query(SolrQuery.All).Count);
}

[Test]
public void ReplacingMapper() {
var mapper = new MReadOnlyMappingManager();
Expand Down Expand Up @@ -174,15 +159,15 @@ public void AddCoreFromXML() {
<solrURL>http://localhost:8983/solr/defaultCore</solrURL>
<cores>
<core id='core0-id'>
<documentType>Castle.Facilities.SolrNetIntegration.Tests.Tests+Document, Castle.Facilities.SolrNetIntegration.Tests</documentType>
<documentType>Castle.Facilities.SolrNetIntegration.Tests.CastleFixture+Document, Castle.Facilities.SolrNetIntegration.Tests</documentType>
<url>http://localhost:8983/solr/core0</url>
</core>
<core id='core1-id'>
<documentType>Castle.Facilities.SolrNetIntegration.Tests.Tests+Document, Castle.Facilities.SolrNetIntegration.Tests</documentType>
<documentType>Castle.Facilities.SolrNetIntegration.Tests.CastleFixture+Document, Castle.Facilities.SolrNetIntegration.Tests</documentType>
<url>http://localhost:8983/solr/core1</url>
</core>
<core id='core2-id'>
<documentType>Castle.Facilities.SolrNetIntegration.Tests.Tests+Core1Entity, Castle.Facilities.SolrNetIntegration.Tests</documentType>
<documentType>Castle.Facilities.SolrNetIntegration.Tests.CastleFixture+Core1Entity, Castle.Facilities.SolrNetIntegration.Tests</documentType>
<url>http://localhost:8983/solr/core1</url>
</core>
</cores>
Expand Down Expand Up @@ -210,36 +195,7 @@ public void TestCores(IWindsorContainer container) {
Assert.IsInstanceOfType<ISolrOperations<Core1Entity>>(container.Resolve<ISolrOperations<Core1Entity>>("core2-id"));
}

[Test]
[Category("Integration")]
public void DictionaryDocument() {
var solrFacility = new SolrNetFacility("http://localhost:8983/solr");
var container = new WindsorContainer();
container.AddFacility("solr", solrFacility);
var solr = container.Resolve<ISolrOperations<Dictionary<string, object>>>();
var results = solr.Query(SolrQuery.All);
Assert.GreaterThan(results.Count, 0);
foreach (var d in results) {
Assert.GreaterThan(d.Count, 0);
foreach (var kv in d)
Console.WriteLine("{0}: {1}", kv.Key, kv.Value);
}
}

[Test]
[Category("Integration")]
public void DictionaryDocument_add() {
var solrFacility = new SolrNetFacility("http://localhost:8983/solr");
var container = new WindsorContainer();
container.AddFacility("solr", solrFacility);
var solr = container.Resolve<ISolrOperations<Dictionary<string, object>>>();
solr.Add(new Dictionary<string, object> {
{"id", "ababa"},
{"manu", "who knows"},
{"popularity", 55},
{"timestamp", DateTime.UtcNow},
});
}

[Test]
public void DictionaryDocument_Operations() {
Expand Down
Loading

0 comments on commit 25f6dc5

Please sign in to comment.