Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
Expand All @@ -7,15 +7,15 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Moq" Version="4.13.1" />
<PackageReference Include="Moq" Version="4.14.4" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
<PackageReference Include="Shouldly" Version="3.0.2" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.msbuild" Version="2.8.0">
<PackageReference Include="coverlet.msbuild" Version="2.9.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ namespace MessagingService.BusinessLogic.Tests.Services
using BusinessLogic.Services.EmailServices;
using EmailMessageAggregate;
using Moq;
using Shared.DomainDrivenDesign.EventStore;
using Shared.EventStore.EventStore;
using Testing;
using Xunit;
Expand All @@ -22,8 +21,6 @@ public async Task TransactionDomainService_ProcessLogonTransaction_TransactionIs
{
Mock<IAggregateRepository<EmailAggregate>> aggregateRepository = new Mock<IAggregateRepository<EmailAggregate>>();
aggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny<Guid>(), It.IsAny<CancellationToken>())).ReturnsAsync(TestData.GetEmptyEmailAggregate());
Mock<IAggregateRepositoryManager> aggregateRepositoryManager = new Mock<IAggregateRepositoryManager>();
aggregateRepositoryManager.Setup(a => a.GetAggregateRepository<EmailAggregate>(It.IsAny<Guid>())).Returns(aggregateRepository.Object);
Mock<IEmailServiceProxy> emailServiceProxy = new Mock<IEmailServiceProxy>();
emailServiceProxy
.Setup(e => e.SendEmail(It.IsAny<Guid>(),
Expand All @@ -39,7 +36,7 @@ public async Task TransactionDomainService_ProcessLogonTransaction_TransactionIs
//Logger.Initialise(NullLogger.Instance);

EmailDomainService emailDomainService =
new EmailDomainService(aggregateRepositoryManager.Object, emailServiceProxy.Object);
new EmailDomainService(aggregateRepository.Object, emailServiceProxy.Object);

await emailDomainService.SendEmailMessage(TestData.ConnectionIdentifier,
TestData.MessageId,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
Expand All @@ -10,7 +10,7 @@

<ItemGroup>
<PackageReference Include="MediatR" Version="8.0.1" />
<PackageReference Include="Shared.EventStore" Version="0.0.12" />
<PackageReference Include="Shared.EventStore" Version="0.0.15.3" />
</ItemGroup>

<ItemGroup>
Expand Down
56 changes: 45 additions & 11 deletions MessagingService.BusinessLogic/Services/EmailDomainService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
using System.Threading.Tasks;
using EmailMessageAggregate;
using EmailServices;
using Shared.DomainDrivenDesign.EventStore;
using Microsoft.Extensions.Logging;
using Shared.EventStore.EventStore;
using Shared.Logger;

/// <summary>
///
Expand All @@ -18,9 +19,9 @@ public class EmailDomainService : IEmailDomainService
#region Fields

/// <summary>
/// The aggregate repository manager
/// The email aggregate repository
/// </summary>
private readonly IAggregateRepositoryManager AggregateRepositoryManager;
private readonly IAggregateRepository<EmailAggregate> EmailAggregateRepository;

/// <summary>
/// The email service proxy
Expand All @@ -32,15 +33,16 @@ public class EmailDomainService : IEmailDomainService
#region Constructors

/// <summary>
/// Initializes a new instance of the <see cref="EmailDomainService"/> class.
/// Initializes a new instance of the <see cref="EmailDomainService" /> class.
/// </summary>
/// <param name="aggregateRepositoryManager">The aggregate repository manager.</param>
/// <param name="emailAggregateRepository">The email aggregate repository.</param>
/// <param name="emailServiceProxy">The email service proxy.</param>
public EmailDomainService(IAggregateRepositoryManager aggregateRepositoryManager,
public EmailDomainService(IAggregateRepository<EmailAggregate> emailAggregateRepository,
IEmailServiceProxy emailServiceProxy)
{
this.AggregateRepositoryManager = aggregateRepositoryManager;
this.EmailAggregateRepository = emailAggregateRepository;
this.EmailServiceProxy = emailServiceProxy;
this.EmailAggregateRepository.TraceGenerated += EmailDomainService.EmailAggregateRepository_TraceGenerated;
}

#endregion
Expand All @@ -67,10 +69,8 @@ public async Task SendEmailMessage(Guid connectionIdentifier,
Boolean isHtml,
CancellationToken cancellationToken)
{
IAggregateRepository<EmailAggregate> emailAggregateRepository = this.AggregateRepositoryManager.GetAggregateRepository<EmailAggregate>(connectionIdentifier);

// Rehydrate Email Message aggregate
EmailAggregate emailAggregate = await emailAggregateRepository.GetLatestVersion(messageId, cancellationToken);
EmailAggregate emailAggregate = await this.EmailAggregateRepository.GetLatestVersion(messageId, cancellationToken);

// send message to provider (record event)
emailAggregate.SendRequestToProvider(fromAddress, toAddresses, subject, body, isHtml);
Expand All @@ -83,7 +83,41 @@ public async Task SendEmailMessage(Guid connectionIdentifier,
emailAggregate.ReceiveResponseFromProvider(emailResponse.RequestIdentifier, emailResponse.EmailIdentifier);

// Save Changes to persistance
await emailAggregateRepository.SaveChanges(emailAggregate, cancellationToken);
await this.EmailAggregateRepository.SaveChanges(emailAggregate, cancellationToken);
}

/// <summary>
/// Emails the aggregate repository trace generated.
/// </summary>
/// <param name="trace">The trace.</param>
/// <param name="logLevel">The log level.</param>
private static void EmailAggregateRepository_TraceGenerated(String trace,
LogLevel logLevel)
{
switch(logLevel)
{
case LogLevel.Critical:
Logger.LogCritical(new Exception(trace));
break;
case LogLevel.Debug:
Logger.LogDebug(trace);
break;
case LogLevel.Error:
Logger.LogError(new Exception(trace));
break;
case LogLevel.Information:
Logger.LogInformation(trace);
break;
case LogLevel.Trace:
Logger.LogTrace(trace);
break;
case LogLevel.Warning:
Logger.LogWarning(trace);
break;
default:
Logger.LogInformation(trace);
break;
}
}

#endregion
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
Expand All @@ -8,14 +8,14 @@

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
<PackageReference Include="Shared.EventStore" Version="0.0.12" />
<PackageReference Include="Shared.EventStore" Version="0.0.15.3" />
<PackageReference Include="Shouldly" Version="3.0.2" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.msbuild" Version="2.8.0">
<PackageReference Include="coverlet.msbuild" Version="2.9.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Shared.DomainDrivenDesign" Version="0.0.12" />
<PackageReference Include="Shared.DomainDrivenDesign" Version="0.0.15.3" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions MessagingService.EmailMessageAggregate/EmailAggregate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
using System.Diagnostics.CodeAnalysis;
using EmailMessage.DomainEvents;
using Shared.DomainDrivenDesign.EventSourcing;
using Shared.DomainDrivenDesign.EventStore;
using Shared.EventStore.EventStore;
using Shared.General;

/// <summary>
///
/// </summary>
/// <seealso cref="Shared.DomainDrivenDesign.EventStore.Aggregate" />
/// <seealso cref="Aggregate" />
public class EmailAggregate : Aggregate
{
#region Fields
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Shared.EventStore" Version="0.0.12" />
<PackageReference Include="Shared.EventStore" Version="0.0.15.3" />
</ItemGroup>

<ItemGroup>
Expand Down
5 changes: 2 additions & 3 deletions MessagingService.IntegrationTests/Common/DockerHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public override async Task StartContainersForScenarioRun(String scenarioName)
INetworkService testNetwork = DockerHelper.SetupTestNetwork();
this.TestNetworks.Add(testNetwork);
IContainerService eventStoreContainer =
DockerHelper.SetupEventStoreContainer(this.EventStoreContainerName, this.Logger, "eventstore/eventstore:release-5.0.2", testNetwork, traceFolder);
DockerHelper.SetupEventStoreContainer(this.EventStoreContainerName, this.Logger, "eventstore/eventstore:20.6.0-buster-slim", testNetwork, traceFolder, usesEventStore2006OrLater:true);

IContainerService securityServiceContainer = DockerHelper.SetupSecurityServiceContainer(this.SecurityServiceContainerName,
this.Logger,
Expand Down Expand Up @@ -215,8 +215,7 @@ public static IContainerService SetupMessagingServiceContainer(String containerN
logger.LogInformation("About to Start Messaging Service Container");

List<String> environmentVariables = new List<String>();
environmentVariables
.Add($"EventStoreSettings:ConnectionString=ConnectTo=tcp://admin:changeit@{eventStoreContainerName}:{DockerHelper.EventStoreTcpDockerPort};VerboseLogging=true;");
environmentVariables.Add($"EventStoreSettings:ConnectionString=https://{eventStoreContainerName}:{DockerHelper.EventStoreHttpDockerPort}");
environmentVariables.Add($"AppSettings:SecurityService=http://{securityServiceContainerName}:{securityServicePort}");
environmentVariables.Add($"SecurityConfiguration:Authority=http://{securityServiceContainerName}:{securityServicePort}");
environmentVariables.Add($"urls=http://*:{DockerHelper.MessagingServiceDockerPort}");
Expand Down
12 changes: 6 additions & 6 deletions MessagingService.IntegrationTests/Email/SendEmail.feature.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
Expand All @@ -7,20 +7,20 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="ClientProxyBase" Version="0.0.12" />
<PackageReference Include="ClientProxyBase" Version="0.0.15.3" />
<PackageReference Include="Ductus.FluentDocker" Version="2.7.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
<PackageReference Include="SecurityService.Client" Version="0.0.9" />
<PackageReference Include="Shared.IntegrationTesting" Version="0.0.12" />
<PackageReference Include="SecurityService.Client" Version="1.0.0" />
<PackageReference Include="Shared.IntegrationTesting" Version="0.0.15.3" />
<PackageReference Include="Shouldly" Version="3.0.2" />
<PackageReference Include="SpecFlow.Tools.MsBuild.Generation" Version="3.1.97" />
<PackageReference Include="SpecFlow.xUnit" Version="3.1.97" />
<PackageReference Include="SpecFlow.Tools.MsBuild.Generation" Version="3.3.30" />
<PackageReference Include="SpecFlow.xUnit" Version="3.3.30" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="1.2.1">
<PackageReference Include="coverlet.collector" Version="1.3.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand All @@ -44,4 +44,10 @@
</Compile>
</ItemGroup>

<ItemGroup>
<None Update="nlog.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
17 changes: 17 additions & 0 deletions MessagingService.IntegrationTests/nlog.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<nlog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<targets>
<target name="asyncFile" xsi:type="AsyncWrapper">
<target name="logfile" xsi:type="File"
fileName="/home/txnproc/trace/${event-properties:item=FileName}/Specflow_${date:format=yyyyMMdd}.txt"
layout="${date:format=yyyy-MM-dd HH-mm-ss.fff} | ${level} | ${callsite:className=true}| ${message} | ${exception:format=tostring}"/>
<target name="console" xsi:type="Console"
layout="${date:format=yyyy-MM-dd HH-mm-ss.fff} | ${level} | ${callsite:className=true}| ${message} | ${exception:format=tostring}"/>
</target>
</targets>

<rules>
<logger name="*" minlevel="Info" writeTo="logfile"/>
</rules>
</nlog>
5 changes: 3 additions & 2 deletions MessagingService.Tests/General/BootstrapperTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ private IConfigurationRoot SetupMemoryConfiguration()

IConfigurationBuilder builder = new ConfigurationBuilder();

configuration.Add("EventStoreSettings:ConnectionString", "ConnectTo=tcp://admin:changeit@127.0.0.1:1112;VerboseLogging=true;");
configuration.Add("EventStoreSettings:ConnectionString", "https://127.0.0.1:2113");
configuration.Add("EventStoreSettings:ConnectionName", "UnitTestConnection");
configuration.Add("EventStoreSettings:HttpPort", "2113");
configuration.Add("EventStoreSettings:UserName", "admin");
configuration.Add("EventStoreSettings:Password", "changeit");
configuration.Add("AppSettings:UseConnectionStringConfig", "false");
configuration.Add("AppSettings:ClientId", "clientId");
configuration.Add("AppSettings:ClientSecret", "clientSecret");
Expand Down
8 changes: 4 additions & 4 deletions MessagingService.Tests/MessagingService.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="3.1.3" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="3.1.5" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
<PackageReference Include="Moq" Version="4.13.1" />
<PackageReference Include="Moq" Version="4.14.4" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.msbuild" Version="2.8.0">
<PackageReference Include="coverlet.msbuild" Version="2.9.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Loading