Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: dotnet AgentId and MetaData tests #5271

Merged
merged 7 commits into from
Jan 30, 2025
Merged
Changes from 1 commit
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
Next Next commit
feat: dotnet AgentId tests
bassmang committed Jan 30, 2025
commit b908d1d99aa724185f0b33c4fea7077a7040f18f
62 changes: 62 additions & 0 deletions dotnet/test/Microsoft.AutoGen.Core.Tests/AgentIdTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// AgentIdTests.cs
using FluentAssertions;
using Microsoft.AutoGen.Contracts;
using Xunit;

namespace Microsoft.AutoGen.Core.Tests;

public class AgentIdTests()
{
[Fact]
public void AgentIdShouldInitializeCorrectlyTest()
{
var agentId = new AgentId("TestType", "TestKey");

agentId.Type.Should().Be("TestType");
agentId.Key.Should().Be("TestKey");
}

[Fact]
public void AgentIdShouldConvertFromTupleTest()
{
var agentTuple = ("TupleType", "TupleKey");
var agentId = new AgentId(agentTuple);

agentId.Type.Should().Be("TupleType");
agentId.Key.Should().Be("TupleKey");
}

[Fact]
public void AgentIdShouldParseFromStringTest()
{
var agentId = AgentId.FromStr("ParsedType/ParsedKey");

agentId.Type.Should().Be("ParsedType");
agentId.Key.Should().Be("ParsedKey");
}

[Fact]
public void AgentIdShouldCompareEqualityCorrectlyTest()
{
var agentId1 = new AgentId("SameType", "SameKey");
var agentId2 = new AgentId("SameType", "SameKey");
var agentId3 = new AgentId("DifferentType", "DifferentKey");

agentId1.Should().Be(agentId2);
agentId1.Should().NotBe(agentId3);
(agentId1 == agentId2).Should().BeTrue();
(agentId1 != agentId3).Should().BeTrue();
}

[Fact]
public void AgentIdShouldGenerateCorrectHashCodeTest()
{
var agentId1 = new AgentId("HashType", "HashKey");
var agentId2 = new AgentId("HashType", "HashKey");
var agentId3 = new AgentId("DifferentType", "DifferentKey");

agentId1.GetHashCode().Should().Be(agentId2.GetHashCode());
agentId1.GetHashCode().Should().NotBe(agentId3.GetHashCode());
}
}