Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT License.

using System.Collections;
using Azure.Mcp.Core.Areas.Server.Commands;
using Microsoft.Mcp.Core.Areas.Server.Commands;
using Xunit;

namespace Azure.Mcp.Core.UnitTests.Areas.Server;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using Azure.Mcp.Core.Areas.Server.Commands.Discovery;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Mcp.Core.Areas.Server.Commands.Discovery;
using ModelContextProtocol.Client;
using NSubstitute;
using Xunit;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using Azure.Mcp.Core.Areas.Server.Commands.Discovery;
using Azure.Mcp.Core.Areas.Server.Options;
using Azure.Mcp.Core.Commands;
using Azure.Mcp.Tests.Client.Helpers;
using Microsoft.Mcp.Core.Areas.Server.Commands.Discovery;
using Microsoft.Mcp.Core.Areas.Server.Options;
using Xunit;

namespace Azure.Mcp.Core.UnitTests.Areas.Server.Commands.Discovery;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using Azure.Mcp.Core.Areas.Server.Commands.Discovery;
using Azure.Mcp.Core.Commands;
using Azure.Mcp.Tests.Client.Helpers;
using Microsoft.Mcp.Core.Areas.Server.Commands.Discovery;
using Microsoft.Mcp.Core.Commands;
using ModelContextProtocol.Client;
using Xunit;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using Azure.Mcp.Core.Areas.Server.Commands.Discovery;
using Microsoft.Mcp.Core.Areas.Server.Commands.Discovery;
using NSubstitute;
using Xunit;

Expand Down Expand Up @@ -42,7 +42,7 @@ public void Constructor_WithValidStrategies_InitializesCorrectly()
var strategy2 = Substitute.For<IMcpDiscoveryStrategy>();

// Act
var composite = CreateCompositeStrategy(new[] { strategy1, strategy2 });
var composite = CreateCompositeStrategy([strategy1, strategy2]);

// Assert
Assert.NotNull(composite);
Expand Down Expand Up @@ -89,7 +89,7 @@ public async Task DiscoverServersAsync_WithSingleStrategy_ReturnsProvidersFromTh
var provider1 = CreateMockProvider("test1");
var provider2 = CreateMockProvider("test2");
var strategy = CreateMockStrategy(provider1, provider2);
var composite = CreateCompositeStrategy(new[] { strategy });
var composite = CreateCompositeStrategy([strategy]);

// Act
var result = (await composite.DiscoverServersAsync(TestContext.Current.CancellationToken)).ToList();
Expand All @@ -111,7 +111,7 @@ public async Task DiscoverServersAsync_WithMultipleStrategies_AggregatesAllResul

var strategy1 = CreateMockStrategy(provider1, provider2);
var strategy2 = CreateMockStrategy(provider3, provider4);
var composite = CreateCompositeStrategy(new[] { strategy1, strategy2 });
var composite = CreateCompositeStrategy([strategy1, strategy2]);

// Act
var result = (await composite.DiscoverServersAsync(TestContext.Current.CancellationToken)).ToList();
Expand All @@ -133,7 +133,7 @@ public async Task DiscoverServersAsync_WithStrategiesReturningEmpty_HandlesGrace
var emptyStrategy1 = CreateMockStrategy(); // No providers
var emptyStrategy2 = CreateMockStrategy(); // No providers

var composite = CreateCompositeStrategy(new[] { activeStrategy, emptyStrategy1, emptyStrategy2 });
var composite = CreateCompositeStrategy([activeStrategy, emptyStrategy1, emptyStrategy2]);

// Act
var result = (await composite.DiscoverServersAsync(TestContext.Current.CancellationToken)).ToList();
Expand All @@ -149,7 +149,7 @@ public async Task DiscoverServersAsync_WithAllEmptyStrategies_ReturnsEmptyCollec
// Arrange
var emptyStrategy1 = CreateMockStrategy();
var emptyStrategy2 = CreateMockStrategy();
var composite = CreateCompositeStrategy(new[] { emptyStrategy1, emptyStrategy2 });
var composite = CreateCompositeStrategy([emptyStrategy1, emptyStrategy2]);

// Act
var result = await composite.DiscoverServersAsync(TestContext.Current.CancellationToken);
Expand All @@ -171,7 +171,7 @@ public async Task DiscoverServersAsync_ExecutesAllStrategiesInParallel()
var strategy2 = CreateMockStrategy(provider2);
var strategy3 = CreateMockStrategy(provider3);

var composite = CreateCompositeStrategy(new[] { strategy1, strategy2, strategy3 });
var composite = CreateCompositeStrategy([strategy1, strategy2, strategy3]);

// Act
var result = (await composite.DiscoverServersAsync(TestContext.Current.CancellationToken)).ToList();
Expand Down Expand Up @@ -200,7 +200,7 @@ public async Task DiscoverServersAsync_PreservesOrderFromStrategies()
var strategy1 = CreateMockStrategy(provider1, provider2);
var strategy2 = CreateMockStrategy(provider3, provider4);

var composite = CreateCompositeStrategy(new[] { strategy1, strategy2 });
var composite = CreateCompositeStrategy([strategy1, strategy2]);

// Act
var result = (await composite.DiscoverServersAsync(TestContext.Current.CancellationToken)).ToList();
Expand All @@ -221,7 +221,7 @@ public async Task DiscoverServersAsync_CanBeCalledMultipleTimes()
var provider1 = CreateMockProvider("provider1");
var provider2 = CreateMockProvider("provider2");
var strategy = CreateMockStrategy(provider1, provider2);
var composite = CreateCompositeStrategy(new[] { strategy });
var composite = CreateCompositeStrategy([strategy]);

// Act
var result1 = (await composite.DiscoverServersAsync(TestContext.Current.CancellationToken)).ToList();
Expand All @@ -246,7 +246,7 @@ public async Task DiscoverServersAsync_WithDuplicateProviders_IncludesAllProvide
var strategy1 = CreateMockStrategy(provider1);
var strategy2 = CreateMockStrategy(provider2);

var composite = CreateCompositeStrategy(new[] { strategy1, strategy2 });
var composite = CreateCompositeStrategy([strategy1, strategy2]);

// Act
var result = (await composite.DiscoverServersAsync(TestContext.Current.CancellationToken)).ToList();
Expand All @@ -263,7 +263,7 @@ public async Task DiscoverServersAsync_InheritsFromBaseDiscoveryStrategy()
{
// Arrange
var strategy = CreateMockStrategy();
var composite = CreateCompositeStrategy(new[] { strategy });
var composite = CreateCompositeStrategy([strategy]);

// Act & Assert
Assert.IsAssignableFrom<BaseDiscoveryStrategy>(composite);
Expand All @@ -281,9 +281,9 @@ public async Task ShouldAggregateResults()
var mockStrategy2 = Substitute.For<IMcpDiscoveryStrategy>();
var provider1 = Substitute.For<IMcpServerProvider>();
var provider2 = Substitute.For<IMcpServerProvider>();
mockStrategy1.DiscoverServersAsync(TestContext.Current.CancellationToken).Returns(Task.FromResult<IEnumerable<IMcpServerProvider>>(new[] { provider1 }));
mockStrategy2.DiscoverServersAsync(TestContext.Current.CancellationToken).Returns(Task.FromResult<IEnumerable<IMcpServerProvider>>(new[] { provider2 }));
var composite = CreateCompositeStrategy(new[] { mockStrategy1, mockStrategy2 });
mockStrategy1.DiscoverServersAsync(TestContext.Current.CancellationToken).Returns(Task.FromResult<IEnumerable<IMcpServerProvider>>([provider1]));
mockStrategy2.DiscoverServersAsync(TestContext.Current.CancellationToken).Returns(Task.FromResult<IEnumerable<IMcpServerProvider>>([provider2]));
var composite = CreateCompositeStrategy([mockStrategy1, mockStrategy2]);
var result = await composite.DiscoverServersAsync(TestContext.Current.CancellationToken);
Assert.Contains(provider1, result);
Assert.Contains(provider2, result);
Expand All @@ -298,9 +298,9 @@ public async Task ShouldAggregateResults_ReturnsAllProviders()
var provider2 = Substitute.For<IMcpServerProvider>();
provider1.CreateMetadata().Returns(new McpServerMetadata { Id = "one", Name = "one", Description = "desc1" });
provider2.CreateMetadata().Returns(new McpServerMetadata { Id = "two", Name = "two", Description = "desc2" });
mockStrategy1.DiscoverServersAsync(TestContext.Current.CancellationToken).Returns(Task.FromResult<IEnumerable<IMcpServerProvider>>(new[] { provider1 }));
mockStrategy2.DiscoverServersAsync(TestContext.Current.CancellationToken).Returns(Task.FromResult<IEnumerable<IMcpServerProvider>>(new[] { provider2 }));
var composite = CreateCompositeStrategy(new[] { mockStrategy1, mockStrategy2 });
mockStrategy1.DiscoverServersAsync(TestContext.Current.CancellationToken).Returns(Task.FromResult<IEnumerable<IMcpServerProvider>>([provider1]));
mockStrategy2.DiscoverServersAsync(TestContext.Current.CancellationToken).Returns(Task.FromResult<IEnumerable<IMcpServerProvider>>([provider2]));
var composite = CreateCompositeStrategy([mockStrategy1, mockStrategy2]);
var result = (await composite.DiscoverServersAsync(TestContext.Current.CancellationToken)).ToList();
Assert.Equal(2, result.Count);
Assert.Contains(result, p => p.CreateMetadata().Id == "one");
Expand All @@ -312,7 +312,7 @@ public async Task DiscoverServersAsync_WithSingleEmptyStrategy_ReturnsEmptyColle
{
// Arrange
var emptyStrategy = CreateMockStrategy(); // No providers
var composite = CreateCompositeStrategy(new[] { emptyStrategy });
var composite = CreateCompositeStrategy([emptyStrategy]);

// Act
var result = await composite.DiscoverServersAsync(TestContext.Current.CancellationToken);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using Azure.Mcp.Core.Areas.Server.Commands.Discovery;
using Azure.Mcp.Core.Areas.Server.Options;
using Azure.Mcp.Core.Commands;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Mcp.Core.Areas.Server.Commands.Discovery;
using Microsoft.Mcp.Core.Areas.Server.Options;
using Microsoft.Mcp.Core.Configuration;
using Xunit;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using Azure.Mcp.Core.Areas.Server.Commands.Discovery;
using Azure.Mcp.Core.Areas.Server.Options;
using Azure.Mcp.Core.Helpers;
using Microsoft.Mcp.Core.Areas.Server.Commands.Discovery;
using Microsoft.Mcp.Core.Areas.Server.Options;
using Xunit;

namespace Azure.Mcp.Core.UnitTests.Areas.Server.Commands.Discovery;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

using System.Net;
using System.Net.Sockets;
using Azure.Mcp.Core.Areas.Server.Commands.Discovery;
using Azure.Mcp.Core.Areas.Server.Models;
using Microsoft.Mcp.Core.Areas.Server.Commands.Discovery;
using Microsoft.Mcp.Core.Areas.Server.Models;
using ModelContextProtocol.Client;
using NSubstitute;
using Xunit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

using System.Diagnostics;
using System.Text.Json;
using Azure.Mcp.Core.Areas.Server.Commands.Runtime;
using Azure.Mcp.Core.Areas.Server.Commands.ToolLoading;
using Azure.Mcp.Core.Areas.Server.Options;
using Azure.Mcp.Core.Models.Option;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Microsoft.Mcp.Core.Areas.Server.Commands.Runtime;
using Microsoft.Mcp.Core.Areas.Server.Commands.ToolLoading;
using Microsoft.Mcp.Core.Areas.Server.Options;
using Microsoft.Mcp.Core.Commands;
using Microsoft.Mcp.Core.Services.Telemetry;
using ModelContextProtocol.Protocol;
Expand Down Expand Up @@ -91,7 +91,7 @@ public void Constructor_WithValidParameters_InitializesCorrectly()
// Assert
Assert.NotNull(runtime);
Assert.IsType<McpRuntime>(runtime);
Assert.IsAssignableFrom<IMcpRuntime>(runtime);
Assert.IsType<IMcpRuntime>(runtime, exactMatch: false);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using Azure.Mcp.Core.Areas.Server.Commands;
using Azure.Mcp.Core.Areas.Server.Options;
using Azure.Mcp.Core.Helpers;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Microsoft.Mcp.Core.Areas.Server.Commands;
using Microsoft.Mcp.Core.Areas.Server.Options;
using Microsoft.Mcp.Core.Configuration;
using Xunit;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using Azure.Mcp.Core.Areas.Server;
using Azure.Mcp.Core.Areas.Server.Commands;
using Azure.Mcp.Core.Areas.Server.Commands.Discovery;
using Azure.Mcp.Core.Areas.Server.Commands.Runtime;
using Azure.Mcp.Core.Areas.Server.Commands.ToolLoading;
using Azure.Mcp.Core.Areas.Server.Options;
using Azure.Mcp.Core.Services.Azure.Authentication;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Microsoft.Mcp.Core.Areas.Server;
using Microsoft.Mcp.Core.Areas.Server.Commands;
using Microsoft.Mcp.Core.Areas.Server.Commands.Discovery;
using Microsoft.Mcp.Core.Areas.Server.Commands.Runtime;
using Microsoft.Mcp.Core.Areas.Server.Commands.ToolLoading;
using Microsoft.Mcp.Core.Areas.Server.Options;
using ModelContextProtocol.Server;
using Xunit;

using TransportTypes = Azure.Mcp.Core.Areas.Server.Options.TransportTypes;

namespace Azure.Mcp.Core.UnitTests.Areas.Server.Commands;

public class ServiceCollectionExtensionsTests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

using System.CommandLine;
using System.Text.Json;
using Azure.Mcp.Core.Areas.Server.Commands;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Mcp.Core.Areas.Server.Commands;
using Microsoft.Mcp.Core.Configuration;
using Microsoft.Mcp.Core.Models.Command;
using NSubstitute;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// Licensed under the MIT License.

using System.Text.Json;
using Azure.Mcp.Core.Areas.Server.Commands.ToolLoading;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Mcp.Core.Areas.Server.Commands.ToolLoading;
using ModelContextProtocol.Client;
using ModelContextProtocol.Protocol;
using ModelContextProtocol.Server;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
using System.CommandLine;
using System.Net;
using System.Text.Json;
using Azure.Mcp.Core.Areas.Server.Commands.ToolLoading;
using Azure.Mcp.Core.Commands;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Mcp.Core.Areas.Server.Commands.ToolLoading;
using Microsoft.Mcp.Core.Commands;
using Microsoft.Mcp.Core.Models.Command;
using ModelContextProtocol.Protocol;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// Licensed under the MIT License.

using System.Text.Json;
using Azure.Mcp.Core.Areas.Server.Commands.ToolLoading;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Mcp.Core.Areas.Server.Commands.ToolLoading;
using ModelContextProtocol.Protocol;
using ModelContextProtocol.Server;
using NSubstitute;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
// Licensed under the MIT License.

using System.Text.Json;
using Azure.Mcp.Core.Areas.Server.Commands.ToolLoading;
using Azure.Mcp.Core.Areas.Server.Options;
using Azure.Mcp.Core.Commands;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Microsoft.Mcp.Core.Areas.Server.Commands.Discovery;
using Microsoft.Mcp.Core.Areas.Server.Commands.ToolLoading;
using Microsoft.Mcp.Core.Areas.Server.Options;
using ModelContextProtocol.Protocol;
using NSubstitute;
using Xunit;
Expand Down Expand Up @@ -561,7 +562,7 @@ await Assert.ThrowsAsync<ArgumentNullException>(async () =>
private string GetFirstAvailableNamespace()
{
var namespaces = _commandFactory.RootGroup.SubGroup
.Where(g => !Azure.Mcp.Core.Areas.Server.Commands.Discovery.DiscoveryConstants.IgnoredCommandGroups.Contains(g.Name, StringComparer.OrdinalIgnoreCase))
.Where(g => !DiscoveryConstants.IgnoredCommandGroups.Contains(g.Name, StringComparer.OrdinalIgnoreCase))
.Select(g => g.Name)
.ToList();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
// Licensed under the MIT License.

using System.Text.Json;
using Azure.Mcp.Core.Areas.Server.Commands.Discovery;
using Azure.Mcp.Core.Areas.Server.Commands.ToolLoading;
using Azure.Mcp.Core.UnitTests.Areas.Server.Helpers;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Mcp.Core.Areas.Server.Commands.Discovery;
using Microsoft.Mcp.Core.Areas.Server.Commands.ToolLoading;
using ModelContextProtocol.Client;
using ModelContextProtocol.Protocol;
using NSubstitute;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
// Licensed under the MIT License.

using System.Text.Json;
using Azure.Mcp.Core.Areas.Server.Commands.Discovery;
using Azure.Mcp.Core.Areas.Server.Commands.ToolLoading;
using Azure.Mcp.Core.Areas.Server.Options;
using Azure.Mcp.Core.Helpers;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Mcp.Core.Areas.Server.Commands.Discovery;
using Microsoft.Mcp.Core.Areas.Server.Commands.ToolLoading;
using Microsoft.Mcp.Core.Areas.Server.Options;
using ModelContextProtocol.Protocol;
using NSubstitute;
using Xunit;
Expand Down
Loading
Loading