diff --git a/MessagingService.BusinessLogic.Tests/Mediator/MediatorTests.cs b/MessagingService.BusinessLogic.Tests/Mediator/MediatorTests.cs index 654718c..b6acc87 100644 --- a/MessagingService.BusinessLogic.Tests/Mediator/MediatorTests.cs +++ b/MessagingService.BusinessLogic.Tests/Mediator/MediatorTests.cs @@ -34,20 +34,20 @@ public MediatorTests() { [Fact] public async Task Mediator_Send_RequestHandled() { - Mock hostingEnvironment = new Mock(); + Mock hostingEnvironment = new(); hostingEnvironment.Setup(he => he.EnvironmentName).Returns("Development"); hostingEnvironment.Setup(he => he.ContentRootPath).Returns("/home"); hostingEnvironment.Setup(he => he.ApplicationName).Returns("Test Application"); - ServiceRegistry services = new ServiceRegistry(); - Startup s = new Startup(hostingEnvironment.Object); + ServiceRegistry services = new(); + Startup s = new(hostingEnvironment.Object); Startup.Configuration = this.SetupMemoryConfiguration(); this.AddTestRegistrations(services, hostingEnvironment.Object); s.ConfigureContainer(services); Startup.Container.AssertConfigurationIsValid(AssertMode.Full); - List errors = new List(); + List errors = new(); IMediator mediator = Startup.Container.GetService(); foreach (IBaseRequest baseRequest in this.Requests) { try { @@ -78,7 +78,7 @@ private IConfigurationRoot SetupMemoryConfiguration() private void AddTestRegistrations(ServiceRegistry services, IWebHostEnvironment hostingEnvironment) { services.AddLogging(); - DiagnosticListener diagnosticSource = new DiagnosticListener(hostingEnvironment.ApplicationName); + DiagnosticListener diagnosticSource = new(hostingEnvironment.ApplicationName); services.AddSingleton(diagnosticSource); services.AddSingleton(diagnosticSource); services.AddSingleton(hostingEnvironment); diff --git a/MessagingService.BusinessLogic.Tests/Services/MessagingDomainServiceTests.cs b/MessagingService.BusinessLogic.Tests/Services/MessagingDomainServiceTests.cs index 092db6e..98405c4 100644 --- a/MessagingService.BusinessLogic.Tests/Services/MessagingDomainServiceTests.cs +++ b/MessagingService.BusinessLogic.Tests/Services/MessagingDomainServiceTests.cs @@ -26,11 +26,11 @@ public class MessagingDomainServiceTests [Fact] public async Task MessagingDomainService_SendEmailMessage_MessageSent() { - Mock> emailAggregateRepository = new Mock>(); + Mock> emailAggregateRepository = new(); emailAggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(TestData.GetEmptyEmailAggregate()); emailAggregateRepository.Setup(a => a.SaveChanges(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success); - Mock> smsAggregateRepository = new Mock>(); - Mock emailServiceProxy = new Mock(); + Mock> smsAggregateRepository = new(); + Mock emailServiceProxy = new(); emailServiceProxy .Setup(e => e.SendEmail(It.IsAny(), It.IsAny(), @@ -40,10 +40,10 @@ public async Task MessagingDomainService_SendEmailMessage_MessageSent() It.IsAny(), It.IsAny>(), It.IsAny())).ReturnsAsync(TestData.SuccessfulEmailServiceProxyResponse); - Mock smsServiceProxy = new Mock(); + Mock smsServiceProxy = new(); MessagingDomainService messagingDomainService = - new MessagingDomainService(emailAggregateRepository.Object, smsAggregateRepository.Object, emailServiceProxy.Object, smsServiceProxy.Object); + new(emailAggregateRepository.Object, smsAggregateRepository.Object, emailServiceProxy.Object, smsServiceProxy.Object); var result = await messagingDomainService.SendEmailMessage(TestData.ConnectionIdentifier, TestData.MessageId, @@ -61,11 +61,11 @@ public async Task MessagingDomainService_SendEmailMessage_MessageSent() [Fact] public async Task MessagingDomainService_SendEmailMessage_SecondSend_MessageNotSent() { - Mock> emailAggregateRepository = new Mock>(); + Mock> emailAggregateRepository = new(); emailAggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(TestData.GetSentEmailAggregate()); emailAggregateRepository.Setup(a => a.SaveChanges(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success); - Mock> smsAggregateRepository = new Mock>(); - Mock emailServiceProxy = new Mock(); + Mock> smsAggregateRepository = new(); + Mock emailServiceProxy = new(); emailServiceProxy .Setup(e => e.SendEmail(It.IsAny(), It.IsAny(), @@ -75,10 +75,9 @@ public async Task MessagingDomainService_SendEmailMessage_SecondSend_MessageNotS It.IsAny(), It.IsAny>(), It.IsAny())).ReturnsAsync(TestData.SuccessfulEmailServiceProxyResponse); - Mock smsServiceProxy = new Mock(); + Mock smsServiceProxy = new(); - MessagingDomainService messagingDomainService = - new MessagingDomainService(emailAggregateRepository.Object, smsAggregateRepository.Object, emailServiceProxy.Object, smsServiceProxy.Object); + MessagingDomainService messagingDomainService = new(emailAggregateRepository.Object, smsAggregateRepository.Object, emailServiceProxy.Object, smsServiceProxy.Object); var result = await messagingDomainService.SendEmailMessage(TestData.ConnectionIdentifier, TestData.MessageId, @@ -95,11 +94,11 @@ public async Task MessagingDomainService_SendEmailMessage_SecondSend_MessageNotS [Fact] public async Task MessagingDomainService_SendEmailMessage_SaveFailed_MessageSent() { - Mock> emailAggregateRepository = new Mock>(); + Mock> emailAggregateRepository = new(); emailAggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(TestData.GetEmptyEmailAggregate()); emailAggregateRepository.Setup(a => a.SaveChanges(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure); - Mock> smsAggregateRepository = new Mock>(); - Mock emailServiceProxy = new Mock(); + Mock> smsAggregateRepository = new(); + Mock emailServiceProxy = new(); emailServiceProxy .Setup(e => e.SendEmail(It.IsAny(), It.IsAny(), @@ -109,10 +108,10 @@ [Fact] public async Task MessagingDomainService_SendEmailMessage_SaveFailed_Mess It.IsAny(), It.IsAny>(), It.IsAny())).ReturnsAsync(TestData.SuccessfulEmailServiceProxyResponse); - Mock smsServiceProxy = new Mock(); + Mock smsServiceProxy = new(); MessagingDomainService messagingDomainService = - new MessagingDomainService(emailAggregateRepository.Object, smsAggregateRepository.Object, emailServiceProxy.Object, smsServiceProxy.Object); + new(emailAggregateRepository.Object, smsAggregateRepository.Object, emailServiceProxy.Object, smsServiceProxy.Object); await messagingDomainService.SendEmailMessage(TestData.ConnectionIdentifier, TestData.MessageId, @@ -128,10 +127,10 @@ await messagingDomainService.SendEmailMessage(TestData.ConnectionIdentifier, [Fact] public async Task MessagingDomainService_SendEmailMessage_EmailSentFailed_APICallFailed_MessageFailed() { - Mock> emailAggregateRepository = new Mock>(); + Mock> emailAggregateRepository = new(); emailAggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(TestData.GetEmptyEmailAggregate()); - Mock> smsAggregateRepository = new Mock>(); - Mock emailServiceProxy = new Mock(); + Mock> smsAggregateRepository = new(); + Mock emailServiceProxy = new(); emailServiceProxy .Setup(e => e.SendEmail(It.IsAny(), It.IsAny(), @@ -141,10 +140,10 @@ public async Task MessagingDomainService_SendEmailMessage_EmailSentFailed_APICal It.IsAny(), It.IsAny>(), It.IsAny())).ReturnsAsync(TestData.FailedAPICallEmailServiceProxyResponse); - Mock smsServiceProxy = new Mock(); + Mock smsServiceProxy = new(); MessagingDomainService messagingDomainService = - new MessagingDomainService(emailAggregateRepository.Object, smsAggregateRepository.Object, emailServiceProxy.Object, smsServiceProxy.Object); + new(emailAggregateRepository.Object, smsAggregateRepository.Object, emailServiceProxy.Object, smsServiceProxy.Object); await messagingDomainService.SendEmailMessage(TestData.ConnectionIdentifier, TestData.MessageId, @@ -160,10 +159,10 @@ await messagingDomainService.SendEmailMessage(TestData.ConnectionIdentifier, [Fact] public async Task MessagingDomainService_SendEmailMessage_EmailSentFailed_APIResponseError_MessageFailed() { - Mock> emailAggregateRepository = new Mock>(); + Mock> emailAggregateRepository = new(); emailAggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(TestData.GetEmptyEmailAggregate()); - Mock> smsAggregateRepository = new Mock>(); - Mock emailServiceProxy = new Mock(); + Mock> smsAggregateRepository = new(); + Mock emailServiceProxy = new(); emailServiceProxy .Setup(e => e.SendEmail(It.IsAny(), It.IsAny(), @@ -173,10 +172,10 @@ public async Task MessagingDomainService_SendEmailMessage_EmailSentFailed_APIRes It.IsAny(), It.IsAny>(), It.IsAny())).ReturnsAsync(TestData.FailedEmailServiceProxyResponse); - Mock smsServiceProxy = new Mock(); + Mock smsServiceProxy = new(); MessagingDomainService messagingDomainService = - new MessagingDomainService(emailAggregateRepository.Object, smsAggregateRepository.Object, emailServiceProxy.Object, smsServiceProxy.Object); + new(emailAggregateRepository.Object, smsAggregateRepository.Object, emailServiceProxy.Object, smsServiceProxy.Object); await messagingDomainService.SendEmailMessage(TestData.ConnectionIdentifier, TestData.MessageId, @@ -192,10 +191,10 @@ await messagingDomainService.SendEmailMessage(TestData.ConnectionIdentifier, [Fact] public async Task MessagingDomainService_ResendEmailMessage_MessageSent() { - Mock> emailAggregateRepository = new Mock>(); + Mock> emailAggregateRepository = new(); emailAggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(TestData.GetSentEmailAggregate()); - Mock> smsAggregateRepository = new Mock>(); - Mock emailServiceProxy = new Mock(); + Mock> smsAggregateRepository = new(); + Mock emailServiceProxy = new(); emailServiceProxy .Setup(e => e.SendEmail(It.IsAny(), It.IsAny(), @@ -205,7 +204,7 @@ public async Task MessagingDomainService_ResendEmailMessage_MessageSent() It.IsAny(), It.IsAny>(), It.IsAny())).ReturnsAsync(TestData.SuccessfulEmailServiceProxyResponse); - Mock smsServiceProxy = new Mock(); + Mock smsServiceProxy = new(); MessagingDomainService messagingDomainService = new MessagingDomainService(emailAggregateRepository.Object, smsAggregateRepository.Object, emailServiceProxy.Object, smsServiceProxy.Object); @@ -218,10 +217,10 @@ await messagingDomainService.ResendEmailMessage(TestData.ConnectionIdentifier, [Fact] public async Task MessagingDomainService_ResendEmailMessage_APICallFailed_MessageFailed() { - Mock> emailAggregateRepository = new Mock>(); + Mock> emailAggregateRepository = new(); emailAggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(TestData.GetSentEmailAggregate()); - Mock> smsAggregateRepository = new Mock>(); - Mock emailServiceProxy = new Mock(); + Mock> smsAggregateRepository = new(); + Mock emailServiceProxy = new(); emailServiceProxy .Setup(e => e.SendEmail(It.IsAny(), It.IsAny(), @@ -231,10 +230,10 @@ public async Task MessagingDomainService_ResendEmailMessage_APICallFailed_Messag It.IsAny(), It.IsAny>(), It.IsAny())).ReturnsAsync(TestData.FailedAPICallEmailServiceProxyResponse); - Mock smsServiceProxy = new Mock(); + Mock smsServiceProxy = new(); MessagingDomainService messagingDomainService = - new MessagingDomainService(emailAggregateRepository.Object, smsAggregateRepository.Object, emailServiceProxy.Object, smsServiceProxy.Object); + new(emailAggregateRepository.Object, smsAggregateRepository.Object, emailServiceProxy.Object, smsServiceProxy.Object); await messagingDomainService.ResendEmailMessage(TestData.ConnectionIdentifier, TestData.MessageId, @@ -244,10 +243,10 @@ await messagingDomainService.ResendEmailMessage(TestData.ConnectionIdentifier, [Fact] public async Task MessagingDomainService_ResendEmailMessage_APIResponseError_MessageFailed() { - Mock> emailAggregateRepository = new Mock>(); + Mock> emailAggregateRepository = new(); emailAggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(TestData.GetSentEmailAggregate()); - Mock> smsAggregateRepository = new Mock>(); - Mock emailServiceProxy = new Mock(); + Mock> smsAggregateRepository = new(); + Mock emailServiceProxy = new(); emailServiceProxy .Setup(e => e.SendEmail(It.IsAny(), It.IsAny(), @@ -257,7 +256,7 @@ public async Task MessagingDomainService_ResendEmailMessage_APIResponseError_Mes It.IsAny(), It.IsAny>(), It.IsAny())).ReturnsAsync(TestData.FailedEmailServiceProxyResponse); - Mock smsServiceProxy = new Mock(); + Mock smsServiceProxy = new(); MessagingDomainService messagingDomainService = new MessagingDomainService(emailAggregateRepository.Object, smsAggregateRepository.Object, emailServiceProxy.Object, smsServiceProxy.Object); @@ -270,12 +269,12 @@ await messagingDomainService.ResendEmailMessage(TestData.ConnectionIdentifier, [Fact] public async Task MessagingDomainService_SendSMSMessage_MessageSent() { - Mock> emailAggregateRepository = new Mock>(); - Mock> smsAggregateRepository = new Mock>(); + Mock> emailAggregateRepository = new(); + Mock> smsAggregateRepository = new(); smsAggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(TestData.GetEmptySMSAggregate()); smsAggregateRepository.Setup(a => a.SaveChanges(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success()); - Mock emailServiceProxy = new Mock(); - Mock smsServiceProxy = new Mock(); + Mock emailServiceProxy = new(); + Mock smsServiceProxy = new(); smsServiceProxy .Setup(e => e.SendSMS(It.IsAny(), It.IsAny(), @@ -283,7 +282,7 @@ public async Task MessagingDomainService_SendSMSMessage_MessageSent() It.IsAny(), It.IsAny())).ReturnsAsync(TestData.SuccessfulSMSServiceProxyResponse); MessagingDomainService messagingDomainService = - new MessagingDomainService(emailAggregateRepository.Object, smsAggregateRepository.Object, emailServiceProxy.Object, smsServiceProxy.Object); + new(emailAggregateRepository.Object, smsAggregateRepository.Object, emailServiceProxy.Object, smsServiceProxy.Object); var result = await messagingDomainService.SendSMSMessage(TestData.ConnectionIdentifier, TestData.MessageId, @@ -299,12 +298,12 @@ public async Task MessagingDomainService_SendSMSMessage_MessageSent() [Fact] public async Task MessagingDomainService_SendSMSMessage_SecondTime_MessageNotSent() { - Mock> emailAggregateRepository = new Mock>(); - Mock> smsAggregateRepository = new Mock>(); + Mock> emailAggregateRepository = new(); + Mock> smsAggregateRepository = new(); smsAggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(TestData.GetSentSMSAggregate()); smsAggregateRepository.Setup(a => a.SaveChanges(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success()); - Mock emailServiceProxy = new Mock(); - Mock smsServiceProxy = new Mock(); + Mock emailServiceProxy = new(); + Mock smsServiceProxy = new(); smsServiceProxy .Setup(e => e.SendSMS(It.IsAny(), It.IsAny(), @@ -312,7 +311,7 @@ public async Task MessagingDomainService_SendSMSMessage_SecondTime_MessageNotSen It.IsAny(), It.IsAny())).ReturnsAsync(TestData.SuccessfulSMSServiceProxyResponse); MessagingDomainService messagingDomainService = - new MessagingDomainService(emailAggregateRepository.Object, smsAggregateRepository.Object, emailServiceProxy.Object, smsServiceProxy.Object); + new(emailAggregateRepository.Object, smsAggregateRepository.Object, emailServiceProxy.Object, smsServiceProxy.Object); var result = await messagingDomainService.SendSMSMessage(TestData.ConnectionIdentifier, TestData.MessageId, @@ -328,12 +327,12 @@ public async Task MessagingDomainService_SendSMSMessage_SecondTime_MessageNotSen [Fact] public async Task MessagingDomainService_SendSMSMessage_SaveFailed_MessageSent() { - Mock> emailAggregateRepository = new Mock>(); - Mock> smsAggregateRepository = new Mock>(); + Mock> emailAggregateRepository = new(); + Mock> smsAggregateRepository = new(); smsAggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(TestData.GetEmptySMSAggregate()); smsAggregateRepository.Setup(a => a.SaveChanges(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure); - Mock emailServiceProxy = new Mock(); - Mock smsServiceProxy = new Mock(); + Mock emailServiceProxy = new(); + Mock smsServiceProxy = new(); smsServiceProxy .Setup(e => e.SendSMS(It.IsAny(), It.IsAny(), @@ -341,7 +340,7 @@ public async Task MessagingDomainService_SendSMSMessage_SaveFailed_MessageSent() It.IsAny(), It.IsAny())).ReturnsAsync(TestData.SuccessfulSMSServiceProxyResponse); MessagingDomainService messagingDomainService = - new MessagingDomainService(emailAggregateRepository.Object, smsAggregateRepository.Object, emailServiceProxy.Object, smsServiceProxy.Object); + new(emailAggregateRepository.Object, smsAggregateRepository.Object, emailServiceProxy.Object, smsServiceProxy.Object); await messagingDomainService.SendSMSMessage(TestData.ConnectionIdentifier, TestData.MessageId, @@ -354,11 +353,11 @@ await messagingDomainService.SendSMSMessage(TestData.ConnectionIdentifier, [Fact] public async Task MessagingDomainService_ReSendSMSMessage_MessageSent() { - Mock> emailAggregateRepository = new Mock>(); - Mock> smsAggregateRepository = new Mock>(); + Mock> emailAggregateRepository = new(); + Mock> smsAggregateRepository = new(); smsAggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(TestData.GetSentSMSAggregate()); - Mock emailServiceProxy = new Mock(); - Mock smsServiceProxy = new Mock(); + Mock emailServiceProxy = new(); + Mock smsServiceProxy = new(); smsServiceProxy .Setup(e => e.SendSMS(It.IsAny(), It.IsAny(), @@ -366,7 +365,7 @@ public async Task MessagingDomainService_ReSendSMSMessage_MessageSent() It.IsAny(), It.IsAny())).ReturnsAsync(TestData.SuccessfulSMSServiceProxyResponse); MessagingDomainService messagingDomainService = - new MessagingDomainService(emailAggregateRepository.Object, smsAggregateRepository.Object, emailServiceProxy.Object, smsServiceProxy.Object); + new(emailAggregateRepository.Object, smsAggregateRepository.Object, emailServiceProxy.Object, smsServiceProxy.Object); await messagingDomainService.ResendSMSMessage(TestData.ConnectionIdentifier, TestData.MessageId, @@ -376,11 +375,11 @@ await messagingDomainService.ResendSMSMessage(TestData.ConnectionIdentifier, [Fact] public async Task MessagingDomainService_ReSendSMSMessage_APICallFailed_MessageFailed() { - Mock> emailAggregateRepository = new Mock>(); - Mock> smsAggregateRepository = new Mock>(); + Mock> emailAggregateRepository = new(); + Mock> smsAggregateRepository = new(); smsAggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(TestData.GetSentSMSAggregate()); - Mock emailServiceProxy = new Mock(); - Mock smsServiceProxy = new Mock(); + Mock emailServiceProxy = new(); + Mock smsServiceProxy = new(); smsServiceProxy .Setup(e => e.SendSMS(It.IsAny(), It.IsAny(), @@ -398,19 +397,18 @@ await messagingDomainService.ResendSMSMessage(TestData.ConnectionIdentifier, [Fact] public async Task MessagingDomainService_ReSendSMSMessage_APIResponseError_MessageFailed() { - Mock> emailAggregateRepository = new Mock>(); - Mock> smsAggregateRepository = new Mock>(); + Mock> emailAggregateRepository = new(); + Mock> smsAggregateRepository = new(); smsAggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(TestData.GetSentSMSAggregate()); - Mock emailServiceProxy = new Mock(); - Mock smsServiceProxy = new Mock(); + Mock emailServiceProxy = new(); + Mock smsServiceProxy = new(); smsServiceProxy .Setup(e => e.SendSMS(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(TestData.FailedSMSServiceProxyResponse); - MessagingDomainService messagingDomainService = - new MessagingDomainService(emailAggregateRepository.Object, smsAggregateRepository.Object, emailServiceProxy.Object, smsServiceProxy.Object); + MessagingDomainService messagingDomainService = new(emailAggregateRepository.Object, smsAggregateRepository.Object, emailServiceProxy.Object, smsServiceProxy.Object); await messagingDomainService.ResendSMSMessage(TestData.ConnectionIdentifier, TestData.MessageId, @@ -427,13 +425,13 @@ await messagingDomainService.ResendSMSMessage(TestData.ConnectionIdentifier, [InlineData(BusinessLogic.Services.SMSServices.MessageStatus.Incoming)] public async Task MessagingDomainService_UpdateSMSMessageStatus_MessageUpdated(BusinessLogic.Services.SMSServices.MessageStatus status) { - Mock> emailAggregateRepository = new Mock>(); - Mock> smsAggregateRepository = new Mock>(); + Mock> emailAggregateRepository = new(); + Mock> smsAggregateRepository = new(); smsAggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(TestData.GetSentSMSAggregate()); - Mock emailServiceProxy = new Mock(); - Mock smsServiceProxy = new Mock(); + Mock emailServiceProxy = new(); + Mock smsServiceProxy = new(); MessagingDomainService messagingDomainService = - new MessagingDomainService(emailAggregateRepository.Object, smsAggregateRepository.Object, emailServiceProxy.Object, smsServiceProxy.Object); + new(emailAggregateRepository.Object, smsAggregateRepository.Object, emailServiceProxy.Object, smsServiceProxy.Object); SMSCommands.UpdateMessageStatusCommand command = new(TestData.MessageId, status, TestData.ProviderStatusDescription, TestData.BouncedDateTime); Should.NotThrow(async () => { @@ -450,13 +448,13 @@ public async Task MessagingDomainService_UpdateSMSMessageStatus_MessageUpdated(B public async Task MessagingDomainService_UpdateEmailMessageStatus_MessageUpdated(BusinessLogic.Services.EmailServices.MessageStatus status) { - Mock> emailAggregateRepository = new Mock>(); + Mock> emailAggregateRepository = new(); emailAggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(TestData.GetSentEmailAggregate()); - Mock> smsAggregateRepository = new Mock>(); - Mock emailServiceProxy = new Mock(); - Mock smsServiceProxy = new Mock(); + Mock> smsAggregateRepository = new(); + Mock emailServiceProxy = new(); + Mock smsServiceProxy = new(); MessagingDomainService messagingDomainService = - new MessagingDomainService(emailAggregateRepository.Object, smsAggregateRepository.Object, emailServiceProxy.Object, smsServiceProxy.Object); + new(emailAggregateRepository.Object, smsAggregateRepository.Object, emailServiceProxy.Object, smsServiceProxy.Object); EmailCommands.UpdateMessageStatusCommand command = new(TestData.MessageId, status, TestData.ProviderStatusDescription, TestData.BouncedDateTime); Should.NotThrow(async () => { diff --git a/MessagingService.BusinessLogic/Services/EmailServices/Smtp2Go/Smtp2GoProxy.cs b/MessagingService.BusinessLogic/Services/EmailServices/Smtp2Go/Smtp2GoProxy.cs index efb3730..1c2a771 100644 --- a/MessagingService.BusinessLogic/Services/EmailServices/Smtp2Go/Smtp2GoProxy.cs +++ b/MessagingService.BusinessLogic/Services/EmailServices/Smtp2Go/Smtp2GoProxy.cs @@ -87,7 +87,7 @@ public async Task SendEmail(Guid messageId, StringContent content = new(requestSerialised, Encoding.UTF8, "application/json"); String requestUri = $"{ConfigurationReader.GetValue("SMTP2GoBaseAddress")}email/send"; - HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Post, requestUri); + HttpRequestMessage requestMessage = new(HttpMethod.Post, requestUri); requestMessage.Content = content; HttpResponseMessage httpResponse = await this.HttpClient.SendAsync(requestMessage, cancellationToken); @@ -135,7 +135,7 @@ public async Task GetMessageStatus(String providerReferen { MessageStatusResponse response = null; - Smtp2GoEmailSearchRequest apiRequest = new Smtp2GoEmailSearchRequest + Smtp2GoEmailSearchRequest apiRequest = new() { ApiKey = ConfigurationReader.GetValue("SMTP2GoAPIKey"), EmailId = new List @@ -153,10 +153,10 @@ public async Task GetMessageStatus(String providerReferen Logger.LogDebug($"Request Message Sent to Email Provider [SMTP2Go] {requestSerialised}"); - StringContent content = new StringContent(requestSerialised, Encoding.UTF8, "application/json"); + StringContent content = new(requestSerialised, Encoding.UTF8, "application/json"); String requestUri = $"{ConfigurationReader.GetValue("SMTP2GoBaseAddress")}email/search"; - HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Post, requestUri); + HttpRequestMessage requestMessage = new(HttpMethod.Post, requestUri); requestMessage.Content = content; HttpResponseMessage httpResponse = await this.HttpClient.SendAsync(requestMessage, cancellationToken); diff --git a/MessagingService.BusinessLogic/Services/SMSServices/TheSMSWorks/TheSmsWorksProxy.cs b/MessagingService.BusinessLogic/Services/SMSServices/TheSMSWorks/TheSmsWorksProxy.cs index 325f234..01d7def 100644 --- a/MessagingService.BusinessLogic/Services/SMSServices/TheSMSWorks/TheSmsWorksProxy.cs +++ b/MessagingService.BusinessLogic/Services/SMSServices/TheSMSWorks/TheSmsWorksProxy.cs @@ -41,10 +41,10 @@ public async Task SendSMS(Guid messageId, SMSServiceProxyResponse response = null; // Create the Auth Request - TheSmsWorksTokenRequest apiTokenRequest = new TheSmsWorksTokenRequest { CustomerId = ConfigurationReader.GetValue("TheSMSWorksCustomerId"), Key = ConfigurationReader.GetValue("TheSMSWorksKey"), Secret = ConfigurationReader.GetValue("TheSMSWorksSecret") }; + TheSmsWorksTokenRequest apiTokenRequest = new() { CustomerId = ConfigurationReader.GetValue("TheSMSWorksCustomerId"), Key = ConfigurationReader.GetValue("TheSMSWorksKey"), Secret = ConfigurationReader.GetValue("TheSMSWorksSecret") }; String apiTokenRequestSerialised = JsonConvert.SerializeObject(apiTokenRequest).ToLower(); - StringContent content = new StringContent(apiTokenRequestSerialised, Encoding.UTF8, "application/json"); + StringContent content = new(apiTokenRequestSerialised, Encoding.UTF8, "application/json"); // First do the authentication HttpResponseMessage apiTokenHttpResponse = await this.HttpClient.PostAsync($"{ConfigurationReader.GetValue("TheSMSWorksBaseAddress")}auth/token", content, cancellationToken); @@ -53,7 +53,7 @@ public async Task SendSMS(Guid messageId, TheSmsWorksTokenResponse apiTokenResponse = JsonConvert.DeserializeObject(await apiTokenHttpResponse.Content.ReadAsStringAsync()); // Now do the actual send - TheSmsWorksSendSMSRequest apiSendSmsRequest = new TheSmsWorksSendSMSRequest { + TheSmsWorksSendSMSRequest apiSendSmsRequest = new() { Content = message, Sender = sender, Destination = destination, @@ -87,13 +87,13 @@ public async Task SendSMS(Guid messageId, public async Task GetMessageStatus(String providerReference, CancellationToken cancellationToken) { - MessageStatusResponse response = new MessageStatusResponse(); + MessageStatusResponse response = new(); // Create the Auth Request - TheSmsWorksTokenRequest apiTokenRequest = new TheSmsWorksTokenRequest { CustomerId = ConfigurationReader.GetValue("TheSMSWorksCustomerId"), Key = ConfigurationReader.GetValue("TheSMSWorksKey"), Secret = ConfigurationReader.GetValue("TheSMSWorksSecret") }; + TheSmsWorksTokenRequest apiTokenRequest = new() { CustomerId = ConfigurationReader.GetValue("TheSMSWorksCustomerId"), Key = ConfigurationReader.GetValue("TheSMSWorksKey"), Secret = ConfigurationReader.GetValue("TheSMSWorksSecret") }; String apiTokenRequestSerialised = JsonConvert.SerializeObject(apiTokenRequest).ToLower(); - StringContent content = new StringContent(apiTokenRequestSerialised, Encoding.UTF8, "application/json"); + StringContent content = new(apiTokenRequestSerialised, Encoding.UTF8, "application/json"); // First do the authentication HttpResponseMessage apiTokenHttpResponse = await this.HttpClient.PostAsync($"{ConfigurationReader.GetValue("TheSMSWorksBaseAddress")}auth/token", content, cancellationToken); @@ -159,7 +159,7 @@ private MessageStatus TranslateMessageStatus(String status) /// private async Task HandleAPIError(HttpResponseMessage httpResponse) { - SMSServiceProxyResponse response = new SMSServiceProxyResponse(); + SMSServiceProxyResponse response = new(); String responseContent = await httpResponse.Content.ReadAsStringAsync(); diff --git a/MessagingService.Client/MessagingServiceClient.cs b/MessagingService.Client/MessagingServiceClient.cs index e5a7a20..5d38602 100644 --- a/MessagingService.Client/MessagingServiceClient.cs +++ b/MessagingService.Client/MessagingServiceClient.cs @@ -70,7 +70,7 @@ public async Task SendEmail(String accessToken, { String requestSerialised = JsonConvert.SerializeObject(sendEmailRequest); - StringContent httpContent = new StringContent(requestSerialised, Encoding.UTF8, "application/json"); + StringContent httpContent = new(requestSerialised, Encoding.UTF8, "application/json"); // Add the access token to the client headers this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); @@ -89,7 +89,7 @@ public async Task SendEmail(String accessToken, catch(Exception ex) { // An exception has occurred, add some additional information to the message - Exception exception = new Exception("Error sending email message.", ex); + Exception exception = new("Error sending email message.", ex); throw exception; } @@ -103,7 +103,7 @@ public async Task ResendEmail(String accessToken, try { String requestSerialised = JsonConvert.SerializeObject(resendEmailRequest); - StringContent httpContent = new StringContent(requestSerialised, Encoding.UTF8, "application/json"); + StringContent httpContent = new(requestSerialised, Encoding.UTF8, "application/json"); // Add the access token to the client headers this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); @@ -121,7 +121,7 @@ public async Task ResendEmail(String accessToken, } catch(Exception ex) { // An exception has occurred, add some additional information to the message - Exception exception = new Exception("Error re-sending email message.", ex); + Exception exception = new("Error re-sending email message.", ex); throw exception; } @@ -146,7 +146,7 @@ public async Task SendSMS(String accessToken, { String requestSerialised = JsonConvert.SerializeObject(sendSMSRequest); - StringContent httpContent = new StringContent(requestSerialised, Encoding.UTF8, "application/json"); + StringContent httpContent = new(requestSerialised, Encoding.UTF8, "application/json"); // Add the access token to the client headers this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); @@ -165,7 +165,7 @@ public async Task SendSMS(String accessToken, catch (Exception ex) { // An exception has occurred, add some additional information to the message - Exception exception = new Exception("Error sending sms message.", ex); + Exception exception = new("Error sending sms message.", ex); throw exception; } diff --git a/MessagingService.EmailAggregate.Tests/EmailAggregateTests.cs b/MessagingService.EmailAggregate.Tests/EmailAggregateTests.cs index 560c102..f034bb7 100644 --- a/MessagingService.EmailAggregate.Tests/EmailAggregateTests.cs +++ b/MessagingService.EmailAggregate.Tests/EmailAggregateTests.cs @@ -412,7 +412,7 @@ public void EmailAggregate_ResendRequestToProvider_Bounced_ErrorThrown() { [Fact] public void EmailAggregate_PlayEvent_UnsupportedEvent_ErrorThrown() { Logger.Initialise(NullLogger.Instance); - EmailAggregate emailAggregate = new EmailAggregate(); + EmailAggregate emailAggregate = new(); Should.Throw(() => emailAggregate.PlayEvent(new TestEvent(Guid.NewGuid(), Guid.NewGuid()))); } } diff --git a/MessagingService.EmailMessageAggregate/EmailAggregate.cs b/MessagingService.EmailMessageAggregate/EmailAggregate.cs index cb8cd5b..9036ab1 100644 --- a/MessagingService.EmailMessageAggregate/EmailAggregate.cs +++ b/MessagingService.EmailMessageAggregate/EmailAggregate.cs @@ -19,7 +19,7 @@ public static void MarkMessageAsBounced(this EmailAggregate aggregate, String pr return; aggregate.CheckMessageCanBeSetToBounced(); - EmailMessageBouncedEvent messageBouncedEvent = new EmailMessageBouncedEvent(aggregate.AggregateId, providerStatus, bouncedDateTime); + EmailMessageBouncedEvent messageBouncedEvent = new(aggregate.AggregateId, providerStatus, bouncedDateTime); aggregate.ApplyAndAppend(messageBouncedEvent); } @@ -31,7 +31,7 @@ public static void MarkMessageAsDelivered(this EmailAggregate aggregate, String return; aggregate.CheckMessageCanBeSetToDelivered(); - EmailMessageDeliveredEvent messageDeliveredEvent = new EmailMessageDeliveredEvent(aggregate.AggregateId, providerStatus, deliveredDateTime); + EmailMessageDeliveredEvent messageDeliveredEvent = new(aggregate.AggregateId, providerStatus, deliveredDateTime); aggregate.ApplyAndAppend(messageDeliveredEvent); } @@ -43,7 +43,7 @@ public static void MarkMessageAsFailed(this EmailAggregate aggregate, String pro return; aggregate.CheckMessageCanBeSetToFailed(); - EmailMessageFailedEvent messageFailedEvent = new EmailMessageFailedEvent(aggregate.AggregateId, providerStatus, failedDateTime); + EmailMessageFailedEvent messageFailedEvent = new(aggregate.AggregateId, providerStatus, failedDateTime); aggregate.ApplyAndAppend(messageFailedEvent); } @@ -55,7 +55,7 @@ public static void MarkMessageAsRejected(this EmailAggregate aggregate, String p return; aggregate.CheckMessageCanBeSetToRejected(); - EmailMessageRejectedEvent messageRejectedEvent = new EmailMessageRejectedEvent(aggregate.AggregateId, providerStatus, rejectedDateTime); + EmailMessageRejectedEvent messageRejectedEvent = new(aggregate.AggregateId, providerStatus, rejectedDateTime); aggregate.ApplyAndAppend(messageRejectedEvent); } @@ -67,7 +67,7 @@ public static void MarkMessageAsSpam(this EmailAggregate aggregate, String provi return; aggregate.CheckMessageCanBeSetToSpam(); - EmailMessageMarkedAsSpamEvent messageMarkedAsSpamEvent = new EmailMessageMarkedAsSpamEvent(aggregate.AggregateId, providerStatus, spamDateTime); + EmailMessageMarkedAsSpamEvent messageMarkedAsSpamEvent = new(aggregate.AggregateId, providerStatus, spamDateTime); aggregate.ApplyAndAppend(messageMarkedAsSpamEvent); } @@ -76,7 +76,7 @@ public static void ReceiveResponseFromProvider(this EmailAggregate aggregate, St String providerEmailReference) { ResponseReceivedFromEmailProviderEvent responseReceivedFromProviderEvent = - new ResponseReceivedFromEmailProviderEvent(aggregate.AggregateId, providerRequestReference, providerEmailReference); + new(aggregate.AggregateId, providerRequestReference, providerEmailReference); aggregate.ApplyAndAppend(responseReceivedFromProviderEvent); } @@ -84,7 +84,7 @@ public static void ReceiveResponseFromProvider(this EmailAggregate aggregate, St public static void ReceiveBadResponseFromProvider(this EmailAggregate aggregate, String error, String errorCode) { BadResponseReceivedFromEmailProviderEvent badResponseReceivedFromProviderEvent = - new BadResponseReceivedFromEmailProviderEvent(aggregate.AggregateId, errorCode, error); + new(aggregate.AggregateId, errorCode, error); aggregate.ApplyAndAppend(badResponseReceivedFromProviderEvent); } @@ -101,14 +101,14 @@ public static void SendRequestToProvider(this EmailAggregate aggregate, String f Boolean isHtml, List attachments) { - RequestSentToEmailProviderEvent requestSentToProviderEvent = new RequestSentToEmailProviderEvent(aggregate.AggregateId, fromAddress, toAddresses, subject, body, isHtml); + RequestSentToEmailProviderEvent requestSentToProviderEvent = new(aggregate.AggregateId, fromAddress, toAddresses, subject, body, isHtml); aggregate.ApplyAndAppend(requestSentToProviderEvent); // Record the attachment data foreach (EmailAttachment emailAttachment in attachments) { - EmailAttachmentRequestSentToProviderEvent emailAttachmentRequestSentToProviderEvent = new EmailAttachmentRequestSentToProviderEvent(aggregate.AggregateId, + EmailAttachmentRequestSentToProviderEvent emailAttachmentRequestSentToProviderEvent = new(aggregate.AggregateId, emailAttachment.Filename, emailAttachment.FileData, (Int32)emailAttachment.FileType); @@ -124,7 +124,7 @@ public static void ResendRequestToProvider(this EmailAggregate aggregate) throw new InvalidOperationException($"Cannot re-send a message to provider that has not already been sent. Current Status [{aggregate.DeliveryStatusList[aggregate.ResendCount]}]"); } - RequestResentToEmailProviderEvent requestResentToEmailProviderEvent = new RequestResentToEmailProviderEvent(aggregate.AggregateId); + RequestResentToEmailProviderEvent requestResentToEmailProviderEvent = new(aggregate.AggregateId); aggregate.ApplyAndAppend(requestResentToEmailProviderEvent); } @@ -181,7 +181,7 @@ public static void PlayEvent(this EmailAggregate aggregate, RequestSentToEmailPr foreach (String domainEventToAddress in domainEvent.ToAddresses) { - MessageRecipient messageRecipient = new MessageRecipient(); + MessageRecipient messageRecipient = new(); messageRecipient.Create(domainEventToAddress); aggregate.Recipients.Add(messageRecipient); } diff --git a/MessagingService.IntegrationTesting.Helpers/SpecflowExtensions.cs b/MessagingService.IntegrationTesting.Helpers/SpecflowExtensions.cs index a25ff4c..ee2f362 100644 --- a/MessagingService.IntegrationTesting.Helpers/SpecflowExtensions.cs +++ b/MessagingService.IntegrationTesting.Helpers/SpecflowExtensions.cs @@ -6,7 +6,7 @@ public static class ReqnrollExtensions{ public static List ToSendEmailRequests(this DataTableRows tableRows){ - List requests = new List(); + List requests = new(); foreach (DataTableRow tableRow in tableRows){ String fromAddress = ReqnrollTableHelper.GetStringRowValue(tableRow, "FromAddress"); String toAddresses = ReqnrollTableHelper.GetStringRowValue(tableRow, "ToAddresses"); @@ -14,7 +14,7 @@ public static List ToSendEmailRequests(this DataTableRows tabl String body = ReqnrollTableHelper.GetStringRowValue(tableRow, "Body"); Boolean isHtml = ReqnrollTableHelper.GetBooleanValue(tableRow, "IsHtml"); - SendEmailRequest request = new SendEmailRequest + SendEmailRequest request = new() { Body = body, ConnectionIdentifier = Guid.NewGuid(), @@ -31,13 +31,13 @@ public static List ToSendEmailRequests(this DataTableRows tabl public static List ToResendEmailRequests(this DataTableRows tableRows, Dictionary sendResponses) { - List requests = new List(); + List requests = new(); foreach (DataTableRow tableRow in tableRows){ String toAddresses = ReqnrollTableHelper.GetStringRowValue(tableRow, "ToAddresses"); SendEmailResponse sendEmailResponse = sendResponses[toAddresses]; - ResendEmailRequest request = new ResendEmailRequest() + ResendEmailRequest request = new() { ConnectionIdentifier = Guid.NewGuid(), MessageId = sendEmailResponse.MessageId @@ -48,14 +48,14 @@ public static List ToResendEmailRequests(this DataTableRows } public static List ToSendSMSRequests(this DataTableRows tableRows){ - List requests = new List(); + List requests = new(); foreach (DataTableRow tableRow in tableRows){ String sender = ReqnrollTableHelper.GetStringRowValue(tableRow, "Sender"); String destination = ReqnrollTableHelper.GetStringRowValue(tableRow, "Destination"); String message = ReqnrollTableHelper.GetStringRowValue(tableRow, "Message"); - SendSMSRequest request = new SendSMSRequest + SendSMSRequest request = new() { ConnectionIdentifier = Guid.NewGuid(), Sender = sender, diff --git a/MessagingService.IntegrationTests/Common/DockerHelper.cs b/MessagingService.IntegrationTests/Common/DockerHelper.cs index 9cf6c40..6be51e8 100644 --- a/MessagingService.IntegrationTests/Common/DockerHelper.cs +++ b/MessagingService.IntegrationTests/Common/DockerHelper.cs @@ -89,16 +89,16 @@ public override async Task StartContainersForScenarioRun(String scenarioName, Do private HttpClient CreateHttpClient() { // Set up test HttpContext - DefaultHttpContext context = new DefaultHttpContext(); + DefaultHttpContext context = new(); context.TraceIdentifier = this.TestId.ToString(); - HttpContextAccessor httpContextAccessor = new HttpContextAccessor + HttpContextAccessor httpContextAccessor = new() { HttpContext = context }; // Configure inner-most handler with SSL bypass - HttpClientHandler clientHandler = new HttpClientHandler + HttpClientHandler clientHandler = new() { ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => true }; diff --git a/MessagingService.IntegrationTests/Common/GenericSteps.cs b/MessagingService.IntegrationTests/Common/GenericSteps.cs index a11fa1a..f11eb6f 100644 --- a/MessagingService.IntegrationTests/Common/GenericSteps.cs +++ b/MessagingService.IntegrationTests/Common/GenericSteps.cs @@ -31,13 +31,13 @@ public async Task StartSystem() // Initialise a logger String scenarioName = this.ScenarioContext.ScenarioInfo.Title.Replace(" ", ""); - NlogLogger logger = new NlogLogger(); + NlogLogger logger = new(); logger.Initialise(LogManager.GetLogger(scenarioName), scenarioName); LogManager.AddHiddenAssembly(typeof(NlogLogger).Assembly); DockerServices dockerServices = DockerServices.SqlServer | DockerServices.MessagingService | DockerServices.EventStore | DockerServices.SecurityService; - this.TestingContext.DockerHelper = new DockerHelper(); + this.TestingContext.DockerHelper = new(); this.TestingContext.DockerHelper.Logger = logger; this.TestingContext.Logger = logger; this.TestingContext.DockerHelper.RequiredDockerServices = dockerServices; diff --git a/MessagingService.SMSAggregate.Tests/SMSAggregateTests.cs b/MessagingService.SMSAggregate.Tests/SMSAggregateTests.cs index 0d21a2b..eb12c01 100644 --- a/MessagingService.SMSAggregate.Tests/SMSAggregateTests.cs +++ b/MessagingService.SMSAggregate.Tests/SMSAggregateTests.cs @@ -349,7 +349,7 @@ public void SMSAggregate_ResendRequestToProvider_Undelivered_ErrorThrown() public void SMSAggregate_PlayEvent_UnsupportedEvent_ErrorThrown() { Logger.Initialise(NullLogger.Instance); - SMSAggregate smsAggregate = new SMSAggregate(); + SMSAggregate smsAggregate = new(); Should.Throw(() => smsAggregate.PlayEvent(new TestEvent(Guid.NewGuid(), Guid.NewGuid()))); } } diff --git a/MessagingService.SMSMessageAggregate/SMSAggregate.cs b/MessagingService.SMSMessageAggregate/SMSAggregate.cs index 4da93d4..863e200 100644 --- a/MessagingService.SMSMessageAggregate/SMSAggregate.cs +++ b/MessagingService.SMSMessageAggregate/SMSAggregate.cs @@ -26,7 +26,7 @@ public static void MarkMessageAsDelivered(this SMSAggregate aggregate, aggregate.CheckMessageCanBeSetToDelivered(); - SMSMessageDeliveredEvent messageDeliveredEvent = new SMSMessageDeliveredEvent(aggregate.AggregateId, providerStatus, failedDateTime); + SMSMessageDeliveredEvent messageDeliveredEvent = new(aggregate.AggregateId, providerStatus, failedDateTime); aggregate.ApplyAndAppend(messageDeliveredEvent); } @@ -38,7 +38,7 @@ public static void MarkMessageAsExpired(this SMSAggregate aggregate, return; aggregate.CheckMessageCanBeSetToExpired(); - SMSMessageExpiredEvent messageExpiredEvent = new SMSMessageExpiredEvent(aggregate.AggregateId, providerStatus, failedDateTime); + SMSMessageExpiredEvent messageExpiredEvent = new(aggregate.AggregateId, providerStatus, failedDateTime); aggregate.ApplyAndAppend(messageExpiredEvent); } @@ -50,7 +50,7 @@ public static void MarkMessageAsRejected(this SMSAggregate aggregate, return; aggregate.CheckMessageCanBeSetToRejected(); - SMSMessageRejectedEvent messageRejectedEvent = new SMSMessageRejectedEvent(aggregate.AggregateId, providerStatus, failedDateTime); + SMSMessageRejectedEvent messageRejectedEvent = new(aggregate.AggregateId, providerStatus, failedDateTime); aggregate.ApplyAndAppend(messageRejectedEvent); } @@ -62,7 +62,7 @@ public static void MarkMessageAsUndeliverable(this SMSAggregate aggregate, return; aggregate.CheckMessageCanBeSetToUndeliverable(); - SMSMessageUndeliveredEvent messageUndeliveredEvent = new SMSMessageUndeliveredEvent(aggregate.AggregateId, providerStatus, failedDateTime); + SMSMessageUndeliveredEvent messageUndeliveredEvent = new(aggregate.AggregateId, providerStatus, failedDateTime); aggregate.ApplyAndAppend(messageUndeliveredEvent); } @@ -102,7 +102,7 @@ public static void PlayEvent(this SMSAggregate aggregate, RequestResentToSMSProv public static void ReceiveResponseFromProvider(this SMSAggregate aggregate, String providerSMSReference){ ResponseReceivedFromSMSProviderEvent responseReceivedFromProviderEvent = - new ResponseReceivedFromSMSProviderEvent(aggregate.AggregateId, providerSMSReference); + new(aggregate.AggregateId, providerSMSReference); aggregate.ApplyAndAppend(responseReceivedFromProviderEvent); } @@ -113,7 +113,7 @@ public static void ResendRequestToProvider(this SMSAggregate aggregate){ throw new InvalidOperationException($"Cannot re-send a message to provider that has not already been sent. Current Status [{aggregate.DeliveryStatusList[aggregate.ResendCount]}]"); } - RequestResentToSMSProviderEvent requestResentToSMSProviderEvent = new RequestResentToSMSProviderEvent(aggregate.AggregateId); + RequestResentToSMSProviderEvent requestResentToSMSProviderEvent = new(aggregate.AggregateId); aggregate.ApplyAndAppend(requestResentToSMSProviderEvent); } @@ -124,7 +124,7 @@ public static void SendRequestToProvider(this SMSAggregate aggregate, String message){ - RequestSentToSMSProviderEvent requestSentToProviderEvent = new RequestSentToSMSProviderEvent(aggregate.AggregateId, sender, destination, message); + RequestSentToSMSProviderEvent requestSentToProviderEvent = new(aggregate.AggregateId, sender, destination, message); aggregate.ApplyAndAppend(requestSentToProviderEvent); } diff --git a/MessagingService.Testing/TestData.cs b/MessagingService.Testing/TestData.cs index fb19767..a0586d4 100644 --- a/MessagingService.Testing/TestData.cs +++ b/MessagingService.Testing/TestData.cs @@ -272,14 +272,14 @@ public class TestData public static EmailAggregate GetEmptyEmailAggregate() { - EmailAggregate emailAggregate = new EmailAggregate(); + EmailAggregate emailAggregate = new(); return emailAggregate; } public static EmailAggregate GetSentEmailAggregate() { - EmailAggregate emailAggregate = new EmailAggregate(); + EmailAggregate emailAggregate = new(); emailAggregate.SendRequestToProvider(TestData.FromAddress, TestData.ToAddresses, TestData.Subject, TestData.Body, TestData.IsHtmlTrue, TestData.EmailAttachmentModels); emailAggregate.ReceiveResponseFromProvider(TestData.ProviderRequestReference, TestData.ProviderEmailReference); @@ -318,14 +318,14 @@ public static EmailAggregate GetSentEmailAggregate() public static SMSAggregate GetEmptySMSAggregate() { - SMSAggregate smsAggregate = new SMSAggregate(); + SMSAggregate smsAggregate = new(); return smsAggregate; } public static SMSAggregate GetSentSMSAggregate() { - SMSAggregate smsAggregate = new SMSAggregate(); + SMSAggregate smsAggregate = new(); smsAggregate.SendRequestToProvider(TestData.Sender, TestData.Destination, TestData.Message); smsAggregate.ReceiveResponseFromProvider(TestData.ProviderSMSReference); return smsAggregate; diff --git a/MessagingService.Tests/ControllerTests.cs b/MessagingService.Tests/ControllerTests.cs index 8a5e1b0..e09291a 100644 --- a/MessagingService.Tests/ControllerTests.cs +++ b/MessagingService.Tests/ControllerTests.cs @@ -26,11 +26,11 @@ public ControllerTests() { } [Fact] public async Task DomainEventController_EventIdNotPresentInJson_ErrorThrown() { - Mock resolver = new Mock(); + Mock resolver = new(); TypeMap.AddType("ResponseReceivedFromEmailProviderEvent"); - DefaultHttpContext httpContext = new DefaultHttpContext(); + DefaultHttpContext httpContext = new(); httpContext.Request.Headers["eventType"] = "ResponseReceivedFromEmailProviderEvent"; - DomainEventController controller = new DomainEventController(resolver.Object) + DomainEventController controller = new(resolver.Object) { ControllerContext = new ControllerContext() { @@ -48,11 +48,11 @@ public async Task DomainEventController_EventIdNotPresentInJson_ErrorThrown() { [Fact] public async Task DomainEventController_EventIdPresentInJson_NoErrorThrown() { - Mock resolver = new Mock(); + Mock resolver = new(); TypeMap.AddType("ResponseReceivedFromEmailProviderEvent"); - DefaultHttpContext httpContext = new DefaultHttpContext(); + DefaultHttpContext httpContext = new(); httpContext.Request.Headers["eventType"] = "ResponseReceivedFromEmailProviderEvent"; - DomainEventController controller = new DomainEventController(resolver.Object) + DomainEventController controller = new(resolver.Object) { ControllerContext = new ControllerContext() { diff --git a/MessagingService.Tests/General/BootstrapperTests.cs b/MessagingService.Tests/General/BootstrapperTests.cs index 63c7887..77ad2ca 100644 --- a/MessagingService.Tests/General/BootstrapperTests.cs +++ b/MessagingService.Tests/General/BootstrapperTests.cs @@ -23,13 +23,13 @@ public class BootstrapperTests [Fact] public void VerifyBootstrapperIsValid() { - Mock hostingEnvironment = new Mock(); + Mock hostingEnvironment = new(); hostingEnvironment.Setup(he => he.EnvironmentName).Returns("Development"); hostingEnvironment.Setup(he => he.ContentRootPath).Returns("/home"); hostingEnvironment.Setup(he => he.ApplicationName).Returns("Test Application"); - ServiceRegistry services = new ServiceRegistry(); - Startup s = new Startup(hostingEnvironment.Object); + ServiceRegistry services = new(); + Startup s = new(hostingEnvironment.Object); Startup.Configuration = this.SetupMemoryConfiguration(); this.AddTestRegistrations(services, hostingEnvironment.Object); @@ -56,7 +56,7 @@ private void AddTestRegistrations(IServiceCollection services, IWebHostEnvironment hostingEnvironment) { services.AddLogging(); - DiagnosticListener diagnosticSource = new DiagnosticListener(hostingEnvironment.ApplicationName); + DiagnosticListener diagnosticSource = new(hostingEnvironment.ApplicationName); services.AddSingleton(diagnosticSource); services.AddSingleton(diagnosticSource); services.AddSingleton(hostingEnvironment); diff --git a/MessagingService/Bootstrapper/MiddlewareRegistry.cs b/MessagingService/Bootstrapper/MiddlewareRegistry.cs index f57f955..406cb2f 100644 --- a/MessagingService/Bootstrapper/MiddlewareRegistry.cs +++ b/MessagingService/Bootstrapper/MiddlewareRegistry.cs @@ -112,8 +112,7 @@ public MiddlewareRegistry() { bool logResponses = ConfigurationReader.GetValueOrDefault("MiddlewareLogging", "LogResponses", true); LogLevel middlewareLogLevel = ConfigurationReader.GetValueOrDefault("MiddlewareLogging", "MiddlewareLogLevel", LogLevel.Warning); - RequestResponseMiddlewareLoggingConfig config = - new RequestResponseMiddlewareLoggingConfig(middlewareLogLevel, logRequests, logResponses); + RequestResponseMiddlewareLoggingConfig config = new(middlewareLogLevel, logRequests, logResponses); this.AddSingleton(config); } diff --git a/MessagingService/Common/Extensions.cs b/MessagingService/Common/Extensions.cs index a323e57..dfffa7c 100644 --- a/MessagingService/Common/Extensions.cs +++ b/MessagingService/Common/Extensions.cs @@ -49,14 +49,14 @@ public static void PreWarm(this IApplicationBuilder applicationBuilder) TypeProvider.LoadDomainEventsTypeDynamically(); IConfigurationSection subscriptionConfigSection = Startup.Configuration.GetSection("AppSettings:SubscriptionConfiguration"); - SubscriptionWorkersRoot subscriptionWorkersRoot = new SubscriptionWorkersRoot(); + SubscriptionWorkersRoot subscriptionWorkersRoot = new(); subscriptionConfigSection.Bind(subscriptionWorkersRoot); String eventStoreConnectionString = ConfigurationReader.GetValue("EventStoreSettings", "ConnectionString"); IDomainEventHandlerResolver mainEventHandlerResolver = Startup.Container.GetInstance("Main"); - Dictionary eventHandlerResolvers = new Dictionary { + Dictionary eventHandlerResolvers = new() { {"Main", mainEventHandlerResolver} }; diff --git a/MessagingService/Common/RequestExamples/SendEmailRequestExample.cs b/MessagingService/Common/RequestExamples/SendEmailRequestExample.cs index afe684c..8d0685f 100644 --- a/MessagingService/Common/RequestExamples/SendEmailRequestExample.cs +++ b/MessagingService/Common/RequestExamples/SendEmailRequestExample.cs @@ -21,7 +21,7 @@ public class SendEmailRequestExample : IMultipleExamplesProvider public IEnumerable> GetExamples() { - SendEmailRequest htmlEmailRequest = new SendEmailRequest + SendEmailRequest htmlEmailRequest = new() { Body = ExampleData.EmailMessageHtmlBody, ConnectionIdentifier = ExampleData.ConnectionIdentifier, @@ -36,7 +36,7 @@ public IEnumerable> GetExamples() Subject = ExampleData.EmailMessageSubject }; - SendEmailRequest plainTextEmailRequest = new SendEmailRequest + SendEmailRequest plainTextEmailRequest = new() { Body = ExampleData.EmailMessagePlainTextBody, ConnectionIdentifier = ExampleData.ConnectionIdentifier, @@ -50,7 +50,7 @@ public IEnumerable> GetExamples() MessageId = ExampleData.EmailMessageId, Subject = ExampleData.EmailMessageSubject }; - List> examples = new List>(); + List> examples = new(); examples.Add(new SwaggerExample { Name = "Html Email Request", diff --git a/MessagingService/Controllers/DomainEventController.cs b/MessagingService/Controllers/DomainEventController.cs index b89fec8..d504f54 100644 --- a/MessagingService/Controllers/DomainEventController.cs +++ b/MessagingService/Controllers/DomainEventController.cs @@ -109,8 +109,8 @@ private async Task GetDomainEvent(Object domainEvent) { if (type == null) throw new Exception($"Failed to find a domain event with type {eventType}"); - JsonIgnoreAttributeIgnorerContractResolver jsonIgnoreAttributeIgnorerContractResolver = new JsonIgnoreAttributeIgnorerContractResolver(); - JsonSerializerSettings jsonSerialiserSettings = new JsonSerializerSettings { + JsonIgnoreAttributeIgnorerContractResolver jsonIgnoreAttributeIgnorerContractResolver = new(); + JsonSerializerSettings jsonSerialiserSettings = new() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore, TypeNameHandling = TypeNameHandling.All, Formatting = Formatting.Indented, diff --git a/MessagingService/Program.cs b/MessagingService/Program.cs index bd5248c..2d89215 100644 --- a/MessagingService/Program.cs +++ b/MessagingService/Program.cs @@ -25,7 +25,7 @@ public static void Main(string[] args) public static IHostBuilder CreateHostBuilder(string[] args) { //At this stage, we only need our hosting file for ip and ports - FileInfo fi = new FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location); + FileInfo fi = new(System.Reflection.Assembly.GetExecutingAssembly().Location); IConfigurationRoot config = new ConfigurationBuilder().SetBasePath(fi.Directory.FullName) .AddJsonFile("hosting.json", optional: false)