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
2 changes: 1 addition & 1 deletion CallbackHander.Testing/TestData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static CallbackMessageAggregate EmptyCallbackMessageAggregate()

public static CallbackMessageAggregate RecordedCallbackMessageAggregate()
{
CallbackMessageAggregate aggregate = new CallbackMessageAggregate();
CallbackMessageAggregate aggregate = new();
aggregate.RecordCallback(TestData.CallbackId, TestData.TypeString, (MessageFormat)TestData.MessageFormat,
TestData.CallbackMessage, TestData.Reference, TestData.Destinations, EstateReference, MerchantReference);

Expand Down
10 changes: 5 additions & 5 deletions CallbackHandler.BusinessLogic.Tests/Mediator/MediatorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,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)
{
Expand Down Expand Up @@ -90,7 +90,7 @@ 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
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,17 @@ public class CallbackHandlerRequestHandlerTests
[Fact]
public void CallbackHandlerRequestHandlerTests_RecordCallbackRequest_IsHandled()
{
Mock<ICallbackDomainService> domainService =
new Mock<ICallbackDomainService>();
Mock<ICallbackDomainService> domainService = new();
domainService.Setup(a => a.RecordCallback(It.IsAny<Guid>(),
It.IsAny<String>(),
It.IsAny<MessageFormat>(),
It.IsAny<String>(),
It.IsAny<String>(),
It.IsAny<String[]>(),
It.IsAny<CancellationToken>()));
Mock<IAggregateRepository<CallbackMessageAggregate, DomainEvent>> aggregateRepository =
new Mock<IAggregateRepository<CallbackMessageAggregate, DomainEvent>>();
Mock<IAggregateRepository<CallbackMessageAggregate, DomainEvent>> aggregateRepository = new();

CallbackHandlerRequestHandler handler = new CallbackHandlerRequestHandler(domainService.Object, aggregateRepository.Object);
CallbackHandlerRequestHandler handler = new(domainService.Object, aggregateRepository.Object);

CallbackCommands.RecordCallbackRequest request = TestData.RecordCallbackRequest;

Expand All @@ -46,7 +44,7 @@ public void CallbackHandlerRequestHandlerTests_RecordCallbackRequest_IsHandled()
public void CallbackHandlerRequestHandlerTests_GetCallbackQuery_IsHandled()
{
Mock<ICallbackDomainService> domainService =
new Mock<ICallbackDomainService>();
new();
domainService.Setup(a => a.RecordCallback(It.IsAny<Guid>(),
It.IsAny<String>(),
It.IsAny<MessageFormat>(),
Expand All @@ -55,12 +53,12 @@ public void CallbackHandlerRequestHandlerTests_GetCallbackQuery_IsHandled()
It.IsAny<String[]>(),
It.IsAny<CancellationToken>()));
Mock<IAggregateRepository<CallbackMessageAggregate, DomainEvent>> aggregateRepository =
new Mock<IAggregateRepository<CallbackMessageAggregate, DomainEvent>>();
new();

aggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny<Guid>(), It.IsAny<CancellationToken>()))
.ReturnsAsync(TestData.RecordedCallbackMessageAggregate());

CallbackHandlerRequestHandler handler = new CallbackHandlerRequestHandler(domainService.Object, aggregateRepository.Object);
CallbackHandlerRequestHandler handler = new(domainService.Object, aggregateRepository.Object);

CallbackQueries.GetCallbackQuery query = TestData.GetCallbackQuery;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class CallbackMessageAggregateTests
[Fact]
public void CallbackMessageAggregate_RecordCallback_CallbackIsRecorded()
{
CallbackMessageAggregate aggregate = new CallbackMessageAggregate();
CallbackMessageAggregate aggregate = new();

Result result = aggregate.RecordCallback(TestData.CallbackId, TestData.TypeString, MessageFormat.JSON, TestData.CallbackMessage, TestData.Reference, TestData.Destinations,
TestData.EstateReference, TestData.MerchantReference);
Expand Down
2 changes: 1 addition & 1 deletion CallbackHandler.IntegrationTests/Common/DockerHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
{
public class DockerHelper : global::Shared.IntegrationTesting.DockerHelper
{
public override async Task CreateSubscriptions()

Check warning on line 21 in CallbackHandler.IntegrationTests/Common/DockerHelper.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 21 in CallbackHandler.IntegrationTests/Common/DockerHelper.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.
{
// Nothing to do here
}
Expand Down Expand Up @@ -49,9 +49,9 @@
{
// 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);

Check warning on line 54 in CallbackHandler.IntegrationTests/Common/DockerHelper.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests

'LogManager.AddHiddenAssembly(Assembly)' is obsolete: 'Replaced by LogManager.Setup().SetupLogFactory(setup => setup.AddCallSiteHiddenAssembly(assembly)). Marked obsolete on NLog 5.3'

DockerServices dockerServices = DockerServices.CallbackHandler | DockerServices.EventStore | DockerServices.SqlServer;

Expand Down Expand Up @@ -99,7 +99,7 @@

public Dictionary<Guid, String> SentCallbacks { get; set; }

public TestingContext()

Check warning on line 102 in CallbackHandler.IntegrationTests/Common/DockerHelper.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests

Non-nullable property 'Deposits' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

Check warning on line 102 in CallbackHandler.IntegrationTests/Common/DockerHelper.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests

Non-nullable property 'Logger' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

Check warning on line 102 in CallbackHandler.IntegrationTests/Common/DockerHelper.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests

Non-nullable property 'DockerHelper' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

Check warning on line 102 in CallbackHandler.IntegrationTests/Common/DockerHelper.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests

Non-nullable property 'Deposits' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

Check warning on line 102 in CallbackHandler.IntegrationTests/Common/DockerHelper.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests

Non-nullable property 'Logger' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

Check warning on line 102 in CallbackHandler.IntegrationTests/Common/DockerHelper.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests

Non-nullable property 'DockerHelper' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
{
this.SentCallbacks = new Dictionary<Guid, string>();
}
Expand All @@ -108,14 +108,14 @@
[Binding]
public class Setup
{
public static IContainerService DatabaseServerContainer;

Check warning on line 111 in CallbackHandler.IntegrationTests/Common/DockerHelper.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests

Non-nullable field 'DatabaseServerContainer' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 111 in CallbackHandler.IntegrationTests/Common/DockerHelper.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests

Non-nullable field 'DatabaseServerContainer' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.
public static INetworkService DatabaseServerNetwork;

Check warning on line 112 in CallbackHandler.IntegrationTests/Common/DockerHelper.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests

Non-nullable field 'DatabaseServerNetwork' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 112 in CallbackHandler.IntegrationTests/Common/DockerHelper.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests

Non-nullable field 'DatabaseServerNetwork' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.
public static (String usename, String password) SqlCredentials = ("sa", "thisisalongpassword123!");
public static (String url, String username, String password) DockerCredentials = ("https://www.docker.com", "stuartferguson", "Sc0tland");

static object padLock = new object(); // Object to lock on

public static async Task GlobalSetup(DockerHelper dockerHelper)

Check warning on line 118 in CallbackHandler.IntegrationTests/Common/DockerHelper.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 118 in CallbackHandler.IntegrationTests/Common/DockerHelper.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.
{
ShouldlyConfiguration.DefaultTaskTimeout = TimeSpan.FromMinutes(1);
dockerHelper.SqlCredentials = Setup.SqlCredentials;
Expand Down
12 changes: 6 additions & 6 deletions CallbackHandler.IntegrationTests/Shared/SharedSteps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
}

[Given(@"I have the following Bank Deposit Callbacks")]
public async Task GivenIHaveTheFollowingBankDepositCallbacks(DataTable table)

Check warning on line 34 in CallbackHandler.IntegrationTests/Shared/SharedSteps.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 34 in CallbackHandler.IntegrationTests/Shared/SharedSteps.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.
{
List<Deposit> requests = table.Rows.ToDepositRequests();
this.TestingContext.Deposits = requests;
Expand All @@ -40,12 +40,12 @@
[When(@"I send the requests to the callback handler for deposits")]
public async Task WhenISendTheRequestsToTheCallbackHandlerForDeposits()
{
using HttpClient client = new HttpClient();
using HttpClient client = new();
foreach (var testingContextDeposit in this.TestingContext.Deposits)
{
String requestUri =
$"http://localhost:{this.TestingContext.DockerHelper.GetCallbackHandlerPort()}/api/callbacks";
HttpRequestMessage msg = new HttpRequestMessage(HttpMethod.Post, requestUri);
HttpRequestMessage msg = new(HttpMethod.Post, requestUri);
var payload = JsonConvert.SerializeObject(testingContextDeposit);

msg.Content = new StringContent(payload, Encoding.UTF8,
Expand All @@ -54,7 +54,7 @@
response.StatusCode.ShouldBe(HttpStatusCode.OK);
var content = await response.Content.ReadAsStringAsync();
ResponseData<Guid> responseData =
JsonConvert.DeserializeObject<ResponseData<Guid>>(content);

Check warning on line 57 in CallbackHandler.IntegrationTests/Shared/SharedSteps.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests

Converting null literal or possible null value to non-nullable type.

this.TestingContext.SentCallbacks.Add(responseData.Data, payload);
}
Expand All @@ -63,12 +63,12 @@
[Then("the deposit records are recorded")]
public async Task ThenTheDepositRecordsAreRecorded()
{
using HttpClient client = new HttpClient();
using HttpClient client = new();
foreach (var sentCallback in this.TestingContext.SentCallbacks)
{
String requestUri =
$"http://localhost:{this.TestingContext.DockerHelper.GetCallbackHandlerPort()}/api/callbacks/{sentCallback.Key}";
HttpRequestMessage msg = new HttpRequestMessage(HttpMethod.Get, requestUri);
HttpRequestMessage msg = new(HttpMethod.Get, requestUri);
var response = await client.SendAsync(msg);
response.StatusCode.ShouldBe(HttpStatusCode.OK);

Expand All @@ -90,10 +90,10 @@
{
public static List<Deposit> ToDepositRequests(this DataTableRows tableRows)
{
List<Deposit> requests = new List<Deposit>();
List<Deposit> requests = new();
foreach (DataTableRow tableRow in tableRows)
{
Deposit depositCallback = new Deposit
Deposit depositCallback = new()
{
AccountNumber = ReqnrollTableHelper.GetStringRowValue(tableRow, "AccountNumber"),
Amount = ReqnrollTableHelper.GetDecimalValue(tableRow, "Amount"),
Expand All @@ -112,6 +112,6 @@

internal class ResponseData<T>
{
public T Data { get; set; }

Check warning on line 115 in CallbackHandler.IntegrationTests/Shared/SharedSteps.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests

Non-nullable property 'Data' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

Check warning on line 115 in CallbackHandler.IntegrationTests/Shared/SharedSteps.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests

Non-nullable property 'Data' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
}
}
8 changes: 4 additions & 4 deletions CallbackHandler.Tests/BootstrapperTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ public class BootstrapperTests
[Fact]
public void VerifyBootstrapperIsValid()
{
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);
Expand Down Expand Up @@ -58,7 +58,7 @@ 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
4 changes: 2 additions & 2 deletions CallbackHandler/Bootstrapper/MiddlewareRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public MiddlewareRegistry()
c.ExampleFilters();

//Locate the XML files being generated by ASP.NET...
DirectoryInfo directory = new DirectoryInfo(AppContext.BaseDirectory);
DirectoryInfo directory = new(AppContext.BaseDirectory);
FileInfo[] xmlFiles = directory.GetFiles("*.xml");

//... and tell Swagger to use those XML comments.
Expand Down Expand Up @@ -82,7 +82,7 @@ public MiddlewareRegistry()
LogLevel middlewareLogLevel = ConfigurationReader.GetValueOrDefault<LogLevel>("MiddlewareLogging", "MiddlewareLogLevel", LogLevel.Warning);

RequestResponseMiddlewareLoggingConfig config =
new RequestResponseMiddlewareLoggingConfig(middlewareLogLevel, logRequests, logResponses);
new(middlewareLogLevel, logRequests, logResponses);

this.AddSingleton(config);
}
Expand Down
1 change: 1 addition & 0 deletions CallbackHandler/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,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(typeof(Program).Assembly.Location);

IConfigurationRoot config = new ConfigurationBuilder().SetBasePath(fi.Directory.FullName)
Expand Down
Loading