using System.Collections.Generic;

using AIRuntime.Runtime.Agents;
using AIRuntime.Runtime.Agents.Permissions;
using AIRuntime.Runtime.Agents.Runtime;
using AIRuntime.Runtime.Capabilities;

using Newtonsoft.Json.Linq;

using NUnit.Framework;


namespace AIRuntime.Tests
{
    public sealed class AgentCapabilityResolverTests
    {
        [Test]
        public void Resolver_ReturnsOnlyAgentCapabilities()
        {
            AgentDefinition agent =
                new AgentDefinition(
                    "ArchitectAgent",
                    "Architect",
                    "",
                    "");


            agent.AllowCapability(
                "project.inspect");


            AgentSession session =
                new AgentSession(
                    agent);


            AgentRuntimeContext context =
                new AgentRuntimeContext(
                    new AgentExecutionContext(
                        session),
                    new List<CapabilityDescriptor>());


            List<CapabilityDescriptor> available =
                new List<CapabilityDescriptor>
                {
                    new CapabilityDescriptor(
                        "project.inspect",
                        "",
                        new JObject()),

                    new CapabilityDescriptor(
                        "file.delete",
                        "",
                        new JObject())
                };


            AgentCapabilityResolver resolver =
                new AgentCapabilityResolver();


            IReadOnlyList<CapabilityDescriptor> result =
                resolver.Resolve(
                    context,
                    available);


            Assert.AreEqual(
                1,
                result.Count);


            Assert.AreEqual(
                "project.inspect",
                result[0].Name);
        }
    }
}
