Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Finishing up unit tests. 291 passing
  • Loading branch information
arobson committed Jun 23, 2010
1 parent 67ddd65 commit a33ad0c
Show file tree
Hide file tree
Showing 24 changed files with 728 additions and 13 deletions.
36 changes: 36 additions & 0 deletions src/CouchDBIndexService/Class1.cs
@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Relax;
using Relax.Lucene;
using Symbiote.Core;
using Symbiote.Daemon;
using Symbiote.Log4Net;
using Symbiote.Lucene;
using Symbiote.Restfully;

namespace CouchDBIndexService
{
class Program
{
static void Main(string[] args)
{
Assimilate
.Core()
.Relax(x => x.UseDefaults().Preauthorize("admin", "p@ssw0rd"))
.Lucene(x => x.UseDefaults())
.RelaxLuceneService(x => x.UseDefaults().IndexDatabase("post"))
.HttpServiceHost(x => x.UseDefaults().HostService<IRelaxQueryService>())
.Dependencies(x => x.For<IRelaxQueryService>().Use<RelaxQueryService>())
.Daemon(x => x
.Name("Relax.Lucene")
.DisplayName("Relax Lucene Service")
.Description("A Lucene indexing and query service for CouchDB")
.Arguments(args)
)
.AddConsoleLogger<RelaxIndexingService>(x => x.Info().MessageLayout(p => p.TimeStamp().Message()))
.RunDaemon();
}
}
}
97 changes: 97 additions & 0 deletions src/CouchDBIndexService/CouchDBIndexService.csproj
@@ -0,0 +1,97 @@
<?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>{681B03FD-66ED-48D8-8C14-EC49452CDBDC}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CouchDBIndexService</RootNamespace>
<AssemblyName>CouchDBIndexService</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\bin\</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>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net">
<HintPath>..\..\lib\log4net.dll</HintPath>
</Reference>
<Reference Include="Lucene.Net">
<HintPath>..\..\lib\Lucene.Net.dll</HintPath>
</Reference>
<Reference Include="StructureMap, Version=2.5.4.0, Culture=neutral, PublicKeyToken=e60ad81abae3c223, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\StructureMap.dll</HintPath>
</Reference>
<Reference Include="Symbiote.Core, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\Symbiote.Core.dll</HintPath>
</Reference>
<Reference Include="Symbiote.Daemon">
<HintPath>..\..\lib\Symbiote.Daemon.dll</HintPath>
</Reference>
<Reference Include="Symbiote.Log4Net">
<HintPath>..\..\lib\Symbiote.Log4Net.dll</HintPath>
</Reference>
<Reference Include="Symbiote.Lucene">
<HintPath>..\..\lib\Symbiote.Lucene.dll</HintPath>
</Reference>
<Reference Include="Symbiote.Restfully, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\Symbiote.Restfully.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="Topshelf">
<HintPath>..\..\lib\Topshelf.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Class1.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Relax.Lucene\Relax.Lucene.csproj">
<Project>{EAC2B6B2-8F3C-49A8-88B0-DA6CC04C4935}</Project>
<Name>Relax.Lucene</Name>
</ProjectReference>
<ProjectReference Include="..\Relax\Relax.csproj">
<Project>{3A8D40A3-96F9-4878-902E-7CBC3A82AEDD}</Project>
<Name>Relax</Name>
</ProjectReference>
</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>
36 changes: 36 additions & 0 deletions src/CouchDBIndexService/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("CouchDBIndexService")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("CouchDBIndexService")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("d8cec351-e25d-4e3c-90d3-9b44ed264fa8")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
2 changes: 1 addition & 1 deletion src/Relax.Lucene/Relax.Lucene.csproj
Expand Up @@ -17,7 +17,7 @@
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath> <OutputPath>..\..\bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
Expand Down
12 changes: 12 additions & 0 deletions src/Relax.sln
Expand Up @@ -13,6 +13,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Relax.Lucene.Tests", "..\te
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Relax.Overflow", "..\demo\Relax.Overflow\Relax.Overflow.csproj", "{03875D45-98AB-4C98-B569-A8A9EE16252D}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Relax.Overflow", "..\demo\Relax.Overflow\Relax.Overflow.csproj", "{03875D45-98AB-4C98-B569-A8A9EE16252D}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CouchDBIndexService", "CouchDBIndexService\CouchDBIndexService.csproj", "{681B03FD-66ED-48D8-8C14-EC49452CDBDC}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -84,6 +86,16 @@ Global
{03875D45-98AB-4C98-B569-A8A9EE16252D}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {03875D45-98AB-4C98-B569-A8A9EE16252D}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{03875D45-98AB-4C98-B569-A8A9EE16252D}.Release|Mixed Platforms.Build.0 = Release|Any CPU {03875D45-98AB-4C98-B569-A8A9EE16252D}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{03875D45-98AB-4C98-B569-A8A9EE16252D}.Release|x86.ActiveCfg = Release|Any CPU {03875D45-98AB-4C98-B569-A8A9EE16252D}.Release|x86.ActiveCfg = Release|Any CPU
{681B03FD-66ED-48D8-8C14-EC49452CDBDC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{681B03FD-66ED-48D8-8C14-EC49452CDBDC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{681B03FD-66ED-48D8-8C14-EC49452CDBDC}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{681B03FD-66ED-48D8-8C14-EC49452CDBDC}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{681B03FD-66ED-48D8-8C14-EC49452CDBDC}.Debug|x86.ActiveCfg = Debug|Any CPU
{681B03FD-66ED-48D8-8C14-EC49452CDBDC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{681B03FD-66ED-48D8-8C14-EC49452CDBDC}.Release|Any CPU.Build.0 = Release|Any CPU
{681B03FD-66ED-48D8-8C14-EC49452CDBDC}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{681B03FD-66ED-48D8-8C14-EC49452CDBDC}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{681B03FD-66ED-48D8-8C14-EC49452CDBDC}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
Expand Down
41 changes: 41 additions & 0 deletions tests/Commands/GettingDocuments/when_getting_all_documents.cs
@@ -0,0 +1,41 @@
using System;
using System.Linq;
using Machine.Specifications;
using Relax.Impl.Commands;
using Relax.Impl.Json;

namespace Relax.Tests.Commands
{
public class when_getting_all_documents : with_get_all_docs
{
protected static CommandResult result;
protected static ViewResult<TestDoc> viewResult;
protected static string json;

private Because of = () =>
{
result = command.GetDocuments<TestDoc>();
viewResult = result.GetResultAs<ViewResult<TestDoc>>();
json = result.Json.Replace("\r\n", "").Replace(" ", "");
};

private It should_produce_expected_json = () => json.ShouldEqual(response);

private It should_have_two_rows = () => ShouldExtensionMethods.ShouldEqual(viewResult.GetList().Count(), 2);

private It should_create_valid_instances = () =>
{
var firstDoc = viewResult.GetList().ToList()[0];
firstDoc.DocumentId.ShouldEqual("1");
firstDoc.DocumentRevision.ShouldEqual("1");
firstDoc.Message.ShouldEqual("Test1");
var secondDoc = viewResult.GetList().ToList()[1];
secondDoc.DocumentId.ShouldEqual("2");
secondDoc.DocumentRevision.ShouldEqual("1");
secondDoc.Message.ShouldEqual("Test2");
};

private It should_call_action = () => mockAction.Verify();
}
}
@@ -0,0 +1,40 @@
using System.Linq;
using Machine.Specifications;
using Relax.Impl.Commands;
using Relax.Impl.Json;

namespace Relax.Tests.Commands
{
public class when_getting_all_documents_by_ids : with_get_all_docs_by_ids
{
protected static CommandResult result;
protected static ViewResult<TestDoc> viewResult;
protected static string json;

private Because of = () =>
{
result = command.GetDocuments<TestDoc>(new object[] {"1","2"});
viewResult = result.GetResultAs<ViewResult<TestDoc>>();
json = result.Json.Replace("\r\n", "").Replace(" ", "");
};

private It should_produce_expected_json = () => json.ShouldEqual(response);

private It should_have_two_rows = () => ShouldExtensionMethods.ShouldEqual(viewResult.GetList().Count(), 2);

private It should_create_valid_instances = () =>
{
var firstDoc = viewResult.GetList().ToList()[0];
firstDoc.DocumentId.ShouldEqual("1");
firstDoc.DocumentRevision.ShouldEqual("1");
firstDoc.Message.ShouldEqual("Test1");
var secondDoc = viewResult.GetList().ToList()[1];
secondDoc.DocumentId.ShouldEqual("2");
secondDoc.DocumentRevision.ShouldEqual("1");
secondDoc.Message.ShouldEqual("Test2");
};

private It should_call_action = () => mockAction.Verify();
}
}
@@ -0,0 +1,40 @@
using System.Linq;
using Machine.Specifications;
using Relax.Impl.Commands;
using Relax.Impl.Json;

namespace Relax.Tests.Commands
{
public class when_getting_all_documents_paged : with_get_docs_paged
{
protected static CommandResult result;
protected static ViewResult<TestDoc> viewResult;
protected static string json;

private Because of = () =>
{
result = command.GetDocumentsPaged<TestDoc>(2, 3);
viewResult = result.GetResultAs<ViewResult<TestDoc>>();
json = result.Json.Replace("\r\n", "").Replace(" ", "");
};

private It should_produce_expected_json = () => json.ShouldEqual(response);

private It should_have_two_rows = () => ShouldExtensionMethods.ShouldEqual(viewResult.GetList().Count(), 2);

private It should_create_valid_instances = () =>
{
var firstDoc = viewResult.GetList().ToList()[0];
firstDoc.DocumentId.ShouldEqual("1");
firstDoc.DocumentRevision.ShouldEqual("1");
firstDoc.Message.ShouldEqual("Test1");
var secondDoc = viewResult.GetList().ToList()[1];
secondDoc.DocumentId.ShouldEqual("2");
secondDoc.DocumentRevision.ShouldEqual("1");
secondDoc.Message.ShouldEqual("Test2");
};

private It should_call_action = () => mockAction.Verify();
}
}
34 changes: 34 additions & 0 deletions tests/Commands/GettingDocuments/when_getting_doc_by_id.cs
@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Machine.Specifications;
using Relax.Impl.Commands;
using It = Machine.Specifications.It;

namespace Relax.Tests.Commands
{
public class when_getting_doc_by_id : with_get_doc_by_id_setup
{
protected static CommandResult result;
protected static TestDoc model;
protected static string json;

private Because of = () =>
{
result = command.GetDocument<TestDoc>("1");
model = result.GetResultAs<TestDoc>();
json = result.Json.Replace("\r\n", "").Replace(" ", "");
};

private It should_produce_expected_json = () => json.ShouldEqual(response);

private It should_create_valid_instance = () =>
{
model.DocumentId.ShouldEqual("1");
model.DocumentRevision.ShouldEqual("1");
model.Message.ShouldEqual("Test");
};
private It should_call_action = () => mockAction.Verify();
}
}

0 comments on commit a33ad0c

Please sign in to comment.