From d7783b6e814ec0943ec09c3833a8a37bced6d445 Mon Sep 17 00:00:00 2001 From: TekH Date: Wed, 25 Mar 2026 11:17:21 +0100 Subject: [PATCH] Make InsertObjectProcedure properties nullable, require ResultType Updated InsertObjectProcedure to make related command properties nullable and removed default initializations. Updated handler to use null-conditional access for these properties. Changed InsertResultCommand.Type to required and updated tests accordingly. Improves null safety and clarifies required fields. --- .../InsertProcedure/InsertObjectProcedure.cs | 116 +++++++++--------- .../Results/Commands/InsertResultCommand.cs | 2 +- .../Results/ResultProcedureTests.cs | 2 +- 3 files changed, 60 insertions(+), 60 deletions(-) diff --git a/src/ReC.Application/Common/Procedures/InsertProcedure/InsertObjectProcedure.cs b/src/ReC.Application/Common/Procedures/InsertProcedure/InsertObjectProcedure.cs index 71f935e..c9410f1 100644 --- a/src/ReC.Application/Common/Procedures/InsertProcedure/InsertObjectProcedure.cs +++ b/src/ReC.Application/Common/Procedures/InsertProcedure/InsertObjectProcedure.cs @@ -24,12 +24,12 @@ public record InsertObjectProcedure : IRequest //TODO: update to set in authentication middleware or similar, and remove from procedure properties internal string? AddedWho { get; private set; } = "ReC.API"; - public InsertActionCommand Action { get; set; } = new(); - public InsertEndpointCommand Endpoint { get; set; } = new(); - public InsertEndpointAuthCommand EndpointAuth { get; set; } = new(); - public InsertProfileCommand Profile { get; set; } = new(); - public InsertResultCommand Result { get; set; } = new(); - public InsertEndpointParamsCommand EndpointParams { get; set; } = new(); + public InsertActionCommand? Action { get; set; } + public InsertEndpointCommand? Endpoint { get; set; } + public InsertEndpointAuthCommand? EndpointAuth { get; set; } + public InsertProfileCommand? Profile { get; set; } + public InsertResultCommand? Result { get; set; } + public InsertEndpointParamsCommand? EndpointParams { get; set; } } public class InsertObjectProcedureHandler(IRepository repo, IOptionsMonitor sqlExOpt) : IRequestHandler @@ -43,58 +43,58 @@ public class InsertObjectProcedureHandler(IRepository repo, IOptionsMonitor diff --git a/tests/ReC.Tests/Application/Results/ResultProcedureTests.cs b/tests/ReC.Tests/Application/Results/ResultProcedureTests.cs index d5b2aa7..b4f2849 100644 --- a/tests/ReC.Tests/Application/Results/ResultProcedureTests.cs +++ b/tests/ReC.Tests/Application/Results/ResultProcedureTests.cs @@ -23,7 +23,7 @@ public class ResultProcedureTests : RecApplicationTestBase [Test] public async Task InsertResultProcedure_runs_via_mediator() { - var procedure = new InsertResultCommand { ActionId = 1, StatusId = 200, Header = "h", Body = "b" }; + var procedure = new InsertResultCommand { ActionId = 1, StatusId = 200, Header = "h", Body = "b", Type = Domain.Constants.ResultType.Main }; var (sender, scope) = CreateScopedSender(); using var _ = scope;