Skip to content

Commit 21e05db

Browse files
Merge pull request #131 from TransactionProcessing/deepsource-autofix-00463dc6
refactor: drop redundant types from object instantiations
2 parents 5b48f4f + 1ae6382 commit 21e05db

9 files changed

Lines changed: 27 additions & 28 deletions

File tree

CallbackHander.Testing/TestData.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public static CallbackMessageAggregate EmptyCallbackMessageAggregate()
4141

4242
public static CallbackMessageAggregate RecordedCallbackMessageAggregate()
4343
{
44-
CallbackMessageAggregate aggregate = new CallbackMessageAggregate();
44+
CallbackMessageAggregate aggregate = new();
4545
aggregate.RecordCallback(TestData.CallbackId, TestData.TypeString, (MessageFormat)TestData.MessageFormat,
4646
TestData.CallbackMessage, TestData.Reference, TestData.Destinations, EstateReference, MerchantReference);
4747

CallbackHandler.BusinessLogic.Tests/Mediator/MediatorTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,20 @@ public MediatorTests()
3030
[Fact]
3131
public async Task Mediator_Send_RequestHandled()
3232
{
33-
Mock<IWebHostEnvironment> hostingEnvironment = new Mock<IWebHostEnvironment>();
33+
Mock<IWebHostEnvironment> hostingEnvironment = new();
3434
hostingEnvironment.Setup(he => he.EnvironmentName).Returns("Development");
3535
hostingEnvironment.Setup(he => he.ContentRootPath).Returns("/home");
3636
hostingEnvironment.Setup(he => he.ApplicationName).Returns("Test Application");
3737

38-
ServiceRegistry services = new ServiceRegistry();
39-
Startup s = new Startup(hostingEnvironment.Object);
38+
ServiceRegistry services = new();
39+
Startup s = new(hostingEnvironment.Object);
4040
Startup.Configuration = this.SetupMemoryConfiguration();
4141

4242
this.AddTestRegistrations(services, hostingEnvironment.Object);
4343
s.ConfigureContainer(services);
4444
Startup.Container.AssertConfigurationIsValid(AssertMode.Full);
4545

46-
List<String> errors = new List<String>();
46+
List<String> errors = new();
4747
IMediator mediator = Startup.Container.GetService<IMediator>();
4848
foreach (IBaseRequest baseRequest in this.Requests)
4949
{
@@ -90,7 +90,7 @@ private void AddTestRegistrations(ServiceRegistry services,
9090
IWebHostEnvironment hostingEnvironment)
9191
{
9292
services.AddLogging();
93-
DiagnosticListener diagnosticSource = new DiagnosticListener(hostingEnvironment.ApplicationName);
93+
DiagnosticListener diagnosticSource = new(hostingEnvironment.ApplicationName);
9494
services.AddSingleton<DiagnosticSource>(diagnosticSource);
9595
services.AddSingleton<DiagnosticListener>(diagnosticSource);
9696
services.AddSingleton<IWebHostEnvironment>(hostingEnvironment);

CallbackHandler.BusinessLogic.Tests/RequestHandler/CallbackHandlerRequestHandlerTests.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,17 @@ public class CallbackHandlerRequestHandlerTests
2323
[Fact]
2424
public void CallbackHandlerRequestHandlerTests_RecordCallbackRequest_IsHandled()
2525
{
26-
Mock<ICallbackDomainService> domainService =
27-
new Mock<ICallbackDomainService>();
26+
Mock<ICallbackDomainService> domainService = new();
2827
domainService.Setup(a => a.RecordCallback(It.IsAny<Guid>(),
2928
It.IsAny<String>(),
3029
It.IsAny<MessageFormat>(),
3130
It.IsAny<String>(),
3231
It.IsAny<String>(),
3332
It.IsAny<String[]>(),
3433
It.IsAny<CancellationToken>()));
35-
Mock<IAggregateRepository<CallbackMessageAggregate, DomainEvent>> aggregateRepository =
36-
new Mock<IAggregateRepository<CallbackMessageAggregate, DomainEvent>>();
34+
Mock<IAggregateRepository<CallbackMessageAggregate, DomainEvent>> aggregateRepository = new();
3735

38-
CallbackHandlerRequestHandler handler = new CallbackHandlerRequestHandler(domainService.Object, aggregateRepository.Object);
36+
CallbackHandlerRequestHandler handler = new(domainService.Object, aggregateRepository.Object);
3937

4038
CallbackCommands.RecordCallbackRequest request = TestData.RecordCallbackRequest;
4139

@@ -46,7 +44,7 @@ public void CallbackHandlerRequestHandlerTests_RecordCallbackRequest_IsHandled()
4644
public void CallbackHandlerRequestHandlerTests_GetCallbackQuery_IsHandled()
4745
{
4846
Mock<ICallbackDomainService> domainService =
49-
new Mock<ICallbackDomainService>();
47+
new();
5048
domainService.Setup(a => a.RecordCallback(It.IsAny<Guid>(),
5149
It.IsAny<String>(),
5250
It.IsAny<MessageFormat>(),
@@ -55,12 +53,12 @@ public void CallbackHandlerRequestHandlerTests_GetCallbackQuery_IsHandled()
5553
It.IsAny<String[]>(),
5654
It.IsAny<CancellationToken>()));
5755
Mock<IAggregateRepository<CallbackMessageAggregate, DomainEvent>> aggregateRepository =
58-
new Mock<IAggregateRepository<CallbackMessageAggregate, DomainEvent>>();
56+
new();
5957

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

63-
CallbackHandlerRequestHandler handler = new CallbackHandlerRequestHandler(domainService.Object, aggregateRepository.Object);
61+
CallbackHandlerRequestHandler handler = new(domainService.Object, aggregateRepository.Object);
6462

6563
CallbackQueries.GetCallbackQuery query = TestData.GetCallbackQuery;
6664

CallbackHandler.CallbackMessageAggregate.Tests/CallbackMessageAggregateTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class CallbackMessageAggregateTests
2020
[Fact]
2121
public void CallbackMessageAggregate_RecordCallback_CallbackIsRecorded()
2222
{
23-
CallbackMessageAggregate aggregate = new CallbackMessageAggregate();
23+
CallbackMessageAggregate aggregate = new();
2424

2525
Result result = aggregate.RecordCallback(TestData.CallbackId, TestData.TypeString, MessageFormat.JSON, TestData.CallbackMessage, TestData.Reference, TestData.Destinations,
2626
TestData.EstateReference, TestData.MerchantReference);

CallbackHandler.IntegrationTests/Common/DockerHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public async Task StartSystem()
4949
{
5050
// Initialise a logger
5151
String scenarioName = this.ScenarioContext.ScenarioInfo.Title.Replace(" ", "");
52-
NlogLogger logger = new NlogLogger();
52+
NlogLogger logger = new();
5353
logger.Initialise(LogManager.GetLogger(scenarioName), scenarioName);
5454
LogManager.AddHiddenAssembly(typeof(NlogLogger).Assembly);
5555

CallbackHandler.IntegrationTests/Shared/SharedSteps.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ public async Task GivenIHaveTheFollowingBankDepositCallbacks(DataTable table)
4040
[When(@"I send the requests to the callback handler for deposits")]
4141
public async Task WhenISendTheRequestsToTheCallbackHandlerForDeposits()
4242
{
43-
using HttpClient client = new HttpClient();
43+
using HttpClient client = new();
4444
foreach (var testingContextDeposit in this.TestingContext.Deposits)
4545
{
4646
String requestUri =
4747
$"http://localhost:{this.TestingContext.DockerHelper.GetCallbackHandlerPort()}/api/callbacks";
48-
HttpRequestMessage msg = new HttpRequestMessage(HttpMethod.Post, requestUri);
48+
HttpRequestMessage msg = new(HttpMethod.Post, requestUri);
4949
var payload = JsonConvert.SerializeObject(testingContextDeposit);
5050

5151
msg.Content = new StringContent(payload, Encoding.UTF8,
@@ -63,12 +63,12 @@ public async Task WhenISendTheRequestsToTheCallbackHandlerForDeposits()
6363
[Then("the deposit records are recorded")]
6464
public async Task ThenTheDepositRecordsAreRecorded()
6565
{
66-
using HttpClient client = new HttpClient();
66+
using HttpClient client = new();
6767
foreach (var sentCallback in this.TestingContext.SentCallbacks)
6868
{
6969
String requestUri =
7070
$"http://localhost:{this.TestingContext.DockerHelper.GetCallbackHandlerPort()}/api/callbacks/{sentCallback.Key}";
71-
HttpRequestMessage msg = new HttpRequestMessage(HttpMethod.Get, requestUri);
71+
HttpRequestMessage msg = new(HttpMethod.Get, requestUri);
7272
var response = await client.SendAsync(msg);
7373
response.StatusCode.ShouldBe(HttpStatusCode.OK);
7474

@@ -90,10 +90,10 @@ public static class ReqnrollExtensions
9090
{
9191
public static List<Deposit> ToDepositRequests(this DataTableRows tableRows)
9292
{
93-
List<Deposit> requests = new List<Deposit>();
93+
List<Deposit> requests = new();
9494
foreach (DataTableRow tableRow in tableRows)
9595
{
96-
Deposit depositCallback = new Deposit
96+
Deposit depositCallback = new()
9797
{
9898
AccountNumber = ReqnrollTableHelper.GetStringRowValue(tableRow, "AccountNumber"),
9999
Amount = ReqnrollTableHelper.GetDecimalValue(tableRow, "Amount"),

CallbackHandler.Tests/BootstrapperTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ public class BootstrapperTests
1818
[Fact]
1919
public void VerifyBootstrapperIsValid()
2020
{
21-
Mock<IWebHostEnvironment> hostingEnvironment = new Mock<IWebHostEnvironment>();
21+
Mock<IWebHostEnvironment> hostingEnvironment = new();
2222
hostingEnvironment.Setup(he => he.EnvironmentName).Returns("Development");
2323
hostingEnvironment.Setup(he => he.ContentRootPath).Returns("/home");
2424
hostingEnvironment.Setup(he => he.ApplicationName).Returns("Test Application");
2525

26-
ServiceRegistry services = new ServiceRegistry();
27-
Startup s = new Startup(hostingEnvironment.Object);
26+
ServiceRegistry services = new();
27+
Startup s = new(hostingEnvironment.Object);
2828
Startup.Configuration = this.SetupMemoryConfiguration();
2929

3030
this.AddTestRegistrations(services, hostingEnvironment.Object);
@@ -58,7 +58,7 @@ private void AddTestRegistrations(ServiceRegistry services,
5858
IWebHostEnvironment hostingEnvironment)
5959
{
6060
services.AddLogging();
61-
DiagnosticListener diagnosticSource = new DiagnosticListener(hostingEnvironment.ApplicationName);
61+
DiagnosticListener diagnosticSource = new(hostingEnvironment.ApplicationName);
6262
services.AddSingleton<DiagnosticSource>(diagnosticSource);
6363
services.AddSingleton<DiagnosticListener>(diagnosticSource);
6464
services.AddSingleton<IWebHostEnvironment>(hostingEnvironment);

CallbackHandler/Bootstrapper/MiddlewareRegistry.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public MiddlewareRegistry()
5353
c.ExampleFilters();
5454

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

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

8484
RequestResponseMiddlewareLoggingConfig config =
85-
new RequestResponseMiddlewareLoggingConfig(middlewareLogLevel, logRequests, logResponses);
85+
new(middlewareLogLevel, logRequests, logResponses);
8686

8787
this.AddSingleton(config);
8888
}

CallbackHandler/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public static void Main(string[] args)
3131
public static IHostBuilder CreateHostBuilder(string[] args)
3232
{
3333
//At this stage, we only need our hosting file for ip and ports
34+
3435
FileInfo fi = new(typeof(Program).Assembly.Location);
3536

3637
IConfigurationRoot config = new ConfigurationBuilder().SetBasePath(fi.Directory.FullName)

0 commit comments

Comments
 (0)