Files
agent-framework/dotnet/tests/Microsoft.Agents.AI.UnitTests/AgentSkills/AgentInMemorySkillsSourceTests.cs
SergeyMenshykh ade295b122 .NET: Add inline skills API (#4951)
* add inline skills

* Fix IDE1006 and IDE0004 formatting errors in test files

- Add 'Async' suffix to async test methods in FilteringAgentSkillsSourceTests,
  DeduplicatingAgentSkillsSourceTests, and AgentInMemorySkillsSourceTests
- Use pragma to suppress false-positive IDE0004 on casts needed for overload
  disambiguation in AgentInlineSkillTests and AgentInlineSkillResourceTests

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* address issues

* address comments

* make inline skills script and resource model classes internal

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-30 16:23:04 +00:00

52 lines
1.5 KiB
C#

// Copyright (c) Microsoft. All rights reserved.
using System;
using System.Threading;
using System.Threading.Tasks;
namespace Microsoft.Agents.AI.UnitTests.AgentSkills;
/// <summary>
/// Unit tests for <see cref="AgentInMemorySkillsSource"/>.
/// </summary>
public sealed class AgentInMemorySkillsSourceTests
{
[Fact]
public async Task GetSkillsAsync_ValidSkills_ReturnsAllAsync()
{
// Arrange
var skills = new AgentSkill[]
{
new AgentInlineSkill("my-skill", "A valid skill.", "Instructions."),
new AgentInlineSkill("another", "Another valid skill.", "More instructions."),
};
var source = new AgentInMemorySkillsSource(skills);
// Act
var result = await source.GetSkillsAsync(CancellationToken.None);
// Assert
Assert.Equal(2, result.Count);
Assert.Equal("my-skill", result[0].Frontmatter.Name);
Assert.Equal("another", result[1].Frontmatter.Name);
}
[Theory]
[InlineData("INVALID-NAME")]
[InlineData("-leading")]
[InlineData("trailing-")]
public void Constructor_InvalidFrontmatter_ThrowsArgumentException(string invalidName)
{
// Act & Assert
Assert.Throws<ArgumentException>(() =>
new AgentInlineSkill(invalidName, "A skill.", "Instructions."));
}
[Fact]
public void Constructor_NullSkills_Throws()
{
// Act & Assert
Assert.Throws<ArgumentNullException>(() => new AgentInMemorySkillsSource(null!));
}
}