Skip to content

Commit 6f20e20

Browse files
committed
Merge branch 'integration-points' into develop
Conflicts: IntegrationEngine.Tests/EngineHostConfigurationTest.cs IntegrationEngine.sln
2 parents e336d5c + d08269a commit 6f20e20

File tree

75 files changed

+1033
-700
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+1033
-700
lines changed

IntegrationEngine.ConsoleHost/IntegrationEngine.ConsoleHost.csproj

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@
2121
<DefineConstants>DEBUG;</DefineConstants>
2222
<ErrorReport>prompt</ErrorReport>
2323
<WarningLevel>4</WarningLevel>
24-
<Externalconsole>true</Externalconsole>
2524
<PlatformTarget>x86</PlatformTarget>
25+
<Externalconsole>true</Externalconsole>
26+
<ConsolePause>false</ConsolePause>
2627
</PropertyGroup>
2728
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
2829
<DebugType>full</DebugType>
@@ -92,11 +93,14 @@
9293
<Compile Include="IntegrationJobs\CarReport\CarReport.cs" />
9394
<Compile Include="IntegrationJobs\CarReport\CarReportJob.cs" />
9495
<Compile Include="IntegrationJobs\CarReport\CarMailMessageJob.cs" />
96+
<Compile Include="IntegrationJobs\SampleSqlReport\SampleSqlReportJobWithIntegrationPoints.cs" />
97+
<Compile Include="IntegrationPoints\FooMailClient.cs" />
98+
<Compile Include="IntegrationPoints\BarSqlServer.cs" />
9599
</ItemGroup>
96100
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
97101
<ItemGroup>
98102
<ProjectReference Include="..\IntegrationEngine.Client\IntegrationEngine.Client.csproj">
99-
<Project>{f3fcb706-f0dd-46c1-b121-785757fae9b9}</Project>
103+
<Project>{F3FCB706-F0DD-46C1-B121-785757FAE9B9}</Project>
100104
<Name>IntegrationEngine.Client</Name>
101105
</ProjectReference>
102106
<ProjectReference Include="..\IntegrationEngine.Core\IntegrationEngine.Core.csproj">
@@ -132,4 +136,7 @@
132136
</Content>
133137
</ItemGroup>
134138
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
139+
<ItemGroup>
140+
<Folder Include="IntegrationPoints\" />
141+
</ItemGroup>
135142
</Project>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using IntegrationEngine.Core.Jobs;
2+
using IntegrationEngine.ConsoleHost.IntegrationPoints;
3+
using RazorEngine;
4+
using RazorEngine.Templating;
5+
using System;
6+
using System.Net.Mail;
7+
8+
namespace IntegrationEngine.ConsoleHost.IntegrationJobs.SampleSqlReport
9+
{
10+
public class SampleSqlReportJobWithIntegrationPoints : IIntegrationJob
11+
{
12+
public FooMailClient FooMailClient { get; set; }
13+
public BarSqlServer BarSqlServer { get; set; }
14+
15+
public void Run()
16+
{
17+
try
18+
{
19+
var report = new SampleReport() {
20+
Created = DateTime.Now,
21+
Data = new System.Collections.Generic.List<SampleDatum>(),
22+
//Data = RunQuery<SampleDatum>(),
23+
};
24+
25+
// Pass into Razor engine
26+
string template = "Created on <strong>@Model.Created</strong> with <strong>@Model.Data.Count</strong> records.";
27+
var html = Engine.Razor.RunCompile(template, "template-01", typeof(SampleReport), report);
28+
29+
// Send Mail
30+
var mailMessage = new MailMessage();
31+
mailMessage.To.Add("ethanhann@gmail.com");
32+
mailMessage.Subject = "Sample SQL Report";
33+
mailMessage.From = new MailAddress("root@localhost");
34+
mailMessage.Body = html;
35+
mailMessage.IsBodyHtml = true;
36+
FooMailClient.Send(mailMessage);
37+
}
38+
catch (Exception exception)
39+
{
40+
throw new IntegrationJobRunFailureException("SampleSqlReportJob failed.", exception);
41+
}
42+
}
43+
}
44+
}
45+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
using System;
2+
3+
namespace IntegrationEngine.ConsoleHost.IntegrationPoints
4+
{
5+
public class BarSqlServer
6+
{}
7+
}
8+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using System;
2+
using IntegrationEngine.Core.Mail;
3+
4+
namespace IntegrationEngine.ConsoleHost.IntegrationPoints
5+
{
6+
public class FooMailClient : MailClient
7+
{}
8+
}
9+

IntegrationEngine.Core.Tests/IntegrationEngine.Core.Tests.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,12 @@
5555
<Reference Include="Common.Logging">
5656
<HintPath>..\packages\Common.Logging.3.0.0\lib\net40\Common.Logging.dll</HintPath>
5757
</Reference>
58+
<Reference Include="RabbitMQ.Client">
59+
<HintPath>..\packages\RabbitMQ.Client.3.4.3\lib\net35\RabbitMQ.Client.dll</HintPath>
60+
</Reference>
5861
</ItemGroup>
5962
<ItemGroup>
63+
<Compile Include="MessageQueue\RabbitMQClientTest.cs" />
6064
<Compile Include="Properties\AssemblyInfo.cs" />
6165
<Compile Include="Storage\ElasticsearchRepositoryTest.cs" />
6266
<Compile Include="Mail\MailClientTest.cs" />
@@ -77,6 +81,7 @@
7781
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
7882
</ItemGroup>
7983
<ItemGroup>
84+
<None Include="app.config" />
8085
<None Include="packages.config" />
8186
</ItemGroup>
8287
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />

IntegrationEngine.Core.Tests/Mail/MailClientTest.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,17 @@ public void Setup()
2121
{
2222
MockLog = new Mock<ILog>();
2323
Subject.Log = MockLog.Object;
24-
Subject.MailConfiguration = new MailConfiguration() {
25-
HostName = "hostName",
26-
Port = 0,
27-
};
2824
}
2925

3026
[Test]
3127
public void ShouldLogExceptionAndReturnFalseIfMailServerIsNotAvailable()
3228
{
33-
MockLog.Setup(x => x.Error(It.IsAny<SocketException>()));
29+
MockLog.Setup(x => x.Error(It.IsAny<Exception>()));
3430

3531
var actual = Subject.IsServerAvailable();
3632

3733
Assert.That(actual, Is.False);
38-
MockLog.Verify(x => x.Error(It.IsAny<SocketException>()));
34+
MockLog.Verify(x => x.Error(It.IsAny<Exception>()));
3935
}
4036

4137
// @TODO Do not mock tcp client, instead test with listener or real mail server.
@@ -52,9 +48,7 @@ public void ShouldLogExceptionAndReturnFalseIfMailServerIsNotAvailable()
5248
// stream.Write(responseInBytes, 0, responseInBytes.Length);
5349
// MockTcpClient.Setup(x => x.GetStream()).Returns(stream);
5450
// MockTcpClient.Setup(x => x.Close());
55-
5651
// var actual = Subject.IsServerAvailable();
57-
5852
// Assert.That(actual, Is.True);
5953
// MockTcpClient.Verify(x => x.Close(), Times.Once);
6054
//}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using BeekmanLabs.UnitTesting;
2+
using Common.Logging;
3+
using IntegrationEngine.Core.Configuration;
4+
using IntegrationEngine.Core.MessageQueue;
5+
using Moq;
6+
using NUnit.Framework;
7+
using RabbitMQ.Client;
8+
using System;
9+
using System.Text;
10+
11+
namespace IntegrationEngine.Core.Tests.MessageQueue
12+
{
13+
public class RabbitMQClientTest : TestBase<RabbitMQClient>
14+
{
15+
[Test]
16+
public void ShouldPublishDispatchMessage()
17+
{
18+
//var config = new RabbitMQConfiguration() {
19+
// QueueName = "MyQueue",
20+
// ExchangeName = "MyExchange",
21+
//};
22+
//Subject.MessageQueueConfiguration = config;
23+
//var expected = new IntegrationJobStub();
24+
//var mockLog = new Mock<ILog>();
25+
//Subject.Log = mockLog.Object;
26+
//var mockMessageQueueConnection = new Mock<IMessageQueueConnection>();
27+
//Subject.MessageQueueConnection = mockMessageQueueConnection.Object;
28+
//var mockConnection = new Mock<IConnection>();
29+
//mockMessageQueueConnection.Setup(x => x.GetConnection()).Returns(mockConnection.Object);
30+
//var mockModel = new Mock<IModel>();
31+
//mockConnection.Setup(x => x.CreateModel()).Returns(mockModel.Object);
32+
//mockModel.Setup(x => x.QueueBind(config.QueueName, config.ExchangeName, ""));
33+
//mockModel.Setup(x => x.BasicPublish(config.ExchangeName, "", null, It.IsAny<byte[]>()));
34+
35+
//Subject.Publish(expected, null);
36+
37+
//mockMessageQueueConnection.Verify(x => x.GetConnection(), Times.Once);
38+
//mockConnection.Verify(x => x.CreateModel(), Times.Once);
39+
//mockModel.Verify(x => x.QueueBind(config.QueueName, config.ExchangeName, ""), Times.Once);
40+
//mockModel.Verify(x => x.BasicPublish(config.ExchangeName, "", null, It.IsAny<byte[]>()), Times.Once);
41+
}
42+
}
43+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<runtime>
4+
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
5+
<dependentAssembly>
6+
<assemblyIdentity name="NLog" publicKeyToken="5120e14c03d0593c" culture="neutral" />
7+
<bindingRedirect oldVersion="0.0.0.0-3.2.0.0" newVersion="3.2.0.0" />
8+
</dependentAssembly>
9+
</assemblyBinding>
10+
</runtime>
11+
</configuration>

IntegrationEngine.Core.Tests/packages.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88
<package id="NEST" version="1.4.0" targetFramework="net45" />
99
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" />
1010
<package id="NUnit" version="2.6.4" targetFramework="net45" />
11+
<package id="RabbitMQ.Client" version="3.4.3" targetFramework="net45" />
1112
</packages>

IntegrationEngine.Core/App.config

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,4 @@
2121
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.9.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
2222
</DbProviderFactories>
2323
</system.data>
24-
<runtime>
25-
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
26-
<dependentAssembly>
27-
<assemblyIdentity name="NLog" publicKeyToken="5120e14c03d0593c" culture="neutral" />
28-
<bindingRedirect oldVersion="0.0.0.0-3.1.0.0" newVersion="3.1.0.0" />
29-
</dependentAssembly>
30-
</assemblyBinding>
31-
</runtime>
3224
</configuration>

0 commit comments

Comments
 (0)