autogen/dotnet/test/Microsoft.AutoGen.Integration.Tests/InMemoryRuntimeIntegrationTests.cs
Ryan Sweet c1646f21c0
Rysweet 4676 remove iagentruntime - collapse into iagentworker (#4740)
* moves AgentId into Agent
* Renames AgentRuntime to AgentMessenger (more accurate name)
* Remove IAgentRuntime Interface
* changes constructor of Agent to take IAgentWorker instead of IAgentRuntime
2024-12-17 13:04:37 -08:00

44 lines
1.9 KiB
C#

// Copyright (c) Microsoft Corporation. All rights reserved.
// InMemoryRuntimeIntegrationTests.cs
using Xunit.Abstractions;
namespace Microsoft.AutoGen.Integration.Tests;
public class InMemoryRuntimeIntegrationTests(ITestOutputHelper testOutput)
{
[Theory, Trait("type", "integration")]
[MemberData(nameof(AppHostAssemblies))]
public async Task HelloAgentsE2EInMemory(string appHostAssemblyPath)
{
var appHost = await DistributedApplicationTestFactory.CreateAsync(appHostAssemblyPath, testOutput);
await using var app = await appHost.BuildAsync().WaitAsync(TimeSpan.FromSeconds(15));
await app.StartAsync().WaitAsync(TimeSpan.FromSeconds(120));
await app.WaitForResourcesAsync().WaitAsync(TimeSpan.FromSeconds(120));
await app.StartAsync().WaitAsync(TimeSpan.FromSeconds(120));
await app.WaitForResourcesAsync().WaitAsync(TimeSpan.FromSeconds(120));
//sleep 5 seconds to make sure the app is running
await Task.Delay(15000);
app.EnsureNoErrorsLogged();
app.EnsureLogContains("Hello World");
app.EnsureLogContains("HelloAgent said Goodbye");
await app.StopAsync().WaitAsync(TimeSpan.FromSeconds(15));
}
public static TheoryData<string> AppHostAssemblies()
{
var appHostAssemblies = GetSamplesAppHostAssemblyPaths();
var theoryData = new TheoryData<string, bool>();
return new(appHostAssemblies.Select(p => Path.GetRelativePath(AppContext.BaseDirectory, p)));
}
private static IEnumerable<string> GetSamplesAppHostAssemblyPaths()
{
// All the AppHost projects are referenced by this project so we can find them by looking for all their assemblies in the base directory
return Directory.GetFiles(AppContext.BaseDirectory, "HelloAgent.AppHost.dll")
.Where(fileName => !fileName.EndsWith("Aspire.Hosting.AppHost.dll", StringComparison.OrdinalIgnoreCase));
}
}