Skip to content

Commit cfd93e8

Browse files
authored
Merge pull request #37 from jongalloway/copilot/fix-template-engine-issue
Fix: Change virtualizeSettings to false to enable template discovery
2 parents ac60520 + abec943 commit cfd93e8

File tree

2 files changed

+81
-1
lines changed

2 files changed

+81
-1
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
using DotNetMcp;
2+
using FluentAssertions;
3+
using Xunit;
4+
5+
namespace DotNetMcp.Tests;
6+
7+
public class TemplateEngineHelperTests
8+
{
9+
[Fact]
10+
public async Task GetInstalledTemplatesAsync_ReturnsSuccessfully()
11+
{
12+
// Act
13+
var result = await TemplateEngineHelper.GetInstalledTemplatesAsync();
14+
15+
// Assert
16+
result.Should().NotBeNull();
17+
// Note: The result may indicate no templates found if the template cache hasn't been
18+
// populated yet. This is expected behavior - templates are discovered when dotnet new
19+
// commands are first run in the environment. The important thing is that the method
20+
// executes without throwing exceptions.
21+
}
22+
23+
[Fact]
24+
public async Task SearchTemplatesAsync_ReturnsSuccessfully()
25+
{
26+
// Act
27+
var result = await TemplateEngineHelper.SearchTemplatesAsync("console");
28+
29+
// Assert
30+
result.Should().NotBeNull();
31+
// The search should return successfully, even if no templates are found
32+
}
33+
34+
[Fact]
35+
public async Task GetTemplateDetailsAsync_ReturnsSuccessfully()
36+
{
37+
// Act
38+
var result = await TemplateEngineHelper.GetTemplateDetailsAsync("console");
39+
40+
// Assert
41+
result.Should().NotBeNull();
42+
// The method should return successfully with an appropriate message
43+
}
44+
45+
[Fact]
46+
public async Task ValidateTemplateExistsAsync_ReturnsBoolean()
47+
{
48+
// Act
49+
var result = await TemplateEngineHelper.ValidateTemplateExistsAsync("console");
50+
51+
// Assert
52+
// Should return a boolean value without throwing - no specific assertion needed
53+
// The test passes if no exception is thrown
54+
}
55+
56+
[Fact]
57+
public async Task ValidateTemplateExistsAsync_HandlesNonExistentTemplate()
58+
{
59+
// Act
60+
var result = await TemplateEngineHelper.ValidateTemplateExistsAsync("non-existent-template-xyz123");
61+
62+
// Assert
63+
// Should return false for non-existent templates
64+
result.Should().BeFalse();
65+
}
66+
67+
[Fact]
68+
public async Task ClearCacheAsync_ExecutesSuccessfully()
69+
{
70+
// Arrange - Load templates into cache (or try to)
71+
await TemplateEngineHelper.GetInstalledTemplatesAsync();
72+
73+
// Act - Clear the cache
74+
await TemplateEngineHelper.ClearCacheAsync();
75+
76+
// Assert - Should be able to query again after clearing
77+
var result = await TemplateEngineHelper.GetInstalledTemplatesAsync();
78+
result.Should().NotBeNull();
79+
}
80+
}

DotNetMcp/TemplateEngineHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ private static async Task<IEnumerable<ITemplateInfo>> GetTemplatesCachedAsync(IL
4343
logger?.LogDebug("Template cache miss - loading templates from template engine");
4444
var engineEnvironmentSettings = new EngineEnvironmentSettings(
4545
new DefaultTemplateEngineHost("dotnet-mcp", "1.0.0"),
46-
virtualizeSettings: true);
46+
virtualizeSettings: false);
4747

4848
var templatePackageManager = new TemplatePackageManager(engineEnvironmentSettings);
4949
_templatesCache = await templatePackageManager.GetTemplatesAsync(default);

0 commit comments

Comments
 (0)