Co-authored-by: Tarek Mahmoud Sayed <tarekms@microsoft.com> Co-authored-by: Tarek Mahmoud Sayed <tarekms@ntdev.microsoft.com> Co-authored-by: Tarek Mahmoud Sayed <10833894+tarekgh@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
59 lines
1.5 KiB
C#
59 lines
1.5 KiB
C#
using ModelContextProtocol.Server;
|
|
|
|
namespace ModelContextProtocol.Tests.Server;
|
|
|
|
public class McpHeaderAttributeTests
|
|
{
|
|
[Theory]
|
|
[InlineData("Region")]
|
|
[InlineData("TenantId")]
|
|
[InlineData("Priority")]
|
|
[InlineData("X-Custom")]
|
|
public void Constructor_ValidHeaderName_Succeeds(string name)
|
|
{
|
|
var attr = new McpHeaderAttribute(name);
|
|
Assert.Equal(name, attr.Name);
|
|
}
|
|
|
|
[Fact]
|
|
public void Constructor_NameWithSpace_Throws()
|
|
{
|
|
Assert.Throws<ArgumentException>(() => new McpHeaderAttribute("My Region"));
|
|
}
|
|
|
|
[Fact]
|
|
public void Constructor_NameWithColon_Throws()
|
|
{
|
|
Assert.Throws<ArgumentException>(() => new McpHeaderAttribute("Region:Primary"));
|
|
}
|
|
|
|
[Fact]
|
|
public void Constructor_NullName_Throws()
|
|
{
|
|
Assert.ThrowsAny<ArgumentException>(() => new McpHeaderAttribute(null!));
|
|
}
|
|
|
|
[Fact]
|
|
public void Constructor_EmptyName_Throws()
|
|
{
|
|
Assert.ThrowsAny<ArgumentException>(() => new McpHeaderAttribute(""));
|
|
}
|
|
|
|
[Fact]
|
|
public void Constructor_WhitespaceName_Throws()
|
|
{
|
|
Assert.ThrowsAny<ArgumentException>(() => new McpHeaderAttribute(" "));
|
|
}
|
|
|
|
[Fact]
|
|
public void Constructor_NameWithControlCharacter_Throws()
|
|
{
|
|
Assert.Throws<ArgumentException>(() => new McpHeaderAttribute("Region\t1"));
|
|
}
|
|
|
|
[Fact]
|
|
public void Constructor_NameWithNonAscii_Throws()
|
|
{
|
|
Assert.Throws<ArgumentException>(() => new McpHeaderAttribute("Région"));
|
|
}
|
|
}
|