Skip to content

Commit ffacf0f

Browse files
Merge pull request #127 from TransactionProcessing/task/#126_eventsizereduction
Code Changes complete, still to fix specflow
2 parents 969db08 + d1c1aa0 commit ffacf0f

43 files changed

Lines changed: 595 additions & 1182 deletions

File tree

Some content is hidden

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

TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/DomainEventHandlerResolverTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
using System;
44
using System.Collections.Generic;
55
using System.Linq;
6-
using MessagingService.BusinessLogic.EventHandling;
76
using Moq;
7+
using Shared.EventStore.EventHandling;
88
using Shouldly;
99
using Testing;
1010
using Transaction.DomainEvents;
@@ -17,7 +17,7 @@ public void DomainEventHandlerResolver_CanBeCreated_IsCreated()
1717
{
1818
Dictionary<String, String[]> eventHandlerConfiguration = new Dictionary<String, String[]>();
1919

20-
eventHandlerConfiguration.Add("TestEventType1", new String[] { "TransactionProcessor.BusinessLogic.EventHandling.TransactionDomainEventHandler" });
20+
eventHandlerConfiguration.Add("TestEventType1", new String[] { "TransactionProcessor.BusinessLogic.EventHandling.TransactionDomainEventHandler, TransactionProcessor.BusinessLogic" });
2121

2222
Mock<IDomainEventHandler> domainEventHandler = new Mock<IDomainEventHandler>();
2323
Func<Type, IDomainEventHandler> createDomainEventHandlerFunc = (type) => { return domainEventHandler.Object; };
@@ -31,7 +31,7 @@ public void DomainEventHandlerResolver_CanBeCreated_InvalidEventHandlerType_Erro
3131
{
3232
Dictionary<String, String[]> eventHandlerConfiguration = new Dictionary<String, String[]>();
3333

34-
eventHandlerConfiguration.Add("TestEventType1", new String[] { "TransactionProcessor.BusinessLogic.EventHandling.NonExistantDomainEventHandler" });
34+
eventHandlerConfiguration.Add("TestEventType1", new String[] { "TransactionProcessor.BusinessLogic.EventHandling.NonExistantDomainEventHandler, TransactionProcessor.BusinessLogic" });
3535

3636
Mock<IDomainEventHandler> domainEventHandler = new Mock<IDomainEventHandler>();
3737
Func<Type, IDomainEventHandler> createDomainEventHandlerFunc = (type) => { return domainEventHandler.Object; };
@@ -42,12 +42,12 @@ public void DomainEventHandlerResolver_CanBeCreated_InvalidEventHandlerType_Erro
4242
[Fact]
4343
public void DomainEventHandlerResolver_GetDomainEventHandlers_TransactionHasBeenCompletedEvent_EventHandlersReturned()
4444
{
45-
String handlerTypeName = "TransactionProcessor.BusinessLogic.EventHandling.TransactionDomainEventHandler";
45+
String handlerTypeName = "TransactionProcessor.BusinessLogic.EventHandling.TransactionDomainEventHandler, TransactionProcessor.BusinessLogic";
4646
Dictionary<String, String[]> eventHandlerConfiguration = new Dictionary<String, String[]>();
4747

4848
TransactionHasBeenCompletedEvent transactionHasBeenCompletedEvent = TestData.TransactionHasBeenCompletedEvent;
4949

50-
eventHandlerConfiguration.Add(transactionHasBeenCompletedEvent.GetType().FullName, new String[] { handlerTypeName });
50+
eventHandlerConfiguration.Add(transactionHasBeenCompletedEvent.GetType().Name, new String[] { handlerTypeName });
5151

5252
Mock<IDomainEventHandler> domainEventHandler = new Mock<IDomainEventHandler>();
5353
Func<Type, IDomainEventHandler> createDomainEventHandlerFunc = (type) => { return domainEventHandler.Object; };
@@ -64,7 +64,7 @@ public void DomainEventHandlerResolver_GetDomainEventHandlers_TransactionHasBeen
6464
[Fact]
6565
public void DomainEventHandlerResolver_GetDomainEventHandlers_TransactionHasBeenCompletedEvent_EventNotConfigured_EventHandlersReturned()
6666
{
67-
String handlerTypeName = "TransactionProcessor.BusinessLogic.EventHandling.TransactionDomainEventHandler";
67+
String handlerTypeName = "TransactionProcessor.BusinessLogic.EventHandling.TransactionDomainEventHandler, TransactionProcessor.BusinessLogic";
6868
Dictionary<String, String[]> eventHandlerConfiguration = new Dictionary<String, String[]>();
6969

7070
TransactionHasBeenCompletedEvent transactionHasBeenCompletedEvent = TestData.TransactionHasBeenCompletedEvent;

TransactionProcessor.BusinessLogic.Tests/Services/TransactionAggregateManagerTests.cs

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ namespace TransactionProcessor.BusinessLogic.Tests.Services
1010
using BusinessLogic.Services;
1111
using Models;
1212
using Moq;
13+
using Shared.DomainDrivenDesign.EventSourcing;
14+
using Shared.EventStore.Aggregate;
1315
using Shared.EventStore.EventStore;
1416
using Shouldly;
1517
using Testing;
@@ -21,7 +23,7 @@ public class TransactionAggregateManagerTests
2123
[Fact]
2224
public async Task TransactionAggregateManager_AuthoriseTransaction_TransactionAuthorised()
2325
{
24-
Mock<IAggregateRepository<TransactionAggregate>> aggregateRepository = new Mock<IAggregateRepository<TransactionAggregate>>();
26+
Mock<IAggregateRepository<TransactionAggregate, DomainEventRecord.DomainEvent>> aggregateRepository = new Mock<IAggregateRepository<TransactionAggregate, DomainEventRecord.DomainEvent>>();
2527
aggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny<Guid>(), It.IsAny<CancellationToken>())).ReturnsAsync(TestData.GetStartedTransactionAggregate());
2628
TransactionAggregateManager transactionAggregateManager = new TransactionAggregateManager(aggregateRepository.Object);
2729

@@ -37,7 +39,7 @@ await transactionAggregateManager.AuthoriseTransaction(TestData.EstateId,
3739
[Fact]
3840
public async Task TransactionAggregateManager_AuthoriseTransactionLocally_TransactionLocallyAuthorised()
3941
{
40-
Mock<IAggregateRepository<TransactionAggregate>> aggregateRepository = new Mock<IAggregateRepository<TransactionAggregate>>();
42+
Mock<IAggregateRepository<TransactionAggregate, DomainEventRecord.DomainEvent>> aggregateRepository = new Mock<IAggregateRepository<TransactionAggregate, DomainEventRecord.DomainEvent>>();
4143
aggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny<Guid>(), It.IsAny<CancellationToken>())).ReturnsAsync(TestData.GetStartedTransactionAggregate());
4244
TransactionAggregateManager transactionAggregateManager = new TransactionAggregateManager(aggregateRepository.Object);
4345

@@ -51,7 +53,7 @@ await transactionAggregateManager.AuthoriseTransactionLocally(TestData.EstateId,
5153
[Fact]
5254
public async Task TransactionAggregateManager_DeclineTransaction_TransactionDeclined()
5355
{
54-
Mock<IAggregateRepository<TransactionAggregate>> aggregateRepository = new Mock<IAggregateRepository<TransactionAggregate>>();
56+
Mock<IAggregateRepository<TransactionAggregate, DomainEventRecord.DomainEvent>> aggregateRepository = new Mock<IAggregateRepository<TransactionAggregate, DomainEventRecord.DomainEvent>>();
5557
aggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny<Guid>(), It.IsAny<CancellationToken>())).ReturnsAsync(TestData.GetStartedTransactionAggregate());
5658
TransactionAggregateManager transactionAggregateManager = new TransactionAggregateManager(aggregateRepository.Object);
5759

@@ -67,7 +69,7 @@ await transactionAggregateManager.DeclineTransaction(TestData.EstateId,
6769
[Fact]
6870
public async Task TransactionAggregateManager_DeclineTransactionLocally_TransactionLocallyDeclined()
6971
{
70-
Mock<IAggregateRepository<TransactionAggregate>> aggregateRepository = new Mock<IAggregateRepository<TransactionAggregate>>();
72+
Mock<IAggregateRepository<TransactionAggregate, DomainEventRecord.DomainEvent>> aggregateRepository = new Mock<IAggregateRepository<TransactionAggregate, DomainEventRecord.DomainEvent>>();
7173
aggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny<Guid>(), It.IsAny<CancellationToken>())).ReturnsAsync(TestData.GetStartedTransactionAggregate());
7274
TransactionAggregateManager transactionAggregateManager = new TransactionAggregateManager(aggregateRepository.Object);
7375

@@ -80,7 +82,7 @@ await transactionAggregateManager.DeclineTransactionLocally(TestData.EstateId,
8082
[Fact]
8183
public async Task TransactionAggregateManager_GetAggregate_AggregateReturned()
8284
{
83-
Mock<IAggregateRepository<TransactionAggregate>> aggregateRepository = new Mock<IAggregateRepository<TransactionAggregate>>();
85+
Mock<IAggregateRepository<TransactionAggregate, DomainEventRecord.DomainEvent>> aggregateRepository = new Mock<IAggregateRepository<TransactionAggregate, DomainEventRecord.DomainEvent>>();
8486
aggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny<Guid>(), It.IsAny<CancellationToken>())).ReturnsAsync(TestData.GetCompletedLogonTransactionAggregate);
8587
TransactionAggregateManager transactionAggregateManager = new TransactionAggregateManager(aggregateRepository.Object);
8688

@@ -94,7 +96,7 @@ public async Task TransactionAggregateManager_GetAggregate_AggregateReturned()
9496
[Fact]
9597
public async Task TransactionAggregateManager_RecordAdditionalRequestData_AdditionalRequestDataRecorded()
9698
{
97-
Mock<IAggregateRepository<TransactionAggregate>> aggregateRepository = new Mock<IAggregateRepository<TransactionAggregate>>();
99+
Mock<IAggregateRepository<TransactionAggregate, DomainEventRecord.DomainEvent>> aggregateRepository = new Mock<IAggregateRepository<TransactionAggregate, DomainEventRecord.DomainEvent>>();
98100
aggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny<Guid>(), It.IsAny<CancellationToken>())).ReturnsAsync(TestData.GetStartedTransactionAggregate());
99101
TransactionAggregateManager transactionAggregateManager = new TransactionAggregateManager(aggregateRepository.Object);
100102

@@ -108,7 +110,7 @@ await transactionAggregateManager.RecordAdditionalRequestData(TestData.EstateId,
108110
[Fact]
109111
public async Task TransactionAggregateManager_RecordAdditionalRequestData_NullAdditionalRequestData_NoActionPerformed()
110112
{
111-
Mock<IAggregateRepository<TransactionAggregate>> aggregateRepository = new Mock<IAggregateRepository<TransactionAggregate>>();
113+
Mock<IAggregateRepository<TransactionAggregate, DomainEventRecord.DomainEvent>> aggregateRepository = new Mock<IAggregateRepository<TransactionAggregate, DomainEventRecord.DomainEvent>>();
112114
aggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny<Guid>(), It.IsAny<CancellationToken>())).ReturnsAsync(TestData.GetStartedTransactionAggregate());
113115
TransactionAggregateManager transactionAggregateManager = new TransactionAggregateManager(aggregateRepository.Object);
114116

@@ -122,7 +124,7 @@ await transactionAggregateManager.RecordAdditionalRequestData(TestData.EstateId,
122124
[Fact]
123125
public async Task TransactionAggregateManager_RecordAdditionalRequestData_EmptyAdditionalRequestData_NoActionPerformed()
124126
{
125-
Mock<IAggregateRepository<TransactionAggregate>> aggregateRepository = new Mock<IAggregateRepository<TransactionAggregate>>();
127+
Mock<IAggregateRepository<TransactionAggregate, DomainEventRecord.DomainEvent>> aggregateRepository = new Mock<IAggregateRepository<TransactionAggregate, DomainEventRecord.DomainEvent>>();
126128
aggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny<Guid>(), It.IsAny<CancellationToken>())).ReturnsAsync(TestData.GetStartedTransactionAggregate());
127129
TransactionAggregateManager transactionAggregateManager = new TransactionAggregateManager(aggregateRepository.Object);
128130

@@ -136,7 +138,7 @@ await transactionAggregateManager.RecordAdditionalRequestData(TestData.EstateId,
136138
[Fact]
137139
public async Task TransactionAggregateManager_RecordAdditionalResponseData_AdditionalResponseDataRecorded()
138140
{
139-
Mock<IAggregateRepository<TransactionAggregate>> aggregateRepository = new Mock<IAggregateRepository<TransactionAggregate>>();
141+
Mock<IAggregateRepository<TransactionAggregate, DomainEventRecord.DomainEvent>> aggregateRepository = new Mock<IAggregateRepository<TransactionAggregate, DomainEventRecord.DomainEvent>>();
140142
aggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny<Guid>(), It.IsAny<CancellationToken>())).ReturnsAsync(TestData.GetStartedTransactionAggregate());
141143
TransactionAggregateManager transactionAggregateManager = new TransactionAggregateManager(aggregateRepository.Object);
142144

@@ -150,7 +152,7 @@ await transactionAggregateManager.RecordAdditionalResponseData(TestData.EstateId
150152
[Fact]
151153
public async Task TransactionAggregateManager_RecordAdditionalResponseData_NullAdditionalResponseData_NoActionPerformed()
152154
{
153-
Mock<IAggregateRepository<TransactionAggregate>> aggregateRepository = new Mock<IAggregateRepository<TransactionAggregate>>();
155+
Mock<IAggregateRepository<TransactionAggregate, DomainEventRecord.DomainEvent>> aggregateRepository = new Mock<IAggregateRepository<TransactionAggregate, DomainEventRecord.DomainEvent>>();
154156
aggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny<Guid>(), It.IsAny<CancellationToken>())).ReturnsAsync(TestData.GetStartedTransactionAggregate());
155157
TransactionAggregateManager transactionAggregateManager = new TransactionAggregateManager(aggregateRepository.Object);
156158

@@ -164,7 +166,7 @@ await transactionAggregateManager.RecordAdditionalResponseData(TestData.EstateId
164166
[Fact]
165167
public async Task TransactionAggregateManager_RecordAdditionalResponseData_EmptyAdditionalResponseData_NoActionPerformed()
166168
{
167-
Mock<IAggregateRepository<TransactionAggregate>> aggregateRepository = new Mock<IAggregateRepository<TransactionAggregate>>();
169+
Mock<IAggregateRepository<TransactionAggregate, DomainEventRecord.DomainEvent>> aggregateRepository = new Mock<IAggregateRepository<TransactionAggregate, DomainEventRecord.DomainEvent>>();
168170
aggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny<Guid>(), It.IsAny<CancellationToken>())).ReturnsAsync(TestData.GetStartedTransactionAggregate());
169171
TransactionAggregateManager transactionAggregateManager = new TransactionAggregateManager(aggregateRepository.Object);
170172

@@ -180,7 +182,7 @@ await transactionAggregateManager.RecordAdditionalResponseData(TestData.EstateId
180182
[InlineData(TransactionType.Sale)]
181183
public async Task TransactionAggregateManager_StartTransaction_TransactionStarted(TransactionType transactionType)
182184
{
183-
Mock<IAggregateRepository<TransactionAggregate>> aggregateRepository = new Mock<IAggregateRepository<TransactionAggregate>>();
185+
Mock<IAggregateRepository<TransactionAggregate, DomainEventRecord.DomainEvent>> aggregateRepository = new Mock<IAggregateRepository<TransactionAggregate, DomainEventRecord.DomainEvent>>();
184186
aggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny<Guid>(), It.IsAny<CancellationToken>())).ReturnsAsync(TestData.GetEmptyTransactionAggregate);
185187
TransactionAggregateManager transactionAggregateManager = new TransactionAggregateManager(aggregateRepository.Object);
186188

@@ -199,7 +201,7 @@ await transactionAggregateManager.StartTransaction(TestData.TransactionId,
199201
[Fact]
200202
public async Task TransactionAggregateManager_CompleteTransaction_TransactionCompleted()
201203
{
202-
Mock<IAggregateRepository<TransactionAggregate>> aggregateRepository = new Mock<IAggregateRepository<TransactionAggregate>>();
204+
Mock<IAggregateRepository<TransactionAggregate, DomainEventRecord.DomainEvent>> aggregateRepository = new Mock<IAggregateRepository<TransactionAggregate, DomainEventRecord.DomainEvent>>();
203205
aggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny<Guid>(), It.IsAny<CancellationToken>())).ReturnsAsync(TestData.GetLocallyAuthorisedTransactionAggregate);
204206
TransactionAggregateManager transactionAggregateManager = new TransactionAggregateManager(aggregateRepository.Object);
205207

@@ -211,7 +213,7 @@ await transactionAggregateManager.CompleteTransaction(TestData.EstateId,
211213
[Fact]
212214
public async Task TransactionAggregateManager_RequestEmailReceipt_EmailRecieptRequested()
213215
{
214-
Mock<IAggregateRepository<TransactionAggregate>> aggregateRepository = new Mock<IAggregateRepository<TransactionAggregate>>();
216+
Mock<IAggregateRepository<TransactionAggregate, DomainEventRecord.DomainEvent>> aggregateRepository = new Mock<IAggregateRepository<TransactionAggregate, DomainEventRecord.DomainEvent>>();
215217
aggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny<Guid>(), It.IsAny<CancellationToken>())).ReturnsAsync(TestData.GetCompletedLogonTransactionAggregate);
216218
TransactionAggregateManager transactionAggregateManager = new TransactionAggregateManager(aggregateRepository.Object);
217219

@@ -224,7 +226,7 @@ await transactionAggregateManager.RequestEmailReceipt(TestData.EstateId,
224226
[Fact]
225227
public async Task TransactionAggregateManager_AddProductDetails_ProductDetailsAddedToTransaction()
226228
{
227-
Mock<IAggregateRepository<TransactionAggregate>> aggregateRepository = new Mock<IAggregateRepository<TransactionAggregate>>();
229+
Mock<IAggregateRepository<TransactionAggregate, DomainEventRecord.DomainEvent>> aggregateRepository = new Mock<IAggregateRepository<TransactionAggregate, DomainEventRecord.DomainEvent>>();
228230
aggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny<Guid>(), It.IsAny<CancellationToken>())).ReturnsAsync(TestData.GetStartedTransactionAggregate());
229231
TransactionAggregateManager transactionAggregateManager = new TransactionAggregateManager(aggregateRepository.Object);
230232

@@ -238,7 +240,7 @@ await transactionAggregateManager.AddProductDetails(TestData.EstateId,
238240
[Fact]
239241
public async Task TransactionAggregateManager_AddFee_FeeAddedToTransaction()
240242
{
241-
Mock<IAggregateRepository<TransactionAggregate>> aggregateRepository = new Mock<IAggregateRepository<TransactionAggregate>>();
243+
Mock<IAggregateRepository<TransactionAggregate, DomainEventRecord.DomainEvent>> aggregateRepository = new Mock<IAggregateRepository<TransactionAggregate, DomainEventRecord.DomainEvent>>();
242244
aggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny<Guid>(), It.IsAny<CancellationToken>())).ReturnsAsync(TestData.GetCompletedAuthorisedSaleTransactionAggregate);
243245
TransactionAggregateManager transactionAggregateManager = new TransactionAggregateManager(aggregateRepository.Object);
244246

0 commit comments

Comments
 (0)