Skip to content

Commit 103238c

Browse files
committed
Add unit tests for McpServer components and services
- Implement tests for DocumentationGuideService to verify guide retrieval and content. - Add tests for FluentUIDocumentationService to ensure component details and categories are correctly returned. - Create tests for various prompts including CreateComponentPrompt, CreateFormPrompt, and ExplainComponentPrompt to validate prompt generation. - Introduce tests for McpCapabilitiesData and McpReflectionService to check data integrity and resource availability. - Develop tests for tools such as ComponentDetailTools, ComponentListTools, EnumTools, and GuideTools to ensure functionality and correctness. - Establish a global usings file for test projects to streamline code. - Set up project file for the test suite with necessary dependencies and configurations. Update namespaces to new McpServer structure and Blazor APIs Migrated all FluentUI.Mcp.Server.* and FluentUI.Mcp.Shared.* references to Microsoft.FluentUI.AspNetCore.Components.McpServer.* and related namespaces across the codebase. Updated Blazor components in McpCapabilities.razor to use new FluentTabs/FluentTab APIs (Label, ActiveTabIdChanged) and added type parameters to FluentDataGrid. Adjusted service initialization and test setup to use the correct assemblies. Added "peer": true to several dev dependencies in package-lock.json. These changes align with the new package structure and resolve naming conflicts. Refine component type filtering and category sorting Expanded IsValidComponentType docs to clarify FluentUI focus and rationale for IFluentComponentBase usage. Updated filtering to require IFluentComponentBase implementation. Improved GetCategories to use case-insensitive distinct and sorting. Added explicit System.Linq import.
1 parent 960886a commit 103238c

File tree

69 files changed

+435
-172
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+435
-172
lines changed

Microsoft.FluentUI-v5.sln

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 18
4-
VisualStudioVersion = 18.0.10906.23
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.14.36705.20 d17.14
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{62586417-1901-4732-8188-AE8BADC6AE17}"
77
EndProject
@@ -45,13 +45,15 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FluentUI.Samples.WasmStanda
4545
EndProject
4646
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "mcp", "mcp", "{5B3FD904-3D34-05FA-68A8-2F22A80B7D05}"
4747
EndProject
48-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FluentUI.Mcp.Server", "examples\Mcp\FluentUI.Mcp.Server\FluentUI.Mcp.Server.csproj", "{77D4C32F-A336-44C8-83C7-80EF960B7D6C}"
48+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.FluentUI.AspNetCore.Components.McpServer", "src\Tools\McpServer\Microsoft.FluentUI.AspNetCore.Components.McpServer.csproj", "{77D4C32F-A336-44C8-83C7-80EF960B7D6C}"
4949
EndProject
50-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FluentUI.Mcp.Shared", "examples\Mcp\FluentUI.Mcp.Shared\FluentUI.Mcp.Shared.csproj", "{C908B2BA-F26E-4C10-8761-0DB94709D556}"
50+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.FluentUI.AspNetCore.Components.McpServer.Shared", "src\Tools\McpServer.Shared\Microsoft.FluentUI.AspNetCore.Components.McpServer.Shared.csproj", "{C908B2BA-F26E-4C10-8761-0DB94709D556}"
5151
EndProject
52-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Mcp", "Mcp", "{ABFC1483-C021-B6A7-FAC3-E7866B5A76F3}"
52+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tools", "Tools", "{ABFC1483-C021-B6A7-FAC3-E7866B5A76F3}"
5353
EndProject
54-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FluentUI.Mcp.Server.Tests", "tests\Mcp\FluentUI.Mcp.Server.Tests.csproj", "{A38FD403-B707-4F9A-B13F-0689D01E2BC0}"
54+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tools", "Tools", "{3D6EEA2A-E505-4D2E-B118-9F7D1FCA5BE7}"
55+
EndProject
56+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.FluentUI.AspNetCore.Components.McpServer.Tests", "tests\Tools\McpServer.Tests\Microsoft.FluentUI.AspNetCore.Components.McpServer.Tests.csproj", "{8D169F98-6030-38C1-719F-610343A83341}"
5557
EndProject
5658
Global
5759
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -228,18 +230,18 @@ Global
228230
{C908B2BA-F26E-4C10-8761-0DB94709D556}.Release|x64.Build.0 = Release|Any CPU
229231
{C908B2BA-F26E-4C10-8761-0DB94709D556}.Release|x86.ActiveCfg = Release|Any CPU
230232
{C908B2BA-F26E-4C10-8761-0DB94709D556}.Release|x86.Build.0 = Release|Any CPU
231-
{A38FD403-B707-4F9A-B13F-0689D01E2BC0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
232-
{A38FD403-B707-4F9A-B13F-0689D01E2BC0}.Debug|Any CPU.Build.0 = Debug|Any CPU
233-
{A38FD403-B707-4F9A-B13F-0689D01E2BC0}.Debug|x64.ActiveCfg = Debug|Any CPU
234-
{A38FD403-B707-4F9A-B13F-0689D01E2BC0}.Debug|x64.Build.0 = Debug|Any CPU
235-
{A38FD403-B707-4F9A-B13F-0689D01E2BC0}.Debug|x86.ActiveCfg = Debug|Any CPU
236-
{A38FD403-B707-4F9A-B13F-0689D01E2BC0}.Debug|x86.Build.0 = Debug|Any CPU
237-
{A38FD403-B707-4F9A-B13F-0689D01E2BC0}.Release|Any CPU.ActiveCfg = Release|Any CPU
238-
{A38FD403-B707-4F9A-B13F-0689D01E2BC0}.Release|Any CPU.Build.0 = Release|Any CPU
239-
{A38FD403-B707-4F9A-B13F-0689D01E2BC0}.Release|x64.ActiveCfg = Release|Any CPU
240-
{A38FD403-B707-4F9A-B13F-0689D01E2BC0}.Release|x64.Build.0 = Release|Any CPU
241-
{A38FD403-B707-4F9A-B13F-0689D01E2BC0}.Release|x86.ActiveCfg = Release|Any CPU
242-
{A38FD403-B707-4F9A-B13F-0689D01E2BC0}.Release|x86.Build.0 = Release|Any CPU
233+
{8D169F98-6030-38C1-719F-610343A83341}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
234+
{8D169F98-6030-38C1-719F-610343A83341}.Debug|Any CPU.Build.0 = Debug|Any CPU
235+
{8D169F98-6030-38C1-719F-610343A83341}.Debug|x64.ActiveCfg = Debug|Any CPU
236+
{8D169F98-6030-38C1-719F-610343A83341}.Debug|x64.Build.0 = Debug|Any CPU
237+
{8D169F98-6030-38C1-719F-610343A83341}.Debug|x86.ActiveCfg = Debug|Any CPU
238+
{8D169F98-6030-38C1-719F-610343A83341}.Debug|x86.Build.0 = Debug|Any CPU
239+
{8D169F98-6030-38C1-719F-610343A83341}.Release|Any CPU.ActiveCfg = Release|Any CPU
240+
{8D169F98-6030-38C1-719F-610343A83341}.Release|Any CPU.Build.0 = Release|Any CPU
241+
{8D169F98-6030-38C1-719F-610343A83341}.Release|x64.ActiveCfg = Release|Any CPU
242+
{8D169F98-6030-38C1-719F-610343A83341}.Release|x64.Build.0 = Release|Any CPU
243+
{8D169F98-6030-38C1-719F-610343A83341}.Release|x86.ActiveCfg = Release|Any CPU
244+
{8D169F98-6030-38C1-719F-610343A83341}.Release|x86.Build.0 = Release|Any CPU
243245
EndGlobalSection
244246
GlobalSection(SolutionProperties) = preSolution
245247
HideSolutionNode = FALSE
@@ -261,11 +263,12 @@ Global
261263
{D52F6265-A983-46E0-8831-67FA80D95FBE} = {B98A7516-E9B2-4301-B6A3-33656BF4F4D9}
262264
{02EA681E-C7D8-13C7-8484-4AC65E1B71E8} = {F273876F-7528-42B3-BFE8-7CFF8ED1E2A2}
263265
{EB38AC75-966B-41BB-A1C5-0CAFE17FE3D5} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
264-
{5B3FD904-3D34-05FA-68A8-2F22A80B7D05} = {F273876F-7528-42B3-BFE8-7CFF8ED1E2A2}
266+
{5B3FD904-3D34-05FA-68A8-2F22A80B7D05} = {3D6EEA2A-E505-4D2E-B118-9F7D1FCA5BE7}
265267
{77D4C32F-A336-44C8-83C7-80EF960B7D6C} = {5B3FD904-3D34-05FA-68A8-2F22A80B7D05}
266268
{C908B2BA-F26E-4C10-8761-0DB94709D556} = {5B3FD904-3D34-05FA-68A8-2F22A80B7D05}
267269
{ABFC1483-C021-B6A7-FAC3-E7866B5A76F3} = {A7EC98D2-21E3-4967-8C5A-D62E640305EB}
268-
{A38FD403-B707-4F9A-B13F-0689D01E2BC0} = {ABFC1483-C021-B6A7-FAC3-E7866B5A76F3}
270+
{3D6EEA2A-E505-4D2E-B118-9F7D1FCA5BE7} = {62586417-1901-4732-8188-AE8BADC6AE17}
271+
{8D169F98-6030-38C1-719F-610343A83341} = {ABFC1483-C021-B6A7-FAC3-E7866B5A76F3}
269272
EndGlobalSection
270273
GlobalSection(ExtensibilityGlobals) = postSolution
271274
SolutionGuid = {44D95FF7-AEBE-41FB-9D40-CF1E09ADC6BC}

Microsoft.FluentUI-v5.slnx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55
<Project Path="examples/Demo/FluentUI.Demo.Client/FluentUI.Demo.Client.csproj" />
66
<Project Path="examples/Demo/FluentUI.Demo/FluentUI.Demo.csproj" />
77
</Folder>
8-
<Folder Name="/examples/mcp/">
9-
<Project Path="examples/Mcp/FluentUI.Mcp.Server/FluentUI.Mcp.Server.csproj" />
10-
<Project Path="examples/Mcp/FluentUI.Mcp.Shared/FluentUI.Mcp.Shared.csproj" />
11-
</Folder>
128
<Folder Name="/examples/tools/">
139
<Project Path="examples/Tools/FluentUI.Demo.DocApiGen/FluentUI.Demo.DocApiGen.csproj" />
1410
<Project Path="examples/Tools/FluentUI.Demo.DocViewer.Tests/FluentUI.Demo.DocViewer.Tests.csproj" />
@@ -24,11 +20,17 @@
2420
</Project>
2521
<Project Path="src/Core/Microsoft.FluentUI.AspNetCore.Components.csproj" />
2622
</Folder>
23+
<Folder Name="/src/tools/">
24+
<Project Path="src/Tools/McpServer/Microsoft.FluentUI.AspNetCore.Components.McpServer.csproj" />
25+
<Project Path="src/Tools/McpServer.Shared/Microsoft.FluentUI.AspNetCore.Components.McpServer.Shared.csproj" />
26+
</Folder>
2727
<Folder Name="/tests/">
2828
<Project Path="tests/Core/Components.Tests.csproj" />
2929
<Project Path="tests/Integration/Components.IntegrationTests.csproj">
3030
<Build Solution="Debug|*" Project="false" />
3131
</Project>
32-
<Project Path="tests/Mcp/FluentUI.Mcp.Server.Tests.csproj" />
32+
</Folder>
33+
<Folder Name="/tests/tools/">
34+
<Project Path="tests/Tools/McpServer.Tests/Microsoft.FluentUI.AspNetCore.Components.McpServer.Tests.csproj" />
3335
</Folder>
3436
</Solution>

examples/Demo/FluentUI.Demo.Client/Documentation/GetStarted/Examples/McpCapabilities.razor

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
@using FluentUI.Mcp.Shared
1+
@using Microsoft.FluentUI.AspNetCore.Components.McpServer.Shared
2+
@using Microsoft.FluentUI.AspNetCore.Components.McpServer.Shared.Models
3+
@using System.Net.Http.Json
24
@inject HttpClient Http
35

46
@if (_loading)
@@ -13,9 +15,9 @@ else if (_summary is null)
1315
}
1416
else
1517
{
16-
<FluentTabs @bind-ActiveTabId="@_activeTab">
17-
<FluentTab Id="tools" Header="@($"Tools ({_summary.Tools.Count})")">
18-
<FluentDataGrid Items="@_summary.Tools.AsQueryable()" GridTemplateColumns="1fr 2fr 1fr">
18+
<FluentTabs ActiveTabId="@_activeTab" ActiveTabIdChanged="@OnTabChanged">
19+
<FluentTab Id="tools" Label="@($"Tools ({_summary.Tools.Count})")">
20+
<FluentDataGrid TGridItem="McpToolInfo" Items="@_summary.Tools.AsQueryable()" GridTemplateColumns="1fr 2fr 1fr">
1921
<PropertyColumn Property="@(t => t.Name)" Title="Name" />
2022
<PropertyColumn Property="@(t => t.Description)" Title="Description" />
2123
<TemplateColumn Title="Parameters">
@@ -43,8 +45,8 @@ else
4345
</FluentDataGrid>
4446
</FluentTab>
4547

46-
<FluentTab Id="prompts" Header="@($"Prompts ({_summary.Prompts.Count})")">
47-
<FluentDataGrid Items="@_summary.Prompts.AsQueryable()" GridTemplateColumns="1fr 2fr 1fr">
48+
<FluentTab Id="prompts" Label="@($"Prompts ({_summary.Prompts.Count})")">
49+
<FluentDataGrid TGridItem="McpPromptInfo" Items="@_summary.Prompts.AsQueryable()" GridTemplateColumns="1fr 2fr 1fr">
4850
<PropertyColumn Property="@(p => p.Name)" Title="Name" />
4951
<PropertyColumn Property="@(p => p.Description)" Title="Description" />
5052
<TemplateColumn Title="Parameters">
@@ -72,8 +74,8 @@ else
7274
</FluentDataGrid>
7375
</FluentTab>
7476

75-
<FluentTab Id="resources" Header="@($"Resources ({_summary.Resources.Count})")">
76-
<FluentDataGrid Items="@_summary.Resources.AsQueryable()" GridTemplateColumns="1fr 1fr 2fr 0.5fr">
77+
<FluentTab Id="resources" Label="@($"Resources ({_summary.Resources.Count})")">
78+
<FluentDataGrid TGridItem="McpResourceInfo" Items="@_summary.Resources.AsQueryable()" GridTemplateColumns="1fr 1fr 2fr 0.5fr">
7779
<PropertyColumn Property="@(r => r.Uri)" Title="URI" />
7880
<PropertyColumn Property="@(r => r.Title)" Title="Title" />
7981
<PropertyColumn Property="@(r => r.Description)" Title="Description" />
@@ -121,4 +123,9 @@ else
121123
_loading = false;
122124
}
123125
}
126+
127+
private void OnTabChanged(string? tabId)
128+
{
129+
_activeTab = tabId ?? "tools";
130+
}
124131
}

examples/Demo/FluentUI.Demo.Client/FluentUI.Demo.Client.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444

4545
<ItemGroup>
4646
<ProjectReference Include="..\..\..\src\Core\Microsoft.FluentUI.AspNetCore.Components.csproj" />
47-
<ProjectReference Include="..\..\Mcp\FluentUI.Mcp.Shared\FluentUI.Mcp.Shared.csproj" />
47+
<ProjectReference Include="..\..\..\src\Tools\McpServer.Shared\Microsoft.FluentUI.AspNetCore.Components.McpServer.Shared.csproj" />
4848
<ProjectReference Include="..\..\Tools\FluentUI.Demo.DocViewer\FluentUI.Demo.DocViewer.csproj" />
4949
<ProjectReference Include="..\..\Tools\FluentUI.Demo.SampleData\FluentUI.Demo.SampleData.csproj" />
5050
</ItemGroup>

examples/Demo/FluentUI.Demo/FluentUI.Demo.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk.Web">
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
44
<TargetFramework>net9.0</TargetFramework>
@@ -10,7 +10,7 @@
1010

1111
<ItemGroup>
1212
<ProjectReference Include="..\..\..\src\Core\Microsoft.FluentUI.AspNetCore.Components.csproj" />
13-
<ProjectReference Include="..\..\Mcp\FluentUI.Mcp.Server\FluentUI.Mcp.Server.csproj" />
13+
<ProjectReference Include="..\..\..\src\Tools\McpServer\Microsoft.FluentUI.AspNetCore.Components.McpServer.csproj" />
1414
<ProjectReference Include="..\FluentUI.Demo.Client\FluentUI.Demo.Client.csproj" />
1515
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" />
1616
</ItemGroup>

examples/Demo/FluentUI.Demo/Program.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
// ------------------------------------------------------------------------
44

55
using FluentUI.Demo.Client;
6-
using FluentUI.Mcp.Shared;
76
using Microsoft.FluentUI.AspNetCore.Components;
7+
using Microsoft.FluentUI.AspNetCore.Components.McpServer.Services;
8+
using Microsoft.FluentUI.AspNetCore.Components.McpServer.Shared;
89

910
var builder = WebApplication.CreateBuilder(args);
1011

@@ -34,7 +35,7 @@
3435
builder.Services.AddFluentUIDemoServices().ForServer();
3536

3637
// Initialize MCP capabilities data from the MCP Server assembly
37-
McpCapabilitiesData.Initialize(typeof(FluentUI.Mcp.Server.Services.FluentUIDocumentationService).Assembly);
38+
McpCapabilitiesData.Initialize(typeof(FluentUIDocumentationService).Assembly);
3839

3940
var app = builder.Build();
4041

nuget.config

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
33
<packageSources>
44
<clear />
55
<add key="dotnet-public" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json" />
6+
<add key="dotnet9" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet9/nuget/v3/index.json" />
7+
<add key="nuget" value="https://api.nuget.org/v3/index.json" />
68
</packageSources>
79
</configuration>

src/Core.Scripts/package-lock.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/Mcp/FluentUI.Mcp.Shared/McpCapabilitiesData.cs renamed to src/Tools/McpServer.Shared/McpCapabilitiesData.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
// ------------------------------------------------------------------------
44

55
using System.Reflection;
6+
using Microsoft.FluentUI.AspNetCore.Components.McpServer.Shared.Models;
67

7-
namespace FluentUI.Mcp.Shared;
8+
namespace Microsoft.FluentUI.AspNetCore.Components.McpServer.Shared;
89

910
/// <summary>
1011
/// Provides access to MCP capabilities data discovered via reflection.

examples/Mcp/FluentUI.Mcp.Shared/McpReflectionService.cs renamed to src/Tools/McpServer.Shared/McpReflectionService.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44

55
using System.ComponentModel;
66
using System.Reflection;
7+
using Microsoft.FluentUI.AspNetCore.Components.McpServer.Shared.Models;
78

8-
namespace FluentUI.Mcp.Shared;
9+
namespace Microsoft.FluentUI.AspNetCore.Components.McpServer.Shared;
910

1011
/// <summary>
1112
/// Provides reflection-based discovery of MCP tools, prompts, and resources.

0 commit comments

Comments
 (0)