Skip to content

Conversation

@JesuTerraz
Copy link
Contributor

@JesuTerraz JesuTerraz commented Dec 19, 2025

Some mts tests are starting up the server, this abstraction layer with IServerService allows test cases to mock the StartAsync() method and avoid the static call for Server.Start()

@JesuTerraz JesuTerraz marked this pull request as ready for review December 19, 2025 19:28
@JesuTerraz JesuTerraz requested a review from a team as a code owner December 19, 2025 19:28
Copilot AI review requested due to automatic review settings December 19, 2025 19:28
@JesuTerraz JesuTerraz requested a review from a team as a code owner December 19, 2025 19:28
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces an abstraction layer for server startup functionality to improve testability. The IServerService interface allows test cases to mock the StartAsync() method, eliminating the need for static calls to Server.Start() in test scenarios.

Key Changes

  • Created IServerService interface and ServerService implementation to wrap server startup logic
  • Registered ServerService in the dependency injection container
  • Updated MockToolingServerSubcommand and related commands to accept and use IServerService instead of calling Server.Start() directly
  • Updated all test files to mock IServerService for better test isolation

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/Microsoft.Agents.A365.DevTools.Cli/Services/IServerService.cs New interface defining server startup contract
src/Microsoft.Agents.A365.DevTools.Cli/Services/ServerService.cs Implementation that wraps Server.Start() call
src/Microsoft.Agents.A365.DevTools.Cli/Program.cs Registers IServerService in DI container and passes it to commands
src/Microsoft.Agents.A365.DevTools.Cli/Commands/DevelopCommand.cs Updated to accept and pass IServerService to subcommands
src/Microsoft.Agents.A365.DevTools.Cli/Commands/DevelopSubcommands/MockToolingServerSubcommand.cs Refactored to use injected IServerService instead of static Server.Start() call
src/Tests/Microsoft.Agents.A365.DevTools.Cli.Tests/Commands/MockToolingServerSubcommandTests.cs Updated to mock IServerService for all test cases
src/Tests/Microsoft.Agents.A365.DevTools.Cli.Tests/Commands/DevelopCommandTests.cs Updated to pass mock IServerService to command creation methods

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (2)

src/Tests/Microsoft.Agents.A365.DevTools.Cli.Tests/Commands/MockToolingServerSubcommandTests.cs:276

  • The tests verify that the server service mock is configured to return Task.CompletedTask, but there's no verification that StartAsync is actually called when running in foreground mode (background=false). Consider adding assertions to verify that the server service's StartAsync method is invoked with the expected arguments in foreground scenarios, similar to how ProcessService.StartInNewTerminal is verified for background mode.
    public async Task HandleStartServer_WithNullPort_UsesDefaultPort()
    {
        // Act - Default behavior is foreground (background=false)
        await MockToolingServerSubcommand.HandleStartServer(null, false, false, false, _testLogger, _mockProcessService, _mockServerService);

        // Assert - Should log foreground startup messages with default port
        Assert.NotEmpty(_testLogger.LogCalls);
        Assert.Contains(_testLogger.LogCalls, call =>
            call.Level == LogLevel.Information &&
            call.Message.Contains("Starting Up MockToolingServer."));

        Assert.Contains(_testLogger.LogCalls, call =>
            call.Level == LogLevel.Information &&
            call.Message.Contains("Press Ctrl+C to stop the server."));
    }

src/Tests/Microsoft.Agents.A365.DevTools.Cli.Tests/Commands/MockToolingServerSubcommandTests.cs:297

  • The tests verify that the server service mock is configured to return Task.CompletedTask, but there's no verification that StartAsync is actually called when running in foreground mode (background=false). Consider adding assertions to verify that the server service's StartAsync method is invoked with the expected arguments in foreground scenarios, similar to how ProcessService.StartInNewTerminal is verified for background mode.
    public async Task HandleStartServer_WithValidPort_LogsStartingMessage(int validPort)
    {
        // Act - Default behavior is foreground (background=false)
        await MockToolingServerSubcommand.HandleStartServer(validPort, false, false, false, _testLogger, _mockProcessService, _mockServerService);

        // Assert - Should log foreground startup messages
        Assert.NotEmpty(_testLogger.LogCalls);
        Assert.Contains(_testLogger.LogCalls, call =>
            call.Level == LogLevel.Information &&
            call.Message.Contains("Starting Up MockToolingServer."));

        Assert.Contains(_testLogger.LogCalls, call =>
            call.Level == LogLevel.Information &&
            call.Message.Contains("Press Ctrl+C to stop the server."));
    }

Copilot AI review requested due to automatic review settings December 19, 2025 22:18
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants