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
Expand Up @@ -434,9 +434,7 @@ public async Task MessagingDomainService_UpdateSMSMessageStatus_MessageUpdated(B
new(emailAggregateRepository.Object, smsAggregateRepository.Object, emailServiceProxy.Object, smsServiceProxy.Object);

SMSCommands.UpdateMessageStatusCommand command = new(TestData.MessageId, status, TestData.ProviderStatusDescription, TestData.BouncedDateTime);
Should.NotThrow(async () => {
await messagingDomainService.UpdateMessageStatus(command, CancellationToken.None);
});
Should.NotThrow(async () => await messagingDomainService.UpdateMessageStatus(command, CancellationToken.None));
}

[Theory]
Expand Down
10 changes: 5 additions & 5 deletions MessagingService.EmailAggregate.Tests/EmailAggregateTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public void EmailAggregate_MarkMessageAsDelivered_IncorrectState_ErrorThrown(Mes

}

Should.Throw<InvalidOperationException>(() => { emailAggregate.MarkMessageAsDelivered(TestData.ProviderStatusDescription, TestData.DeliveredDateTime); });
Should.Throw<InvalidOperationException>(() => emailAggregate.MarkMessageAsDelivered(TestData.ProviderStatusDescription, TestData.DeliveredDateTime));
}

[Fact]
Expand Down Expand Up @@ -171,7 +171,7 @@ public void EmailAggregate_MarkMessageAsRejected_IncorrectState_ErrorThrown(Mess
break;
}

Should.Throw<InvalidOperationException>(() => { emailAggregate.MarkMessageAsRejected(TestData.ProviderStatusDescription, TestData.RejectedDateTime); });
Should.Throw<InvalidOperationException>(() => emailAggregate.MarkMessageAsRejected(TestData.ProviderStatusDescription, TestData.RejectedDateTime));
}

[Fact]
Expand Down Expand Up @@ -222,7 +222,7 @@ public void EmailAggregate_MarkMessageAsFailed_IncorrectState_ErrorThrown(Messag
break;
}

Should.Throw<InvalidOperationException>(() => { emailAggregate.MarkMessageAsFailed(TestData.ProviderStatusDescription, TestData.FailedDateTime); });
Should.Throw<InvalidOperationException>(() => emailAggregate.MarkMessageAsFailed(TestData.ProviderStatusDescription, TestData.FailedDateTime));
}

[Fact]
Expand Down Expand Up @@ -273,7 +273,7 @@ public void EmailAggregate_MarkMessageAsBounced_IncorrectState_ErrorThrown(Messa
break;
}

Should.Throw<InvalidOperationException>(() => { emailAggregate.MarkMessageAsBounced(TestData.ProviderStatusDescription, TestData.BouncedDateTime); });
Should.Throw<InvalidOperationException>(() => emailAggregate.MarkMessageAsBounced(TestData.ProviderStatusDescription, TestData.BouncedDateTime));
}

[Fact]
Expand Down Expand Up @@ -324,7 +324,7 @@ public void EmailAggregate_MarkMessageAsSpam_IncorrectState_ErrorThrown(MessageS
break;
}

Should.Throw<InvalidOperationException>(() => { emailAggregate.MarkMessageAsSpam(TestData.ProviderStatusDescription, TestData.SpamDateTime); });
Should.Throw<InvalidOperationException>(() => emailAggregate.MarkMessageAsSpam(TestData.ProviderStatusDescription, TestData.SpamDateTime));
}


Expand Down
10 changes: 3 additions & 7 deletions MessagingService.IntegrationTesting.Helpers/MessagingSteps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
var result = await this.MessagingServiceClient.SendEmail(accessToken, sendEmailRequest, CancellationToken.None).ConfigureAwait(false);

result.IsSuccess.ShouldBeTrue();
results.Add((String.Join(",", sendEmailRequest.ToAddresses), null));

Check warning on line 25 in MessagingService.IntegrationTesting.Helpers/MessagingSteps.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests

Argument of type '(string, SendEmailResponse?)' cannot be used for parameter 'item' of type '(string, SendEmailResponse)' in 'void List<(string, SendEmailResponse)>.Add((string, SendEmailResponse) item)' due to differences in the nullability of reference types.

Check warning on line 25 in MessagingService.IntegrationTesting.Helpers/MessagingSteps.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests

Argument of type '(string, SendEmailResponse?)' cannot be used for parameter 'item' of type '(string, SendEmailResponse)' in 'void List<(string, SendEmailResponse)>.Add((string, SendEmailResponse) item)' due to differences in the nullability of reference types.
}
return results;
}
Expand All @@ -39,13 +39,9 @@

public async Task WhenIResendTheFollowingMessages(String accessToken, List<ResendEmailRequest> requests){
foreach (ResendEmailRequest resendEmailRequest in requests){
await Retry.For(async () => {
Should.NotThrow(async () => {
await this.MessagingServiceClient.ResendEmail(accessToken,
resendEmailRequest,
CancellationToken.None);
});
});
await Retry.For(async () => Should.NotThrow(async () => await this.MessagingServiceClient.ResendEmail(accessToken,

Check warning on line 42 in MessagingService.IntegrationTesting.Helpers/MessagingSteps.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 42 in MessagingService.IntegrationTesting.Helpers/MessagingSteps.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
resendEmailRequest,
CancellationToken.None)));
}
}

Expand Down
20 changes: 4 additions & 16 deletions MessagingService.SMSAggregate.Tests/SMSAggregateTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,7 @@ public void SMSAggregate_MarkMessageAsDelivered_IncorrectState_ErrorThrown(Messa
break;
}

Should.Throw<InvalidOperationException>(() =>
{
smsAggregate.MarkMessageAsDelivered(TestData.ProviderStatusDescription, TestData.DeliveredDateTime);
});
Should.Throw<InvalidOperationException>(() => smsAggregate.MarkMessageAsDelivered(TestData.ProviderStatusDescription, TestData.DeliveredDateTime));
}

[Fact]
Expand Down Expand Up @@ -150,10 +147,7 @@ public void SMSAggregate_MarkMessageAsExpired_IncorrectState_ErrorThrown(Message
break;
}

Should.Throw<InvalidOperationException>(() =>
{
smsAggregate.MarkMessageAsExpired(TestData.ProviderStatusDescription, TestData.DeliveredDateTime);
});
Should.Throw<InvalidOperationException>(() => smsAggregate.MarkMessageAsExpired(TestData.ProviderStatusDescription, TestData.DeliveredDateTime));
}

[Fact]
Expand Down Expand Up @@ -205,10 +199,7 @@ public void SMSAggregate_MarkMessageAsUndeliverable_IncorrectState_ErrorThrown(M
break;
}

Should.Throw<InvalidOperationException>(() =>
{
smsAggregate.MarkMessageAsUndeliverable(TestData.ProviderStatusDescription, TestData.DeliveredDateTime);
});
Should.Throw<InvalidOperationException>(() => smsAggregate.MarkMessageAsUndeliverable(TestData.ProviderStatusDescription, TestData.DeliveredDateTime));
}

[Fact]
Expand Down Expand Up @@ -260,10 +251,7 @@ public void SMSAggregate_MarkMessageAsRejected_IncorrectState_ErrorThrown(Messag
break;
}

Should.Throw<InvalidOperationException>(() =>
{
smsAggregate.MarkMessageAsRejected(TestData.ProviderStatusDescription, TestData.DeliveredDateTime);
});
Should.Throw<InvalidOperationException>(() => smsAggregate.MarkMessageAsRejected(TestData.ProviderStatusDescription, TestData.DeliveredDateTime));
}

[Fact]
Expand Down
8 changes: 2 additions & 6 deletions MessagingService.Tests/ControllerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ public async Task DomainEventController_EventIdNotPresentInJson_ErrorThrown() {
};
String json = "{\r\n \"messageId\": \"811bb215-0d99-4639-ac3a-195ba4a47449\",\r\n \"providerRequestReference\": \"d8f669fa-675d-11ec-8b59-f23c92160e3c\"\r\n}\t";
Object request = JsonConvert.DeserializeObject(json);
ArgumentException ex = Should.Throw<ArgumentException>(async () => {
await controller.PostEventAsync(request, CancellationToken.None);
});
ArgumentException ex = Should.Throw<ArgumentException>(() => controller.PostEventAsync(request, CancellationToken.None));
ex.Message.ShouldBe("Domain Event must contain an Event Id");
}

Expand All @@ -61,9 +59,7 @@ public async Task DomainEventController_EventIdPresentInJson_NoErrorThrown()
};
String json = "{\r\n \"messageId\": \"811bb215-0d99-4639-ac3a-195ba4a47449\",\r\n \"providerRequestReference\": \"d8f669fa-675d-11ec-8b59-f23c92160e3c\",\r\n \"eventId\": \"123bb215-0d99-4639-ac3a-195ba4a47449\"\r\n}\t";
Object request = JsonConvert.DeserializeObject(json);
Should.NotThrow(async () => {
await controller.PostEventAsync(request, CancellationToken.None);
});
Should.NotThrow(async () => await controller.PostEventAsync(request, CancellationToken.None));
}
}
}
5 changes: 1 addition & 4 deletions MessagingService/Bootstrapper/MediatorRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ public MediatorRegistry()
this.AddSingleton<IRequestHandler<SMSCommands.UpdateMessageStatusCommand, Result>, MessagingRequestHandler>();
this.AddSingleton<IRequestHandler<EmailCommands.UpdateMessageStatusCommand, Result>, MessagingRequestHandler>();

this.AddSingleton<Func<String, String>>(container => (serviceName) =>
{
return ConfigurationReader.GetBaseServerUri(serviceName).OriginalString;
});
this.AddSingleton<Func<String, String>>(container => (serviceName) => ConfigurationReader.GetBaseServerUri(serviceName).OriginalString);
}
}
4 changes: 1 addition & 3 deletions MessagingService/Bootstrapper/RepositoryRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ public RepositoryRegistry()
this.AddSingleton<IAggregateRepository<EmailAggregate, DomainEvent>, AggregateRepository<EmailAggregate, DomainEvent>>();
this.AddSingleton<IAggregateRepository<SMSAggregate, DomainEvent>, AggregateRepository<SMSAggregate, DomainEvent>>();

this.AddSingleton<Func<String, Int32, ISubscriptionRepository>>(cont => (esConnString, cacheDuration) => {
return SubscriptionRepository.Create(esConnString, cacheDuration);
});
this.AddSingleton<Func<String, Int32, ISubscriptionRepository>>(cont => (esConnString, cacheDuration) => SubscriptionRepository.Create(esConnString, cacheDuration));
}
}
Loading