Skip to content

Commit 437c273

Browse files
committed
Add some client lib tests
1 parent 9431b83 commit 437c273

File tree

6 files changed

+158
-1
lines changed

6 files changed

+158
-1
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using BeekmanLabs.UnitTesting;
2+
using NUnit.Framework;
3+
using Moq;
4+
using RestSharp;
5+
using System;
6+
using System.Net;
7+
8+
namespace IntegrationEngine.Client.Tests
9+
{
10+
public class InEngineClientTest : TestBase<InEngineClient>
11+
{
12+
[Test]
13+
public void ShouldInstantiateWithDefaultApiUrl()
14+
{
15+
var expected = "http://localhost:9001/api/";
16+
17+
var actual = Subject.ApiUrl;
18+
19+
Assert.That(actual.AbsoluteUri, Is.EqualTo(expected));
20+
}
21+
22+
[Test]
23+
public void ShouldQueryTheHealthStatusEndpointAndReturnStatusCodeWhenPinging()
24+
{
25+
var mockRestClient = new Mock<IRestClient>();
26+
var restResponse = new RestResponse() { StatusCode = HttpStatusCode.OK};
27+
mockRestClient.Setup(x => x.Execute(It.Is<RestRequest>(y => y.Resource == EndpointName.HealthStatus)))
28+
.Returns(restResponse);
29+
Subject.RestClient = mockRestClient.Object;
30+
31+
var actual = Subject.Ping();
32+
33+
mockRestClient.Verify(x => x.Execute(It.Is<RestRequest>(y => y.Resource == EndpointName.HealthStatus)), Times.Once);
34+
Assert.That(actual, Is.TypeOf(typeof(HttpStatusCode)));
35+
}
36+
}
37+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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>{8F491136-6C38-4A8E-BFEA-9234FB981414}</ProjectGuid>
7+
<OutputType>Library</OutputType>
8+
<RootNamespace>IntegrationEngine.Client.Tests</RootNamespace>
9+
<AssemblyName>IntegrationEngine.Client.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="RestSharp">
42+
<HintPath>..\packages\RestSharp.105.0.1\lib\net4\RestSharp.dll</HintPath>
43+
</Reference>
44+
<Reference Include="Newtonsoft.Json">
45+
<HintPath>..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
46+
</Reference>
47+
</ItemGroup>
48+
<ItemGroup>
49+
<Compile Include="Properties\AssemblyInfo.cs" />
50+
<Compile Include="InEngineClientTest.cs" />
51+
</ItemGroup>
52+
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
53+
<ItemGroup>
54+
<None Include="packages.config" />
55+
</ItemGroup>
56+
<ItemGroup>
57+
<ProjectReference Include="..\IntegrationEngine.Client\IntegrationEngine.Client.csproj">
58+
<Project>{F3FCB706-F0DD-46C1-B121-785757FAE9B9}</Project>
59+
<Name>IntegrationEngine.Client</Name>
60+
</ProjectReference>
61+
</ItemGroup>
62+
</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.Client.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: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="BeekmanLabs.UnitTesting" version="0.0.0" targetFramework="net45" />
4+
<package id="Moq" version="4.2.1409.1722" targetFramework="net45" />
5+
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" />
6+
<package id="NUnit" version="2.6.4" targetFramework="net45" />
7+
<package id="RestSharp" version="105.0.1" targetFramework="net45" />
8+
</packages>

IntegrationEngine.Client/InEngineClient.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,16 @@ public class InEngineClient : IInEngineClient
1818
/// Gets or sets the rest client.
1919
/// </summary>
2020
/// <value>The rest client.</value>
21-
public RestClient RestClient { get; set; }
21+
public IRestClient RestClient { get; set; }
22+
23+
/// <summary>
24+
/// Gets or sets the API URL.
25+
/// </summary>
26+
/// <value>The API URL.</value>
27+
public Uri ApiUrl {
28+
get { return RestClient.BaseUrl; }
29+
set { RestClient.BaseUrl = value; }
30+
}
2231

2332
/// <summary>
2433
/// Initializes a new instance of the <see cref="IntegrationEngine.Client.InEngineClient"/> class.

IntegrationEngine.sln

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IntegrationEngine.Model.Tes
4141
EndProject
4242
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IntegrationEngine.Core.Tests", "IntegrationEngine.Core.Tests\IntegrationEngine.Core.Tests.csproj", "{04E1E96C-7FDD-426C-BF60-6B45820ED1E5}"
4343
EndProject
44+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IntegrationEngine.Client.Tests", "IntegrationEngine.Client.Tests\IntegrationEngine.Client.Tests.csproj", "{8F491136-6C38-4A8E-BFEA-9234FB981414}"
45+
EndProject
4446
Global
4547
GlobalSection(SolutionConfigurationPlatforms) = preSolution
4648
Debug|Any CPU = Debug|Any CPU
@@ -104,6 +106,18 @@ Global
104106
{7D49353D-A68C-4ACA-A6A5-40B1C314C30E}.Release|Mixed Platforms.Build.0 = Release|x86
105107
{7D49353D-A68C-4ACA-A6A5-40B1C314C30E}.Release|x86.ActiveCfg = Release|x86
106108
{7D49353D-A68C-4ACA-A6A5-40B1C314C30E}.Release|x86.Build.0 = Release|x86
109+
{8F491136-6C38-4A8E-BFEA-9234FB981414}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
110+
{8F491136-6C38-4A8E-BFEA-9234FB981414}.Debug|Any CPU.Build.0 = Debug|Any CPU
111+
{8F491136-6C38-4A8E-BFEA-9234FB981414}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
112+
{8F491136-6C38-4A8E-BFEA-9234FB981414}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
113+
{8F491136-6C38-4A8E-BFEA-9234FB981414}.Debug|x86.ActiveCfg = Debug|Any CPU
114+
{8F491136-6C38-4A8E-BFEA-9234FB981414}.Debug|x86.Build.0 = Debug|Any CPU
115+
{8F491136-6C38-4A8E-BFEA-9234FB981414}.Release|Any CPU.ActiveCfg = Release|Any CPU
116+
{8F491136-6C38-4A8E-BFEA-9234FB981414}.Release|Any CPU.Build.0 = Release|Any CPU
117+
{8F491136-6C38-4A8E-BFEA-9234FB981414}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
118+
{8F491136-6C38-4A8E-BFEA-9234FB981414}.Release|Mixed Platforms.Build.0 = Release|Any CPU
119+
{8F491136-6C38-4A8E-BFEA-9234FB981414}.Release|x86.ActiveCfg = Release|Any CPU
120+
{8F491136-6C38-4A8E-BFEA-9234FB981414}.Release|x86.Build.0 = Release|Any CPU
107121
{BBF7B784-DF72-4561-92B9-4021B5F7D8E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
108122
{BBF7B784-DF72-4561-92B9-4021B5F7D8E3}.Debug|Any CPU.Build.0 = Debug|Any CPU
109123
{BBF7B784-DF72-4561-92B9-4021B5F7D8E3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU

0 commit comments

Comments
 (0)