2024-12-11 12:59:02 -08:00
|
|
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
|
|
// InMemoryRuntimeIntegrationTests.cs
|
|
|
|
using Xunit.Abstractions;
|
|
|
|
|
|
|
|
namespace Microsoft.AutoGen.Integration.Tests;
|
|
|
|
|
|
|
|
public class InMemoryRuntimeIntegrationTests(ITestOutputHelper testOutput)
|
|
|
|
{
|
2025-02-13 16:43:57 -08:00
|
|
|
[Fact]
|
|
|
|
public async Task HelloAgentsE2EInMemory()
|
2024-12-11 12:59:02 -08:00
|
|
|
{
|
2025-02-13 16:43:57 -08:00
|
|
|
// Locate InMemoryTests.AppHost.dll in the test output folder
|
|
|
|
var appHostAssemblyPath = Directory.GetFiles(AppContext.BaseDirectory, "InMemoryTests.AppHost.dll", SearchOption.AllDirectories)
|
|
|
|
.FirstOrDefault()
|
|
|
|
?? throw new FileNotFoundException("Could not find InMemoryTests.AppHost.dll in the test output folder");
|
2024-12-11 12:59:02 -08:00
|
|
|
var appHost = await DistributedApplicationTestFactory.CreateAsync(appHostAssemblyPath, testOutput);
|
|
|
|
await using var app = await appHost.BuildAsync().WaitAsync(TimeSpan.FromSeconds(15));
|
|
|
|
|
2025-02-13 16:43:57 -08:00
|
|
|
// Start the application and wait for resources
|
2024-12-11 12:59:02 -08:00
|
|
|
await app.StartAsync().WaitAsync(TimeSpan.FromSeconds(120));
|
|
|
|
await app.WaitForResourcesAsync().WaitAsync(TimeSpan.FromSeconds(120));
|
|
|
|
|
2025-02-13 16:43:57 -08:00
|
|
|
// Sleep 5 seconds to ensure the app is up
|
|
|
|
await Task.Delay(5000);
|
2024-12-11 12:59:02 -08:00
|
|
|
app.EnsureNoErrorsLogged();
|
|
|
|
app.EnsureLogContains("Hello World");
|
2024-12-17 13:04:37 -08:00
|
|
|
app.EnsureLogContains("HelloAgent said Goodbye");
|
2024-12-11 12:59:02 -08:00
|
|
|
|
|
|
|
await app.StopAsync().WaitAsync(TimeSpan.FromSeconds(15));
|
|
|
|
}
|
|
|
|
}
|