Skip to content

Commit e251d66

Browse files
Merge pull request #210 from TransactionProcessing/deepsource-autofix-a3aad22b
refactor: drop redundant type declarations
2 parents 24fd392 + 5fbbc10 commit e251d66

20 files changed

Lines changed: 153 additions & 156 deletions

File tree

MessagingService.BusinessLogic.Tests/Mediator/MediatorTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,20 @@ public MediatorTests() {
3434

3535
[Fact]
3636
public async Task Mediator_Send_RequestHandled() {
37-
Mock<IWebHostEnvironment> hostingEnvironment = new Mock<IWebHostEnvironment>();
37+
Mock<IWebHostEnvironment> hostingEnvironment = new();
3838
hostingEnvironment.Setup(he => he.EnvironmentName).Returns("Development");
3939
hostingEnvironment.Setup(he => he.ContentRootPath).Returns("/home");
4040
hostingEnvironment.Setup(he => he.ApplicationName).Returns("Test Application");
4141

42-
ServiceRegistry services = new ServiceRegistry();
43-
Startup s = new Startup(hostingEnvironment.Object);
42+
ServiceRegistry services = new();
43+
Startup s = new(hostingEnvironment.Object);
4444
Startup.Configuration = this.SetupMemoryConfiguration();
4545

4646
this.AddTestRegistrations(services, hostingEnvironment.Object);
4747
s.ConfigureContainer(services);
4848
Startup.Container.AssertConfigurationIsValid(AssertMode.Full);
4949

50-
List<String> errors = new List<String>();
50+
List<String> errors = new();
5151
IMediator mediator = Startup.Container.GetService<IMediator>();
5252
foreach (IBaseRequest baseRequest in this.Requests) {
5353
try {
@@ -78,7 +78,7 @@ private IConfigurationRoot SetupMemoryConfiguration()
7878
private void AddTestRegistrations(ServiceRegistry services,
7979
IWebHostEnvironment hostingEnvironment) {
8080
services.AddLogging();
81-
DiagnosticListener diagnosticSource = new DiagnosticListener(hostingEnvironment.ApplicationName);
81+
DiagnosticListener diagnosticSource = new(hostingEnvironment.ApplicationName);
8282
services.AddSingleton<DiagnosticSource>(diagnosticSource);
8383
services.AddSingleton<DiagnosticListener>(diagnosticSource);
8484
services.AddSingleton<IWebHostEnvironment>(hostingEnvironment);

MessagingService.BusinessLogic.Tests/Services/MessagingDomainServiceTests.cs

Lines changed: 77 additions & 79 deletions
Large diffs are not rendered by default.

MessagingService.BusinessLogic/Services/EmailServices/Smtp2Go/Smtp2GoProxy.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public async Task<EmailServiceProxyResponse> SendEmail(Guid messageId,
8787
StringContent content = new(requestSerialised, Encoding.UTF8, "application/json");
8888

8989
String requestUri = $"{ConfigurationReader.GetValue("SMTP2GoBaseAddress")}email/send";
90-
HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Post, requestUri);
90+
HttpRequestMessage requestMessage = new(HttpMethod.Post, requestUri);
9191
requestMessage.Content = content;
9292

9393
HttpResponseMessage httpResponse = await this.HttpClient.SendAsync(requestMessage, cancellationToken);
@@ -135,7 +135,7 @@ public async Task<MessageStatusResponse> GetMessageStatus(String providerReferen
135135
{
136136
MessageStatusResponse response = null;
137137

138-
Smtp2GoEmailSearchRequest apiRequest = new Smtp2GoEmailSearchRequest
138+
Smtp2GoEmailSearchRequest apiRequest = new()
139139
{
140140
ApiKey = ConfigurationReader.GetValue("SMTP2GoAPIKey"),
141141
EmailId = new List<String>
@@ -153,10 +153,10 @@ public async Task<MessageStatusResponse> GetMessageStatus(String providerReferen
153153

154154
Logger.LogDebug($"Request Message Sent to Email Provider [SMTP2Go] {requestSerialised}");
155155

156-
StringContent content = new StringContent(requestSerialised, Encoding.UTF8, "application/json");
156+
StringContent content = new(requestSerialised, Encoding.UTF8, "application/json");
157157

158158
String requestUri = $"{ConfigurationReader.GetValue("SMTP2GoBaseAddress")}email/search";
159-
HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Post, requestUri);
159+
HttpRequestMessage requestMessage = new(HttpMethod.Post, requestUri);
160160
requestMessage.Content = content;
161161

162162
HttpResponseMessage httpResponse = await this.HttpClient.SendAsync(requestMessage, cancellationToken);

MessagingService.BusinessLogic/Services/SMSServices/TheSMSWorks/TheSmsWorksProxy.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ public async Task<SMSServiceProxyResponse> SendSMS(Guid messageId,
4141
SMSServiceProxyResponse response = null;
4242

4343
// Create the Auth Request
44-
TheSmsWorksTokenRequest apiTokenRequest = new TheSmsWorksTokenRequest { CustomerId = ConfigurationReader.GetValue("TheSMSWorksCustomerId"), Key = ConfigurationReader.GetValue("TheSMSWorksKey"), Secret = ConfigurationReader.GetValue("TheSMSWorksSecret") };
44+
TheSmsWorksTokenRequest apiTokenRequest = new() { CustomerId = ConfigurationReader.GetValue("TheSMSWorksCustomerId"), Key = ConfigurationReader.GetValue("TheSMSWorksKey"), Secret = ConfigurationReader.GetValue("TheSMSWorksSecret") };
4545

4646
String apiTokenRequestSerialised = JsonConvert.SerializeObject(apiTokenRequest).ToLower();
47-
StringContent content = new StringContent(apiTokenRequestSerialised, Encoding.UTF8, "application/json");
47+
StringContent content = new(apiTokenRequestSerialised, Encoding.UTF8, "application/json");
4848

4949
// First do the authentication
5050
HttpResponseMessage apiTokenHttpResponse = await this.HttpClient.PostAsync($"{ConfigurationReader.GetValue("TheSMSWorksBaseAddress")}auth/token", content, cancellationToken);
@@ -53,7 +53,7 @@ public async Task<SMSServiceProxyResponse> SendSMS(Guid messageId,
5353
TheSmsWorksTokenResponse apiTokenResponse = JsonConvert.DeserializeObject<TheSmsWorksTokenResponse>(await apiTokenHttpResponse.Content.ReadAsStringAsync());
5454

5555
// Now do the actual send
56-
TheSmsWorksSendSMSRequest apiSendSmsRequest = new TheSmsWorksSendSMSRequest {
56+
TheSmsWorksSendSMSRequest apiSendSmsRequest = new() {
5757
Content = message,
5858
Sender = sender,
5959
Destination = destination,
@@ -87,13 +87,13 @@ public async Task<SMSServiceProxyResponse> SendSMS(Guid messageId,
8787

8888
public async Task<MessageStatusResponse> GetMessageStatus(String providerReference,
8989
CancellationToken cancellationToken) {
90-
MessageStatusResponse response = new MessageStatusResponse();
90+
MessageStatusResponse response = new();
9191

9292
// Create the Auth Request
93-
TheSmsWorksTokenRequest apiTokenRequest = new TheSmsWorksTokenRequest { CustomerId = ConfigurationReader.GetValue("TheSMSWorksCustomerId"), Key = ConfigurationReader.GetValue("TheSMSWorksKey"), Secret = ConfigurationReader.GetValue("TheSMSWorksSecret") };
93+
TheSmsWorksTokenRequest apiTokenRequest = new() { CustomerId = ConfigurationReader.GetValue("TheSMSWorksCustomerId"), Key = ConfigurationReader.GetValue("TheSMSWorksKey"), Secret = ConfigurationReader.GetValue("TheSMSWorksSecret") };
9494

9595
String apiTokenRequestSerialised = JsonConvert.SerializeObject(apiTokenRequest).ToLower();
96-
StringContent content = new StringContent(apiTokenRequestSerialised, Encoding.UTF8, "application/json");
96+
StringContent content = new(apiTokenRequestSerialised, Encoding.UTF8, "application/json");
9797

9898
// First do the authentication
9999
HttpResponseMessage apiTokenHttpResponse = await this.HttpClient.PostAsync($"{ConfigurationReader.GetValue("TheSMSWorksBaseAddress")}auth/token", content, cancellationToken);
@@ -159,7 +159,7 @@ private MessageStatus TranslateMessageStatus(String status)
159159
/// <returns></returns>
160160
private async Task<SMSServiceProxyResponse> HandleAPIError(HttpResponseMessage httpResponse)
161161
{
162-
SMSServiceProxyResponse response = new SMSServiceProxyResponse();
162+
SMSServiceProxyResponse response = new();
163163

164164
String responseContent = await httpResponse.Content.ReadAsStringAsync();
165165

MessagingService.Client/MessagingServiceClient.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public async Task<Result> SendEmail(String accessToken,
7070
{
7171
String requestSerialised = JsonConvert.SerializeObject(sendEmailRequest);
7272

73-
StringContent httpContent = new StringContent(requestSerialised, Encoding.UTF8, "application/json");
73+
StringContent httpContent = new(requestSerialised, Encoding.UTF8, "application/json");
7474

7575
// Add the access token to the client headers
7676
this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
@@ -89,7 +89,7 @@ public async Task<Result> SendEmail(String accessToken,
8989
catch(Exception ex)
9090
{
9191
// An exception has occurred, add some additional information to the message
92-
Exception exception = new Exception("Error sending email message.", ex);
92+
Exception exception = new("Error sending email message.", ex);
9393

9494
throw exception;
9595
}
@@ -103,7 +103,7 @@ public async Task<Result> ResendEmail(String accessToken,
103103
try {
104104
String requestSerialised = JsonConvert.SerializeObject(resendEmailRequest);
105105

106-
StringContent httpContent = new StringContent(requestSerialised, Encoding.UTF8, "application/json");
106+
StringContent httpContent = new(requestSerialised, Encoding.UTF8, "application/json");
107107

108108
// Add the access token to the client headers
109109
this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
@@ -121,7 +121,7 @@ public async Task<Result> ResendEmail(String accessToken,
121121
}
122122
catch(Exception ex) {
123123
// An exception has occurred, add some additional information to the message
124-
Exception exception = new Exception("Error re-sending email message.", ex);
124+
Exception exception = new("Error re-sending email message.", ex);
125125

126126
throw exception;
127127
}
@@ -146,7 +146,7 @@ public async Task<Result> SendSMS(String accessToken,
146146
{
147147
String requestSerialised = JsonConvert.SerializeObject(sendSMSRequest);
148148

149-
StringContent httpContent = new StringContent(requestSerialised, Encoding.UTF8, "application/json");
149+
StringContent httpContent = new(requestSerialised, Encoding.UTF8, "application/json");
150150

151151
// Add the access token to the client headers
152152
this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
@@ -165,7 +165,7 @@ public async Task<Result> SendSMS(String accessToken,
165165
catch (Exception ex)
166166
{
167167
// An exception has occurred, add some additional information to the message
168-
Exception exception = new Exception("Error sending sms message.", ex);
168+
Exception exception = new("Error sending sms message.", ex);
169169

170170
throw exception;
171171
}

MessagingService.EmailAggregate.Tests/EmailAggregateTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ public void EmailAggregate_ResendRequestToProvider_Bounced_ErrorThrown() {
412412
[Fact]
413413
public void EmailAggregate_PlayEvent_UnsupportedEvent_ErrorThrown() {
414414
Logger.Initialise(NullLogger.Instance);
415-
EmailAggregate emailAggregate = new EmailAggregate();
415+
EmailAggregate emailAggregate = new();
416416
Should.Throw<Exception>(() => emailAggregate.PlayEvent(new TestEvent(Guid.NewGuid(), Guid.NewGuid())));
417417
}
418418
}

MessagingService.EmailMessageAggregate/EmailAggregate.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public static void MarkMessageAsBounced(this EmailAggregate aggregate, String pr
1919
return;
2020
aggregate.CheckMessageCanBeSetToBounced();
2121

22-
EmailMessageBouncedEvent messageBouncedEvent = new EmailMessageBouncedEvent(aggregate.AggregateId, providerStatus, bouncedDateTime);
22+
EmailMessageBouncedEvent messageBouncedEvent = new(aggregate.AggregateId, providerStatus, bouncedDateTime);
2323

2424
aggregate.ApplyAndAppend(messageBouncedEvent);
2525
}
@@ -31,7 +31,7 @@ public static void MarkMessageAsDelivered(this EmailAggregate aggregate, String
3131
return;
3232
aggregate.CheckMessageCanBeSetToDelivered();
3333

34-
EmailMessageDeliveredEvent messageDeliveredEvent = new EmailMessageDeliveredEvent(aggregate.AggregateId, providerStatus, deliveredDateTime);
34+
EmailMessageDeliveredEvent messageDeliveredEvent = new(aggregate.AggregateId, providerStatus, deliveredDateTime);
3535

3636
aggregate.ApplyAndAppend(messageDeliveredEvent);
3737
}
@@ -43,7 +43,7 @@ public static void MarkMessageAsFailed(this EmailAggregate aggregate, String pro
4343
return;
4444
aggregate.CheckMessageCanBeSetToFailed();
4545

46-
EmailMessageFailedEvent messageFailedEvent = new EmailMessageFailedEvent(aggregate.AggregateId, providerStatus, failedDateTime);
46+
EmailMessageFailedEvent messageFailedEvent = new(aggregate.AggregateId, providerStatus, failedDateTime);
4747

4848
aggregate.ApplyAndAppend(messageFailedEvent);
4949
}
@@ -55,7 +55,7 @@ public static void MarkMessageAsRejected(this EmailAggregate aggregate, String p
5555
return;
5656
aggregate.CheckMessageCanBeSetToRejected();
5757

58-
EmailMessageRejectedEvent messageRejectedEvent = new EmailMessageRejectedEvent(aggregate.AggregateId, providerStatus, rejectedDateTime);
58+
EmailMessageRejectedEvent messageRejectedEvent = new(aggregate.AggregateId, providerStatus, rejectedDateTime);
5959

6060
aggregate.ApplyAndAppend(messageRejectedEvent);
6161
}
@@ -67,7 +67,7 @@ public static void MarkMessageAsSpam(this EmailAggregate aggregate, String provi
6767
return;
6868
aggregate.CheckMessageCanBeSetToSpam();
6969

70-
EmailMessageMarkedAsSpamEvent messageMarkedAsSpamEvent = new EmailMessageMarkedAsSpamEvent(aggregate.AggregateId, providerStatus, spamDateTime);
70+
EmailMessageMarkedAsSpamEvent messageMarkedAsSpamEvent = new(aggregate.AggregateId, providerStatus, spamDateTime);
7171

7272
aggregate.ApplyAndAppend(messageMarkedAsSpamEvent);
7373
}
@@ -76,15 +76,15 @@ public static void ReceiveResponseFromProvider(this EmailAggregate aggregate, St
7676
String providerEmailReference)
7777
{
7878
ResponseReceivedFromEmailProviderEvent responseReceivedFromProviderEvent =
79-
new ResponseReceivedFromEmailProviderEvent(aggregate.AggregateId, providerRequestReference, providerEmailReference);
79+
new(aggregate.AggregateId, providerRequestReference, providerEmailReference);
8080

8181
aggregate.ApplyAndAppend(responseReceivedFromProviderEvent);
8282
}
8383

8484
public static void ReceiveBadResponseFromProvider(this EmailAggregate aggregate, String error, String errorCode)
8585
{
8686
BadResponseReceivedFromEmailProviderEvent badResponseReceivedFromProviderEvent =
87-
new BadResponseReceivedFromEmailProviderEvent(aggregate.AggregateId, errorCode, error);
87+
new(aggregate.AggregateId, errorCode, error);
8888

8989
aggregate.ApplyAndAppend(badResponseReceivedFromProviderEvent);
9090
}
@@ -101,14 +101,14 @@ public static void SendRequestToProvider(this EmailAggregate aggregate, String f
101101
Boolean isHtml,
102102
List<EmailAttachment> attachments)
103103
{
104-
RequestSentToEmailProviderEvent requestSentToProviderEvent = new RequestSentToEmailProviderEvent(aggregate.AggregateId, fromAddress, toAddresses, subject, body, isHtml);
104+
RequestSentToEmailProviderEvent requestSentToProviderEvent = new(aggregate.AggregateId, fromAddress, toAddresses, subject, body, isHtml);
105105

106106
aggregate.ApplyAndAppend(requestSentToProviderEvent);
107107

108108
// Record the attachment data
109109
foreach (EmailAttachment emailAttachment in attachments)
110110
{
111-
EmailAttachmentRequestSentToProviderEvent emailAttachmentRequestSentToProviderEvent = new EmailAttachmentRequestSentToProviderEvent(aggregate.AggregateId,
111+
EmailAttachmentRequestSentToProviderEvent emailAttachmentRequestSentToProviderEvent = new(aggregate.AggregateId,
112112
emailAttachment.Filename,
113113
emailAttachment.FileData,
114114
(Int32)emailAttachment.FileType);
@@ -124,7 +124,7 @@ public static void ResendRequestToProvider(this EmailAggregate aggregate)
124124
throw new InvalidOperationException($"Cannot re-send a message to provider that has not already been sent. Current Status [{aggregate.DeliveryStatusList[aggregate.ResendCount]}]");
125125
}
126126

127-
RequestResentToEmailProviderEvent requestResentToEmailProviderEvent = new RequestResentToEmailProviderEvent(aggregate.AggregateId);
127+
RequestResentToEmailProviderEvent requestResentToEmailProviderEvent = new(aggregate.AggregateId);
128128

129129
aggregate.ApplyAndAppend(requestResentToEmailProviderEvent);
130130
}
@@ -181,7 +181,7 @@ public static void PlayEvent(this EmailAggregate aggregate, RequestSentToEmailPr
181181

182182
foreach (String domainEventToAddress in domainEvent.ToAddresses)
183183
{
184-
MessageRecipient messageRecipient = new MessageRecipient();
184+
MessageRecipient messageRecipient = new();
185185
messageRecipient.Create(domainEventToAddress);
186186
aggregate.Recipients.Add(messageRecipient);
187187
}

0 commit comments

Comments
 (0)