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
10 changes: 5 additions & 5 deletions MessagingService.BusinessLogic.Tests/Mediator/MediatorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,20 @@ public MediatorTests() {

[Fact]
public async Task Mediator_Send_RequestHandled() {
Mock<IWebHostEnvironment> hostingEnvironment = new Mock<IWebHostEnvironment>();
Mock<IWebHostEnvironment> 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<String> errors = new List<String>();
List<String> errors = new();
IMediator mediator = Startup.Container.GetService<IMediator>();
foreach (IBaseRequest baseRequest in this.Requests) {
try {
Expand Down Expand Up @@ -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>(diagnosticSource);
services.AddSingleton<DiagnosticListener>(diagnosticSource);
services.AddSingleton<IWebHostEnvironment>(hostingEnvironment);
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public async Task<EmailServiceProxyResponse> 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);
Expand Down Expand Up @@ -135,7 +135,7 @@ public async Task<MessageStatusResponse> GetMessageStatus(String providerReferen
{
MessageStatusResponse response = null;

Smtp2GoEmailSearchRequest apiRequest = new Smtp2GoEmailSearchRequest
Smtp2GoEmailSearchRequest apiRequest = new()
{
ApiKey = ConfigurationReader.GetValue("SMTP2GoAPIKey"),
EmailId = new List<String>
Expand All @@ -153,10 +153,10 @@ public async Task<MessageStatusResponse> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ public async Task<SMSServiceProxyResponse> 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);
Expand All @@ -53,7 +53,7 @@ public async Task<SMSServiceProxyResponse> SendSMS(Guid messageId,
TheSmsWorksTokenResponse apiTokenResponse = JsonConvert.DeserializeObject<TheSmsWorksTokenResponse>(await apiTokenHttpResponse.Content.ReadAsStringAsync());

// Now do the actual send
TheSmsWorksSendSMSRequest apiSendSmsRequest = new TheSmsWorksSendSMSRequest {
TheSmsWorksSendSMSRequest apiSendSmsRequest = new() {
Content = message,
Sender = sender,
Destination = destination,
Expand Down Expand Up @@ -87,13 +87,13 @@ public async Task<SMSServiceProxyResponse> SendSMS(Guid messageId,

public async Task<MessageStatusResponse> 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);
Expand Down Expand Up @@ -159,7 +159,7 @@ private MessageStatus TranslateMessageStatus(String status)
/// <returns></returns>
private async Task<SMSServiceProxyResponse> HandleAPIError(HttpResponseMessage httpResponse)
{
SMSServiceProxyResponse response = new SMSServiceProxyResponse();
SMSServiceProxyResponse response = new();

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

Expand Down
12 changes: 6 additions & 6 deletions MessagingService.Client/MessagingServiceClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
/// <summary>
/// The base address
/// </summary>
private readonly String BaseAddress;

Check warning on line 28 in MessagingService.Client/MessagingServiceClient.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests

The field 'MessagingServiceClient.BaseAddress' is never used

Check warning on line 28 in MessagingService.Client/MessagingServiceClient.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests

The field 'MessagingServiceClient.BaseAddress' is never used

/// <summary>
/// The base address resolver
Expand Down Expand Up @@ -62,7 +62,7 @@
SendEmailRequest sendEmailRequest,
CancellationToken cancellationToken)
{
SendEmailResponse response = null;

Check warning on line 65 in MessagingService.Client/MessagingServiceClient.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests

The variable 'response' is assigned but its value is never used

Check warning on line 65 in MessagingService.Client/MessagingServiceClient.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests

The variable 'response' is assigned but its value is never used

String requestUri = this.BuildRequestUrl("/api/email/");

Expand All @@ -70,7 +70,7 @@
{
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);
Expand All @@ -89,7 +89,7 @@
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;
}
Expand All @@ -103,7 +103,7 @@
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);
Expand All @@ -121,7 +121,7 @@
}
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;
}
Expand All @@ -138,7 +138,7 @@
SendSMSRequest sendSMSRequest,
CancellationToken cancellationToken)
{
SendSMSResponse response = null;

Check warning on line 141 in MessagingService.Client/MessagingServiceClient.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests

The variable 'response' is assigned but its value is never used

Check warning on line 141 in MessagingService.Client/MessagingServiceClient.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests

The variable 'response' is assigned but its value is never used

String requestUri = this.BuildRequestUrl("/api/sms/");

Expand All @@ -146,7 +146,7 @@
{
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);
Expand All @@ -165,7 +165,7 @@
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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Exception>(() => emailAggregate.PlayEvent(new TestEvent(Guid.NewGuid(), Guid.NewGuid())));
}
}
Expand Down
22 changes: 11 additions & 11 deletions MessagingService.EmailMessageAggregate/EmailAggregate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -76,15 +76,15 @@ 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);
}

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);
}
Expand All @@ -101,14 +101,14 @@ public static void SendRequestToProvider(this EmailAggregate aggregate, String f
Boolean isHtml,
List<EmailAttachment> 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);
Expand All @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down
Loading
Loading