Skip to content

Commit 8143549

Browse files
committed
Add stubs, and add storage test
1 parent 3cb45f0 commit 8143549

File tree

15 files changed

+2729
-58
lines changed

15 files changed

+2729
-58
lines changed

IntegrationEngine.Client/IntegrationEngine.Client.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
<ErrorReport>prompt</ErrorReport>
2121
<WarningLevel>4</WarningLevel>
2222
<ConsolePause>false</ConsolePause>
23-
<DocumentationFile>
24-
</DocumentationFile>
2523
</PropertyGroup>
2624
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
2725
<DebugType>full</DebugType>
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProjectGuid>{04E1E96C-7FDD-426C-BF60-6B45820ED1E5}</ProjectGuid>
7+
<OutputType>Library</OutputType>
8+
<RootNamespace>IntegrationEngine.Core.Tests</RootNamespace>
9+
<AssemblyName>IntegrationEngine.Core.Tests</AssemblyName>
10+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
11+
</PropertyGroup>
12+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
13+
<DebugSymbols>true</DebugSymbols>
14+
<DebugType>full</DebugType>
15+
<Optimize>false</Optimize>
16+
<OutputPath>bin\Debug</OutputPath>
17+
<DefineConstants>DEBUG;</DefineConstants>
18+
<ErrorReport>prompt</ErrorReport>
19+
<WarningLevel>4</WarningLevel>
20+
<ConsolePause>false</ConsolePause>
21+
</PropertyGroup>
22+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
23+
<DebugType>full</DebugType>
24+
<Optimize>true</Optimize>
25+
<OutputPath>bin\Release</OutputPath>
26+
<ErrorReport>prompt</ErrorReport>
27+
<WarningLevel>4</WarningLevel>
28+
<ConsolePause>false</ConsolePause>
29+
</PropertyGroup>
30+
<ItemGroup>
31+
<Reference Include="System" />
32+
<Reference Include="nunit.framework">
33+
<HintPath>..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
34+
</Reference>
35+
<Reference Include="BeekmanLabs.UnitTesting">
36+
<HintPath>..\packages\BeekmanLabs.UnitTesting.0.0.0\lib\net45\BeekmanLabs.UnitTesting.dll</HintPath>
37+
</Reference>
38+
<Reference Include="Moq">
39+
<HintPath>..\packages\Moq.4.2.1409.1722\lib\net40\Moq.dll</HintPath>
40+
</Reference>
41+
<Reference Include="Elasticsearch.Net">
42+
<HintPath>..\packages\Elasticsearch.Net.1.4.0\lib\net45\Elasticsearch.Net.dll</HintPath>
43+
</Reference>
44+
<Reference Include="Newtonsoft.Json">
45+
<HintPath>..\packages\Newtonsoft.Json.6.0.6\lib\net45\Newtonsoft.Json.dll</HintPath>
46+
</Reference>
47+
<Reference Include="Nest">
48+
<HintPath>..\packages\NEST.1.4.0\lib\net45\Nest.dll</HintPath>
49+
</Reference>
50+
</ItemGroup>
51+
<ItemGroup>
52+
<Compile Include="Properties\AssemblyInfo.cs" />
53+
<Compile Include="Storage\ElasticsearchRepositoryTest.cs" />
54+
<Compile Include="StubElasticClient.cs" />
55+
<Compile Include="StubSearchResponse.cs" />
56+
<Compile Include="StubHit.cs" />
57+
</ItemGroup>
58+
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
59+
<ItemGroup>
60+
<ProjectReference Include="..\IntegrationEngine.Core\IntegrationEngine.Core.csproj">
61+
<Project>{3F3794D7-4078-4D26-954C-7864173EDD86}</Project>
62+
<Name>IntegrationEngine.Core</Name>
63+
</ProjectReference>
64+
<ProjectReference Include="..\IntegrationEngine.Model\IntegrationEngine.Model.csproj">
65+
<Project>{0B499FE4-0BDB-4080-BCB7-F8D4CE54A4FF}</Project>
66+
<Name>IntegrationEngine.Model</Name>
67+
</ProjectReference>
68+
</ItemGroup>
69+
<ItemGroup>
70+
<Folder Include="Storage\" />
71+
</ItemGroup>
72+
<ItemGroup>
73+
<None Include="packages.config" />
74+
</ItemGroup>
75+
</Project>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
4+
// Information about this assembly is defined by the following attributes.
5+
// Change them to the values specific to your project.
6+
7+
[assembly: AssemblyTitle("IntegrationEngine.Core.Tests")]
8+
[assembly: AssemblyDescription("")]
9+
[assembly: AssemblyConfiguration("")]
10+
[assembly: AssemblyCompany("")]
11+
[assembly: AssemblyProduct("")]
12+
[assembly: AssemblyCopyright("ethanhann")]
13+
[assembly: AssemblyTrademark("")]
14+
[assembly: AssemblyCulture("")]
15+
16+
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
17+
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
18+
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
19+
20+
[assembly: AssemblyVersion("1.0.*")]
21+
22+
// The following attributes are used to specify the signing key for the assembly,
23+
// if desired. See the Mono documentation for more information about signing.
24+
25+
//[assembly: AssemblyDelaySign(false)]
26+
//[assembly: AssemblyKeyFile("")]
27+
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using BeekmanLabs.UnitTesting;
2+
using IntegrationEngine.Core.Storage;
3+
using IntegrationEngine.Model;
4+
using Moq;
5+
using Nest;
6+
using NUnit.Framework;
7+
using System;
8+
using System.Linq;
9+
using System.Collections.Generic;
10+
11+
namespace IntegrationEngine.Core.Tests.Storage
12+
{
13+
public class ElasticsearchRepositoryTest : TestBase<ElasticsearchRepository>
14+
{
15+
[Test]
16+
public void ShouldReturnListOfDocumentsWithIdsFromElasticsearch()
17+
{
18+
var elasticClient = new Mock<StubElasticClient>();
19+
var searchResponse = new Mock<StubSearchResponse<CronTrigger>>();
20+
var hits = new List<IHit<CronTrigger>>();
21+
var cronTrigger = new CronTrigger();
22+
var hit = new Mock<StubHit<CronTrigger>>();
23+
var expectedId = "1";
24+
hit.SetupGet(x => x.Source).Returns(() => cronTrigger);
25+
hit.SetupGet(x => x.Id).Returns(() => expectedId);
26+
hits.Add(hit.Object);
27+
searchResponse.SetupGet(x => x.Hits).Returns(() => hits);
28+
elasticClient.Setup(x => x.Search<CronTrigger>(It.IsAny<Func<SearchDescriptor<CronTrigger>, SearchDescriptor<CronTrigger>>>()))
29+
.Returns(searchResponse.Object);
30+
Subject.ElasticClient = elasticClient.Object;
31+
32+
var actual = Subject.SelectAll<CronTrigger>();
33+
34+
Assert.That(actual, Is.Not.Empty);
35+
Assert.That(actual.First().Id, Is.EqualTo(expectedId));
36+
}
37+
}
38+
}

0 commit comments

Comments
 (0)