Skip to content

Commit 0c5a40a

Browse files
Increase the test coverage
1 parent 0b47d84 commit 0c5a40a

File tree

2 files changed

+438
-0
lines changed

2 files changed

+438
-0
lines changed

unittests/nexus_engine/nexus_engine_unittests/Internal/CommandQueueTestAccessor.cs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,5 +126,55 @@ public CommandQueueTestAccessor(string sessionId, ISettings settings, IBatchProc
126126
{
127127
base.SetCommandResult(command, result);
128128
}
129+
130+
/// <summary>
131+
/// Exposes the protected ProcessCommandResults method using reflection.
132+
/// </summary>
133+
/// <param name="executionResults">Execution results.</param>
134+
/// <param name="queuedCommandsById">Queued commands by ID.</param>
135+
/// <param name="commandStartTimes">Command start times.</param>
136+
public void ProcessCommandResults(System.Collections.Generic.List<CommandResult> executionResults, System.Collections.Generic.Dictionary<string, QueuedCommand> queuedCommandsById, System.Collections.Generic.Dictionary<string, DateTime> commandStartTimes)
137+
{
138+
var method = typeof(CommandQueue).GetMethod("ProcessCommandResults", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
139+
_ = method?.Invoke(this, new object[] { executionResults, queuedCommandsById, commandStartTimes });
140+
}
141+
142+
/// <summary>
143+
/// Exposes the protected CompleteCommandWithStatistics method using reflection.
144+
/// </summary>
145+
/// <param name="result">The command result.</param>
146+
/// <param name="queuedCommandsById">Queued commands by ID.</param>
147+
/// <param name="commandStartTimes">Command start times.</param>
148+
public void CompleteCommandWithStatistics(CommandResult result, System.Collections.Generic.Dictionary<string, QueuedCommand> queuedCommandsById, System.Collections.Generic.Dictionary<string, DateTime> commandStartTimes)
149+
{
150+
var method = typeof(CommandQueue).GetMethod("CompleteCommandWithStatistics", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
151+
_ = method?.Invoke(this, new object[] { result, queuedCommandsById, commandStartTimes });
152+
}
153+
154+
/// <summary>
155+
/// Exposes the protected CreateCommandInfoFromResult method using reflection.
156+
/// </summary>
157+
/// <param name="result">The command result.</param>
158+
/// <param name="queuedCommand">The queued command.</param>
159+
/// <param name="startTime">Start time.</param>
160+
/// <param name="endTime">End time.</param>
161+
/// <returns>Tuple of CommandInfo and CommandState.</returns>
162+
public (CommandInfo CommandInfo, CommandState FinalState) CreateCommandInfoFromResult(CommandResult result, QueuedCommand queuedCommand, DateTime startTime, DateTime endTime)
163+
{
164+
var method = typeof(CommandQueue).GetMethod("CreateCommandInfoFromResult", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
165+
var resultObj = method?.Invoke(this, new object[] { result, queuedCommand, startTime, endTime });
166+
return ((CommandInfo, CommandState))resultObj!;
167+
}
168+
169+
/// <summary>
170+
/// Exposes the protected LogUnbatchingResults method using reflection.
171+
/// </summary>
172+
/// <param name="executionCount">Execution count.</param>
173+
/// <param name="individualCount">Individual count.</param>
174+
public void LogUnbatchingResults(int executionCount, int individualCount)
175+
{
176+
var method = typeof(CommandQueue).GetMethod("LogUnbatchingResults", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
177+
_ = method?.Invoke(this, new object[] { executionCount, individualCount });
178+
}
129179
}
130180

0 commit comments

Comments
 (0)