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
4 changes: 2 additions & 2 deletions .github/workflows/createrelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Setup .NET Core 3.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.0.100
dotnet-version: 3.1.102

- name: Restore Nuget Packages
run: dotnet restore EstateManagement.sln --source https://api.nuget.org/v3/index.json --source https://www.myget.org/F/transactionprocessing/api/v3/index.json
Expand Down Expand Up @@ -114,7 +114,7 @@ jobs:
- name: Setup .NET Core 3.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.0.100
dotnet-version: 3.1.102

- name: Build and Publish Nuget Packages
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nightlybuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.0.100
dotnet-version: 3.1.102

- name: Restore Nuget Packages
run: dotnet restore EstateManagement.sln --source https://api.nuget.org/v3/index.json --source https://www.myget.org/F/transactionprocessing/api/v3/index.json
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pullrequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.0.100
dotnet-version: 3.1.102

- name: Restore Nuget Packages
run: dotnet restore EstateManagement.sln --source https://api.nuget.org/v3/index.json --source https://www.myget.org/F/transactionprocessing/api/v3/index.json
Expand All @@ -44,4 +44,4 @@ jobs:
docker pull stuartferguson/securityservice

- name: Run Integration Tests
run: dotnet test "EstateManagement.IntegrationTests\EstateManagement.IntegrationTests.csproj" --filter Category=PRTest
run: dotnet test "EstateManagement.IntegrationTests\EstateManagement.IntegrationTests.csproj" --filter Category=PRTest
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<DebugType>None</DebugType>
<IsPackable>false</IsPackable>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ namespace EstateManagement.BusinessLogic.Tests.Manager
{
using System.Threading;
using System.Threading.Tasks;
using Castle.DynamicProxy.Generators;
using EstateAggregate;
using Manger;
using MerchantAggregate;
using Models;
using Models.Factories;
using Models.Merchant;
using Moq;
using Repository;
using Shared.DomainDrivenDesign.EventStore;
using Shared.EventStore.EventStore;
using Shouldly;
Expand All @@ -24,6 +26,7 @@ public class EstateManagementManagerTests
private readonly Mock<IAggregateRepositoryManager> AggregateRepositoryManager;
private readonly Mock<IAggregateRepository<EstateAggregate>> EstateAggregateRepository;
private readonly Mock<IAggregateRepository<MerchantAggregate>> MerchantAggregateRepository;
private readonly Mock<IEstateManagementRepository> EstateManagementRepository;

private readonly Mock<IModelFactory> ModelFactory;

Expand All @@ -34,18 +37,21 @@ public EstateManagementManagerTests()
Mock<IAggregateRepositoryManager> aggregateRepositoryManager = new Mock<IAggregateRepositoryManager>();
this.EstateAggregateRepository = new Mock<IAggregateRepository<EstateAggregate>>();
this.MerchantAggregateRepository = new Mock<IAggregateRepository<MerchantAggregate>>();
this.EstateManagementRepository = new Mock<IEstateManagementRepository>();

this.ModelFactory = new Mock<IModelFactory>();

aggregateRepositoryManager.Setup(x => x.GetAggregateRepository<EstateAggregate>(It.IsAny<Guid>())).Returns(this.EstateAggregateRepository.Object);
aggregateRepositoryManager.Setup(x => x.GetAggregateRepository<MerchantAggregate>(It.IsAny<Guid>())).Returns(this.MerchantAggregateRepository.Object);

this.EstateManagementManager = new EstateManagementManager(aggregateRepositoryManager.Object, this.ModelFactory.Object);
this.EstateManagementManager =
new EstateManagementManager(aggregateRepositoryManager.Object, this.EstateManagementRepository.Object, this.ModelFactory.Object);
}

[Fact]
public async Task EstateManagementManager_GetEstate_EstateIsReturned()
{
this.EstateAggregateRepository.Setup(e => e.GetLatestVersion(It.IsAny<Guid>(), It.IsAny<CancellationToken>())).ReturnsAsync(TestData.CreatedEstateAggregate);
this.EstateManagementRepository.Setup(e => e.GetEstate(It.IsAny<Guid>(), It.IsAny<CancellationToken>())).ReturnsAsync(TestData.EstateModel);

Estate estateModel = await this.EstateManagementManager.GetEstate(TestData.EstateId, CancellationToken.None);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
namespace EstateManagement.BusinessLogic.Common
{
using System;
using System.Data.Common;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Data.SqlClient;
using Shared.General;
using Shared.Repositories;

[ExcludeFromCodeCoverage]
public class ConfigurationReaderConnectionStringRepository : IConnectionStringConfigurationRepository
{
#region Methods

/// <summary>
/// Creates the connection string.
/// </summary>
/// <param name="externalIdentifier">The external identifier.</param>
/// <param name="connectionStringType">Type of the connection string.</param>
/// <param name="connectionString">The connection string.</param>
/// <param name="cancellationToken">The cancellation token.</param>
public async Task CreateConnectionString(String externalIdentifier,
ConnectionStringType connectionStringType,
String connectionString,
CancellationToken cancellationToken)
{
throw new NotImplementedException("This is only required to complete the interface");
}

/// <summary>
/// Deletes the connection string configuration.
/// </summary>
/// <param name="externalIdentifier">The external identifier.</param>
/// <param name="connectionStringType">Type of the connection string.</param>
/// <param name="cancellationToken">The cancellation token.</param>
public async Task DeleteConnectionStringConfiguration(String externalIdentifier,
ConnectionStringType connectionStringType,
CancellationToken cancellationToken)
{
throw new NotImplementedException("This is only required to complete the interface");
}

/// <summary>
/// Gets the connection string.
/// </summary>
/// <param name="externalIdentifier">The external identifier.</param>
/// <param name="connectionStringType">Type of the connection string.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
public async Task<String> GetConnectionString(String externalIdentifier,
ConnectionStringType connectionStringType,
CancellationToken cancellationToken)
{
String connectionString = string.Empty;
String databaseName = string.Empty;
switch (connectionStringType)
{
case ConnectionStringType.ReadModel:
databaseName = "EstateReportingReadModel" + externalIdentifier;
connectionString = ConfigurationReader.GetConnectionString("EstateReportingReadModel");
break;
default:
throw new NotSupportedException($"Connection String type [{connectionStringType}] is not supported");
}

DbConnectionStringBuilder builder = new SqlConnectionStringBuilder(connectionString)
{
InitialCatalog = databaseName
};

return builder.ToString();
}

#endregion
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

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

<ItemGroup>
<Folder Include="Common\" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="SecurityService.Client" Version="0.0.5.4" />
<PackageReference Include="Shared.DomainDrivenDesign" Version="0.0.5.1" />
Expand All @@ -19,6 +15,7 @@
<ProjectReference Include="..\EstateManagement.EstateAggregate\EstateManagement.EstateAggregate.csproj" />
<ProjectReference Include="..\EstateManagement.MerchantAggregate\EstateManagement.MerchantAggregate.csproj" />
<ProjectReference Include="..\EstateManagement.Models\EstateManagement.Models.csproj" />
<ProjectReference Include="..\EstateManagement.Repository\EstateManagement.Repository.csproj" />
</ItemGroup>

</Project>
11 changes: 7 additions & 4 deletions EstateManagement.BusinessLogic/Manger/EstateManagementManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Models;
using Models.Factories;
using Models.Merchant;
using Repository;
using Shared.DomainDrivenDesign.EventStore;
using Shared.EventStore.EventStore;

Expand All @@ -24,6 +25,8 @@ public class EstateManagementManager : IEstateManagementManager
/// </summary>
private readonly IAggregateRepositoryManager AggregateRepositoryManager;

private readonly IEstateManagementRepository EstateManagementRepository;

private readonly IAggregateRepository<MerchantAggregate> MerchantAggregateRepository;

/// <summary>
Expand All @@ -39,11 +42,14 @@ public class EstateManagementManager : IEstateManagementManager
/// Initializes a new instance of the <see cref="EstateManagementManager" /> class.
/// </summary>
/// <param name="aggregateRepositoryManager">The aggregate repository manager.</param>
/// <param name="estateManagementRepository">The estate management repository.</param>
/// <param name="modelFactory">The model factory.</param>
public EstateManagementManager(IAggregateRepositoryManager aggregateRepositoryManager,
IEstateManagementRepository estateManagementRepository,
IModelFactory modelFactory)
{
this.AggregateRepositoryManager = aggregateRepositoryManager;
this.EstateManagementRepository = estateManagementRepository;
this.ModelFactory = modelFactory;
}

Expand All @@ -61,10 +67,7 @@ public async Task<Estate> GetEstate(Guid estateId,
CancellationToken cancellationToken)
{
// Get the estate from the aggregate repository
IAggregateRepository<EstateAggregate> estateAggregateRepository = this.AggregateRepositoryManager.GetAggregateRepository<EstateAggregate>(estateId);
EstateAggregate estateAggregate = await estateAggregateRepository.GetLatestVersion(estateId, cancellationToken);

Estate estateModel = estateAggregate.GetEstate();
Estate estateModel = await this.EstateManagementRepository.GetEstate(estateId, cancellationToken);

return estateModel;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<DebugType>None</DebugType>
<IsPackable>false</IsPackable>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

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

<ItemGroup>
Expand Down
Loading