Skip to content

Commit b0b0994

Browse files
Merge pull request #44 from TransactionProcessing/task/#43_reduceeventsize
Reduce event size
2 parents 0fbaddb + b217756 commit b0b0994

File tree

58 files changed

+1234
-1568
lines changed

Some content is hidden

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

58 files changed

+1234
-1568
lines changed

MessagingService.BusinessLogic.Tests/DomainEventHanders/DomainEventHandlerResolverTests.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using EmailMessage.DomainEvents;
77
using EventHandling;
88
using Moq;
9+
using Shared.EventStore.EventHandling;
910
using Shouldly;
1011
using Testing;
1112
using Xunit;
@@ -17,7 +18,7 @@ public void DomainEventHandlerResolver_CanBeCreated_IsCreated()
1718
{
1819
Dictionary<String, String[]> eventHandlerConfiguration = new Dictionary<String, String[]>();
1920

20-
eventHandlerConfiguration.Add("TestEventType1", new String[] { "MessagingService.BusinessLogic.EventHandling.EmailDomainEventHandler" });
21+
eventHandlerConfiguration.Add("TestEventType1", new[] { "MessagingService.BusinessLogic.EventHandling.EmailDomainEventHandler, MessagingService.BusinessLogic" });
2122

2223
Mock<IDomainEventHandler> domainEventHandler = new Mock<IDomainEventHandler>();
2324
Func<Type, IDomainEventHandler> createDomainEventHandlerFunc = (type) => { return domainEventHandler.Object; };
@@ -42,12 +43,12 @@ public void DomainEventHandlerResolver_CanBeCreated_InvalidEventHandlerType_Erro
4243
[Fact]
4344
public void DomainEventHandlerResolver_GetDomainEventHandlers_ResponseReceivedFromProviderEvent_EventHandlersReturned()
4445
{
45-
String handlerTypeName = "MessagingService.BusinessLogic.EventHandling.EmailDomainEventHandler";
46+
String handlerTypeName = "MessagingService.BusinessLogic.EventHandling.EmailDomainEventHandler, MessagingService.BusinessLogic";
4647
Dictionary<String, String[]> eventHandlerConfiguration = new Dictionary<String, String[]>();
4748

48-
ResponseReceivedFromProviderEvent responseReceivedFromProviderEvent = TestData.EmailResponseReceivedFromProviderEvent;
49+
ResponseReceivedFromEmailProviderEvent responseReceivedFromProviderEvent = TestData.ResponseReceivedFromEmailProviderEvent;
4950

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

5253
Mock<IDomainEventHandler> domainEventHandler = new Mock<IDomainEventHandler>();
5354
Func<Type, IDomainEventHandler> createDomainEventHandlerFunc = (type) => { return domainEventHandler.Object; };
@@ -64,10 +65,10 @@ public void DomainEventHandlerResolver_GetDomainEventHandlers_ResponseReceivedFr
6465
[Fact]
6566
public void DomainEventHandlerResolver_GetDomainEventHandlers_ResponseReceivedFromProviderEvent_EventNotConfigured_EventHandlersReturned()
6667
{
67-
String handlerTypeName = "MessagingService.BusinessLogic.EventHandling.EmailDomainEventHandler";
68+
String handlerTypeName = "MessagingService.BusinessLogic.EventHandling.EmailDomainEventHandler, MessagingService.BusinessLogic";
6869
Dictionary<String, String[]> eventHandlerConfiguration = new Dictionary<String, String[]>();
6970

70-
ResponseReceivedFromProviderEvent responseReceivedFromProviderEvent = TestData.EmailResponseReceivedFromProviderEvent;
71+
ResponseReceivedFromEmailProviderEvent responseReceivedFromProviderEvent = TestData.ResponseReceivedFromEmailProviderEvent;
7172

7273
eventHandlerConfiguration.Add("RandomEvent", new String[] { handlerTypeName });
7374
Mock<IDomainEventHandler> domainEventHandler = new Mock<IDomainEventHandler>();
@@ -85,7 +86,7 @@ public void DomainEventHandlerResolver_GetDomainEventHandlers_ResponseReceivedFr
8586
{
8687
Dictionary<String, String[]> eventHandlerConfiguration = new Dictionary<String, String[]>();
8788

88-
ResponseReceivedFromProviderEvent responseReceivedFromProviderEvent = TestData.EmailResponseReceivedFromProviderEvent;
89+
ResponseReceivedFromEmailProviderEvent responseReceivedFromProviderEvent = TestData.ResponseReceivedFromEmailProviderEvent;
8990
Mock<IDomainEventHandler> domainEventHandler = new Mock<IDomainEventHandler>();
9091

9192
Func<Type, IDomainEventHandler> createDomainEventHandlerFunc = (type) => { return domainEventHandler.Object; };

MessagingService.BusinessLogic.Tests/DomainEventHanders/EmailDomainEventHandlerTests.cs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ namespace MessagingService.BusinessLogic.Tests.DomainEventHanders
88
using EmailMessageAggregate;
99
using EventHandling;
1010
using Moq;
11-
using Shared.EventStore.EventStore;
1211
using System.Threading.Tasks;
12+
using Shared.DomainDrivenDesign.EventSourcing;
13+
using Shared.EventStore.Aggregate;
1314
using Testing;
1415
using Xunit;
1516

@@ -18,7 +19,7 @@ public class EmailDomainEventHandlerTests
1819
[Fact]
1920
public async Task EmailDomainEventHandler_Handle_ResponseReceivedFromProviderEvent_Delivered_EventIsHandled()
2021
{
21-
Mock<IAggregateRepository<EmailAggregate>> aggregateRepository = new Mock<IAggregateRepository<EmailAggregate>>();
22+
Mock<IAggregateRepository<EmailAggregate, DomainEventRecord.DomainEvent>> aggregateRepository = new Mock<IAggregateRepository<EmailAggregate, DomainEventRecord.DomainEvent>>();
2223
aggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny<Guid>(), It.IsAny<CancellationToken>())).ReturnsAsync(TestData.GetSentEmailAggregate);
2324
Mock<IEmailServiceProxy> emailServiceProxy = new Mock<IEmailServiceProxy>();
2425
emailServiceProxy.Setup(e => e.GetMessageStatus(It.IsAny<String>(), It.IsAny<DateTime>(), It.IsAny<DateTime>(), It.IsAny<CancellationToken>()))
@@ -27,13 +28,13 @@ public async Task EmailDomainEventHandler_Handle_ResponseReceivedFromProviderEve
2728
EmailDomainEventHandler emailDomainEventHandler = new EmailDomainEventHandler(aggregateRepository.Object,
2829
emailServiceProxy.Object);
2930

30-
await emailDomainEventHandler.Handle(TestData.EmailResponseReceivedFromProviderEvent, CancellationToken.None);
31+
await emailDomainEventHandler.Handle(TestData.ResponseReceivedFromEmailProviderEvent, CancellationToken.None);
3132
}
3233

3334
[Fact]
3435
public async Task EmailDomainEventHandler_Handle_ResponseReceivedFromProviderEvent_Failed_EventIsHandled()
3536
{
36-
Mock<IAggregateRepository<EmailAggregate>> aggregateRepository = new Mock<IAggregateRepository<EmailAggregate>>();
37+
Mock<IAggregateRepository<EmailAggregate, DomainEventRecord.DomainEvent>> aggregateRepository = new Mock<IAggregateRepository<EmailAggregate, DomainEventRecord.DomainEvent>>();
3738
aggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny<Guid>(), It.IsAny<CancellationToken>())).ReturnsAsync(TestData.GetSentEmailAggregate);
3839
Mock<IEmailServiceProxy> emailServiceProxy = new Mock<IEmailServiceProxy>();
3940
emailServiceProxy.Setup(e => e.GetMessageStatus(It.IsAny<String>(), It.IsAny<DateTime>(), It.IsAny<DateTime>(), It.IsAny<CancellationToken>()))
@@ -42,13 +43,13 @@ public async Task EmailDomainEventHandler_Handle_ResponseReceivedFromProviderEve
4243
EmailDomainEventHandler emailDomainEventHandler = new EmailDomainEventHandler(aggregateRepository.Object,
4344
emailServiceProxy.Object);
4445

45-
await emailDomainEventHandler.Handle(TestData.EmailResponseReceivedFromProviderEvent, CancellationToken.None);
46+
await emailDomainEventHandler.Handle(TestData.ResponseReceivedFromEmailProviderEvent, CancellationToken.None);
4647
}
4748

4849
[Fact]
4950
public async Task EmailDomainEventHandler_Handle_ResponseReceivedFromProviderEvent_Rejected_EventIsHandled()
5051
{
51-
Mock<IAggregateRepository<EmailAggregate>> aggregateRepository = new Mock<IAggregateRepository<EmailAggregate>>();
52+
Mock<IAggregateRepository<EmailAggregate, DomainEventRecord.DomainEvent>> aggregateRepository = new Mock<IAggregateRepository<EmailAggregate, DomainEventRecord.DomainEvent>>();
5253
aggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny<Guid>(), It.IsAny<CancellationToken>())).ReturnsAsync(TestData.GetSentEmailAggregate);
5354
Mock<IEmailServiceProxy> emailServiceProxy = new Mock<IEmailServiceProxy>();
5455
emailServiceProxy.Setup(e => e.GetMessageStatus(It.IsAny<String>(), It.IsAny<DateTime>(), It.IsAny<DateTime>(), It.IsAny<CancellationToken>()))
@@ -57,13 +58,13 @@ public async Task EmailDomainEventHandler_Handle_ResponseReceivedFromProviderEve
5758
EmailDomainEventHandler emailDomainEventHandler = new EmailDomainEventHandler(aggregateRepository.Object,
5859
emailServiceProxy.Object);
5960

60-
await emailDomainEventHandler.Handle(TestData.EmailResponseReceivedFromProviderEvent, CancellationToken.None);
61+
await emailDomainEventHandler.Handle(TestData.ResponseReceivedFromEmailProviderEvent, CancellationToken.None);
6162
}
6263

6364
[Fact]
6465
public async Task EmailDomainEventHandler_Handle_ResponseReceivedFromProviderEvent_Bounced_EventIsHandled()
6566
{
66-
Mock<IAggregateRepository<EmailAggregate>> aggregateRepository = new Mock<IAggregateRepository<EmailAggregate>>();
67+
Mock<IAggregateRepository<EmailAggregate, DomainEventRecord.DomainEvent>> aggregateRepository = new Mock<IAggregateRepository<EmailAggregate, DomainEventRecord.DomainEvent>>();
6768
aggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny<Guid>(), It.IsAny<CancellationToken>())).ReturnsAsync(TestData.GetSentEmailAggregate);
6869
Mock<IEmailServiceProxy> emailServiceProxy = new Mock<IEmailServiceProxy>();
6970
emailServiceProxy.Setup(e => e.GetMessageStatus(It.IsAny<String>(), It.IsAny<DateTime>(), It.IsAny<DateTime>(), It.IsAny<CancellationToken>()))
@@ -72,13 +73,13 @@ public async Task EmailDomainEventHandler_Handle_ResponseReceivedFromProviderEve
7273
EmailDomainEventHandler emailDomainEventHandler = new EmailDomainEventHandler(aggregateRepository.Object,
7374
emailServiceProxy.Object);
7475

75-
await emailDomainEventHandler.Handle(TestData.EmailResponseReceivedFromProviderEvent, CancellationToken.None);
76+
await emailDomainEventHandler.Handle(TestData.ResponseReceivedFromEmailProviderEvent, CancellationToken.None);
7677
}
7778

7879
[Fact]
7980
public async Task EmailDomainEventHandler_Handle_ResponseReceivedFromProviderEvent_Spam_EventIsHandled()
8081
{
81-
Mock<IAggregateRepository<EmailAggregate>> aggregateRepository = new Mock<IAggregateRepository<EmailAggregate>>();
82+
Mock<IAggregateRepository<EmailAggregate, DomainEventRecord.DomainEvent>> aggregateRepository = new Mock<IAggregateRepository<EmailAggregate, DomainEventRecord.DomainEvent>>();
8283
aggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny<Guid>(), It.IsAny<CancellationToken>())).ReturnsAsync(TestData.GetSentEmailAggregate);
8384
Mock<IEmailServiceProxy> emailServiceProxy = new Mock<IEmailServiceProxy>();
8485
emailServiceProxy.Setup(e => e.GetMessageStatus(It.IsAny<String>(), It.IsAny<DateTime>(), It.IsAny<DateTime>(), It.IsAny<CancellationToken>()))
@@ -87,13 +88,13 @@ public async Task EmailDomainEventHandler_Handle_ResponseReceivedFromProviderEve
8788
EmailDomainEventHandler emailDomainEventHandler = new EmailDomainEventHandler(aggregateRepository.Object,
8889
emailServiceProxy.Object);
8990

90-
await emailDomainEventHandler.Handle(TestData.EmailResponseReceivedFromProviderEvent, CancellationToken.None);
91+
await emailDomainEventHandler.Handle(TestData.ResponseReceivedFromEmailProviderEvent, CancellationToken.None);
9192
}
9293

9394
[Fact]
9495
public async Task EmailDomainEventHandler_Handle_ResponseReceivedFromProviderEvent_Unknown_EventIsHandled()
9596
{
96-
Mock<IAggregateRepository<EmailAggregate>> aggregateRepository = new Mock<IAggregateRepository<EmailAggregate>>();
97+
Mock<IAggregateRepository<EmailAggregate, DomainEventRecord.DomainEvent>> aggregateRepository = new Mock<IAggregateRepository<EmailAggregate, DomainEventRecord.DomainEvent>>();
9798
aggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny<Guid>(), It.IsAny<CancellationToken>())).ReturnsAsync(TestData.GetSentEmailAggregate);
9899
Mock<IEmailServiceProxy> emailServiceProxy = new Mock<IEmailServiceProxy>();
99100
emailServiceProxy.Setup(e => e.GetMessageStatus(It.IsAny<String>(), It.IsAny<DateTime>(), It.IsAny<DateTime>(), It.IsAny<CancellationToken>()))
@@ -102,7 +103,7 @@ public async Task EmailDomainEventHandler_Handle_ResponseReceivedFromProviderEve
102103
EmailDomainEventHandler emailDomainEventHandler = new EmailDomainEventHandler(aggregateRepository.Object,
103104
emailServiceProxy.Object);
104105

105-
await emailDomainEventHandler.Handle(TestData.EmailResponseReceivedFromProviderEvent, CancellationToken.None);
106+
await emailDomainEventHandler.Handle(TestData.ResponseReceivedFromEmailProviderEvent, CancellationToken.None);
106107
}
107108
}
108109
}

MessagingService.BusinessLogic.Tests/DomainEventHanders/SMSDomainEventHandlerTests.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ namespace MessagingService.BusinessLogic.Tests.DomainEventHanders
88
using EmailMessageAggregate;
99
using EventHandling;
1010
using Moq;
11-
using Shared.EventStore.EventStore;
1211
using System.Threading.Tasks;
1312
using BusinessLogic.Services.SMSServices;
13+
using Shared.DomainDrivenDesign.EventSourcing;
14+
using Shared.EventStore.Aggregate;
1415
using SMSMessageAggregate;
1516
using Testing;
1617
using Xunit;
@@ -20,7 +21,7 @@ public class SMSDomainEventHandlerTests
2021
[Fact]
2122
public async Task SMSDomainEventHandler_Handle_ResponseReceivedFromProviderEvent_Delivered_EventIsHandled()
2223
{
23-
Mock<IAggregateRepository<SMSAggregate>> aggregateRepository = new Mock<IAggregateRepository<SMSAggregate>>();
24+
Mock<IAggregateRepository<SMSAggregate, DomainEventRecord.DomainEvent>> aggregateRepository = new Mock<IAggregateRepository<SMSAggregate, DomainEventRecord.DomainEvent>>();
2425
aggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny<Guid>(), It.IsAny<CancellationToken>())).ReturnsAsync(TestData.GetSentSMSAggregate);
2526
Mock<ISMSServiceProxy> smsServiceProxy = new Mock<ISMSServiceProxy>();
2627
smsServiceProxy.Setup(e => e.GetMessageStatus(It.IsAny<String>(), It.IsAny<CancellationToken>()))
@@ -29,13 +30,13 @@ public async Task SMSDomainEventHandler_Handle_ResponseReceivedFromProviderEvent
2930
SMSDomainEventHandler smsDomainEventHandler = new SMSDomainEventHandler(aggregateRepository.Object,
3031
smsServiceProxy.Object);
3132

32-
await smsDomainEventHandler.Handle(TestData.SMSResponseReceivedFromProviderEvent, CancellationToken.None);
33+
await smsDomainEventHandler.Handle(TestData.ResponseReceivedFromSMSProviderEvent, CancellationToken.None);
3334
}
3435

3536
[Fact]
3637
public async Task SMSDomainEventHandler_Handle_ResponseReceivedFromProviderEvent_Expired_EventIsHandled()
3738
{
38-
Mock<IAggregateRepository<SMSAggregate>> aggregateRepository = new Mock<IAggregateRepository<SMSAggregate>>();
39+
Mock<IAggregateRepository<SMSAggregate, DomainEventRecord.DomainEvent>> aggregateRepository = new Mock<IAggregateRepository<SMSAggregate, DomainEventRecord.DomainEvent>>();
3940
aggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny<Guid>(), It.IsAny<CancellationToken>())).ReturnsAsync(TestData.GetSentSMSAggregate);
4041
Mock<ISMSServiceProxy> smsServiceProxy = new Mock<ISMSServiceProxy>();
4142
smsServiceProxy.Setup(e => e.GetMessageStatus(It.IsAny<String>(), It.IsAny<CancellationToken>()))
@@ -44,13 +45,13 @@ public async Task SMSDomainEventHandler_Handle_ResponseReceivedFromProviderEvent
4445
SMSDomainEventHandler smsDomainEventHandler = new SMSDomainEventHandler(aggregateRepository.Object,
4546
smsServiceProxy.Object);
4647

47-
await smsDomainEventHandler.Handle(TestData.SMSResponseReceivedFromProviderEvent, CancellationToken.None);
48+
await smsDomainEventHandler.Handle(TestData.ResponseReceivedFromSMSProviderEvent, CancellationToken.None);
4849
}
4950

5051
[Fact]
5152
public async Task SMSDomainEventHandler_Handle_ResponseReceivedFromProviderEvent_Rejected_EventIsHandled()
5253
{
53-
Mock<IAggregateRepository<SMSAggregate>> aggregateRepository = new Mock<IAggregateRepository<SMSAggregate>>();
54+
Mock<IAggregateRepository<SMSAggregate, DomainEventRecord.DomainEvent>> aggregateRepository = new Mock<IAggregateRepository<SMSAggregate, DomainEventRecord.DomainEvent>>();
5455
aggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny<Guid>(), It.IsAny<CancellationToken>())).ReturnsAsync(TestData.GetSentSMSAggregate);
5556
Mock<ISMSServiceProxy> smsServiceProxy = new Mock<ISMSServiceProxy>();
5657
smsServiceProxy.Setup(e => e.GetMessageStatus(It.IsAny<String>(), It.IsAny<CancellationToken>()))
@@ -59,13 +60,13 @@ public async Task SMSDomainEventHandler_Handle_ResponseReceivedFromProviderEvent
5960
SMSDomainEventHandler smsDomainEventHandler = new SMSDomainEventHandler(aggregateRepository.Object,
6061
smsServiceProxy.Object);
6162

62-
await smsDomainEventHandler.Handle(TestData.SMSResponseReceivedFromProviderEvent, CancellationToken.None);
63+
await smsDomainEventHandler.Handle(TestData.ResponseReceivedFromSMSProviderEvent, CancellationToken.None);
6364
}
6465

6566
[Fact]
6667
public async Task SMSDomainEventHandler_Handle_ResponseReceivedFromProviderEvent_Undelivered_EventIsHandled()
6768
{
68-
Mock<IAggregateRepository<SMSAggregate>> aggregateRepository = new Mock<IAggregateRepository<SMSAggregate>>();
69+
Mock<IAggregateRepository<SMSAggregate, DomainEventRecord.DomainEvent>> aggregateRepository = new Mock<IAggregateRepository<SMSAggregate, DomainEventRecord.DomainEvent>>();
6970
aggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny<Guid>(), It.IsAny<CancellationToken>())).ReturnsAsync(TestData.GetSentSMSAggregate);
7071
Mock<ISMSServiceProxy> smsServiceProxy = new Mock<ISMSServiceProxy>();
7172
smsServiceProxy.Setup(e => e.GetMessageStatus(It.IsAny<String>(), It.IsAny<CancellationToken>()))
@@ -74,7 +75,7 @@ public async Task SMSDomainEventHandler_Handle_ResponseReceivedFromProviderEvent
7475
SMSDomainEventHandler smsDomainEventHandler = new SMSDomainEventHandler(aggregateRepository.Object,
7576
smsServiceProxy.Object);
7677

77-
await smsDomainEventHandler.Handle(TestData.SMSResponseReceivedFromProviderEvent, CancellationToken.None);
78+
await smsDomainEventHandler.Handle(TestData.ResponseReceivedFromSMSProviderEvent, CancellationToken.None);
7879
}
7980
}
8081
}

0 commit comments

Comments
 (0)