Skip to content

Commit 90745a7

Browse files
Increase the test coverage
1 parent 9f45d88 commit 90745a7

File tree

2 files changed

+117
-7
lines changed

2 files changed

+117
-7
lines changed

unittests/nexus_engine/nexus_engine_unittests/Internal/CommandQueueTests.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -885,17 +885,15 @@ public void EnqueueCommand_WithNoSubscribers_DoesNotThrow()
885885
}
886886

887887
/// <summary>
888-
/// Verifies that GetCommandInfoAsync returns null when command does not exist.
888+
/// Verifies that GetCommandInfoAsync throws KeyNotFoundException when command does not exist.
889889
/// </summary>
890890
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
891891
[Fact]
892-
public async Task GetCommandInfoAsync_WhenCommandNotFound_ReturnsNull()
892+
public async Task GetCommandInfoAsync_WhenCommandNotFound_ThrowsKeyNotFoundException()
893893
{
894-
// Act
895-
var result = await m_Queue.GetCommandInfoAsync("nonexistent-command-id");
896-
897-
// Assert
898-
_ = result.Should().BeNull();
894+
// Act & Assert
895+
var act = async () => await m_Queue.GetCommandInfoAsync("nonexistent-command-id");
896+
_ = await act.Should().ThrowAsync<KeyNotFoundException>().WithMessage("*nonexistent-command-id*");
899897
}
900898

901899
/// <summary>

unittests/nexus_unittests/Startup/StartupBannerTests.cs

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,4 +224,116 @@ public void DisplayBanner_WithVariousModes_Succeeds(string mode)
224224
// Assert - No exception thrown
225225
_ = banner.Should().NotBeNull();
226226
}
227+
228+
/// <summary>
229+
/// Verifies that DisplayBanner displays service configuration when install path is set.
230+
/// </summary>
231+
[Fact]
232+
public void DisplayBanner_WithServiceInstallPath_DisplaysServiceConfiguration()
233+
{
234+
// Arrange
235+
var config = new Config.Models.SharedConfiguration
236+
{
237+
McpNexus = new Config.Models.McpNexusSettings
238+
{
239+
Service = new Config.Models.ServiceSettings
240+
{
241+
InstallPath = @"C:\Program Files\MCP-Nexus",
242+
BackupPath = @"C:\Program Files\MCP-Nexus\Backup",
243+
},
244+
},
245+
};
246+
_ = m_Settings.Setup(s => s.Get()).Returns(config);
247+
var context = new CommandLineContext(Array.Empty<string>());
248+
var banner = new StartupBanner(false, context, m_Settings.Object);
249+
250+
// Act
251+
banner.DisplayBanner();
252+
253+
// Assert - No exception thrown, service configuration should be displayed
254+
_ = banner.Should().NotBeNull();
255+
}
256+
257+
/// <summary>
258+
/// Verifies that DisplayBanner handles null settings values gracefully.
259+
/// </summary>
260+
[Fact]
261+
public void DisplayBanner_WithNullSettingsValues_HandlesGracefully()
262+
{
263+
// Arrange
264+
var config = new Config.Models.SharedConfiguration
265+
{
266+
McpNexus = new Config.Models.McpNexusSettings
267+
{
268+
Server = new Config.Models.ServerSettings
269+
{
270+
Host = null!,
271+
Port = 5511,
272+
},
273+
Transport = new Config.Models.TransportSettings
274+
{
275+
Mode = null!,
276+
ServiceMode = false,
277+
},
278+
Debugging = new Config.Models.DebuggingSettings
279+
{
280+
CdbPath = null!,
281+
CommandTimeoutMs = 30000,
282+
SymbolServerMaxRetries = 3,
283+
SymbolSearchPath = null!,
284+
StartupDelayMs = 0,
285+
},
286+
Service = new Config.Models.ServiceSettings
287+
{
288+
InstallPath = null!,
289+
BackupPath = null!,
290+
},
291+
},
292+
Logging = new Config.Models.LoggingSettings
293+
{
294+
LogLevel = null!,
295+
},
296+
};
297+
_ = m_Settings.Setup(s => s.Get()).Returns(config);
298+
var context = new CommandLineContext(Array.Empty<string>());
299+
var banner = new StartupBanner(false, context, m_Settings.Object);
300+
301+
// Act
302+
banner.DisplayBanner();
303+
304+
// Assert - No exception thrown
305+
_ = banner.Should().NotBeNull();
306+
}
307+
308+
/// <summary>
309+
/// Verifies that DisplayBanner handles empty string settings values gracefully.
310+
/// </summary>
311+
[Fact]
312+
public void DisplayBanner_WithEmptyStringSettingsValues_HandlesGracefully()
313+
{
314+
// Arrange
315+
var config = new Config.Models.SharedConfiguration
316+
{
317+
McpNexus = new Config.Models.McpNexusSettings
318+
{
319+
Debugging = new Config.Models.DebuggingSettings
320+
{
321+
CdbPath = string.Empty,
322+
SymbolSearchPath = string.Empty,
323+
CommandTimeoutMs = 30000,
324+
SymbolServerMaxRetries = 3,
325+
StartupDelayMs = 0,
326+
},
327+
},
328+
};
329+
_ = m_Settings.Setup(s => s.Get()).Returns(config);
330+
var context = new CommandLineContext(Array.Empty<string>());
331+
var banner = new StartupBanner(false, context, m_Settings.Object);
332+
333+
// Act
334+
banner.DisplayBanner();
335+
336+
// Assert - No exception thrown
337+
_ = banner.Should().NotBeNull();
338+
}
227339
}

0 commit comments

Comments
 (0)