You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

InMemoryRuntimeIntegrationTests.cs 2.0 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Copyright (c) Microsoft Corporation. All rights reserved.
  2. // InMemoryRuntimeIntegrationTests.cs
  3. using Xunit.Abstractions;
  4. namespace Microsoft.AutoGen.Integration.Tests;
  5. public class InMemoryRuntimeIntegrationTests(ITestOutputHelper testOutput)
  6. {
  7. [Theory, Trait("type", "integration")]
  8. [MemberData(nameof(AppHostAssemblies))]
  9. public async Task HelloAgentsE2EInMemory(string appHostAssemblyPath)
  10. {
  11. var appHost = await DistributedApplicationTestFactory.CreateAsync(appHostAssemblyPath, testOutput);
  12. await using var app = await appHost.BuildAsync().WaitAsync(TimeSpan.FromSeconds(15));
  13. await app.StartAsync().WaitAsync(TimeSpan.FromSeconds(120));
  14. await app.WaitForResourcesAsync().WaitAsync(TimeSpan.FromSeconds(120));
  15. await app.StartAsync().WaitAsync(TimeSpan.FromSeconds(120));
  16. await app.WaitForResourcesAsync().WaitAsync(TimeSpan.FromSeconds(120));
  17. //sleep 5 seconds to make sure the app is running
  18. await Task.Delay(15000);
  19. app.EnsureNoErrorsLogged();
  20. app.EnsureLogContains("Hello World");
  21. app.EnsureLogContains("HelloAgent said Goodbye");
  22. await app.StopAsync().WaitAsync(TimeSpan.FromSeconds(15));
  23. }
  24. public static TheoryData<string> AppHostAssemblies()
  25. {
  26. var appHostAssemblies = GetSamplesAppHostAssemblyPaths();
  27. var theoryData = new TheoryData<string, bool>();
  28. return new(appHostAssemblies.Select(p => Path.GetRelativePath(AppContext.BaseDirectory, p)));
  29. }
  30. private static IEnumerable<string> GetSamplesAppHostAssemblyPaths()
  31. {
  32. // All the AppHost projects are referenced by this project so we can find them by looking for all their assemblies in the base directory
  33. return Directory.GetFiles(AppContext.BaseDirectory, "HelloAgent.AppHost.dll")
  34. .Where(fileName => !fileName.EndsWith("Aspire.Hosting.AppHost.dll", StringComparison.OrdinalIgnoreCase));
  35. }
  36. }