Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
<PackageVersion Include="Microsoft.CodeAnalysis.Common" Version="$(MicrosoftCodeAnalysisVersion)" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="$(MicrosoftCodeAnalysisVersion)" />
<PackageVersion Include="Microsoft.Diagnostics.NETCore.Client" Version="0.2.607501" />
<PackageVersion Include="Microsoft.Extensions.AI" Version="9.10.0" />
<PackageVersion Include="Microsoft.Extensions.AI.OpenAI" Version="9.10.0-preview.1.25513.3" />
<PackageVersion Include="Azure.AI.OpenAI" Version="2.1.0" />
<PackageVersion Include="Microsoft.Testing.Extensions.CodeCoverage" Version="$(MicrosoftTestingExtensionsCodeCoverageVersion)" />
<PackageVersion Include="Microsoft.TestPlatform.AdapterUtilities" Version="$(MicrosoftNETTestSdkVersion)" />
<PackageVersion Include="Microsoft.TestPlatform.ObjectModel" Version="$(MicrosoftNETTestSdkVersion)" />
Expand Down
26 changes: 14 additions & 12 deletions TestFx.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<File Path="global.json" />
<File Path="Nuget.config" />
</Folder>
<Folder Name="/Solution Items/eng/" Id="5450f9c7-f297-9839-c636-5c9c04a5ba28">
<Folder Name="/Solution Items/eng/">
<File Path="eng/AfterSolutionBuild.targets" />
<File Path="eng/Analyzers.props" />
<File Path="eng/Build.props" />
Expand All @@ -23,16 +23,17 @@
<File Path="eng/Versions.props" />
<File Path="eng/write-release-notes.ps1" />
</Folder>
<Folder Name="/Solution Items/eng/TestingPlatformRunner/" Id="a7b54d83-9a9c-527b-00f3-bda998e116c9">
<Folder Name="/Solution Items/eng/TestingPlatformRunner/">
<File Path="eng/TestingPlatformRunner/TestingPlatform.Runner.targets" />
<File Path="eng/TestingPlatformRunner/TestingPlatformRunner.targets" />
</Folder>
<Folder Name="/src/">
<File Path="src/.editorconfig" />
<File Path="src/Directory.Build.props" />
</Folder>
<Folder Name="/src/1 - Platform and Extensions/" Id="4272bbd9-efdb-ae85-3883-a1ab2fbd20bd">
<Folder Name="/src/1 - Platform and Extensions/">
<File Path="src/Platform/Directory.Build.props" />
<Project Path="src/Platform/Microsoft.Testing.Extensions.AzFoundry/Microsoft.Testing.Extensions.AzFoundry.csproj" Id="60c660b9-6d0c-4967-b21c-e1c34257cc75" />
<Project Path="src/Platform/Microsoft.Testing.Extensions.AzureDevOpsReport/Microsoft.Testing.Extensions.AzureDevOpsReport.csproj" />
<Project Path="src/Platform/Microsoft.Testing.Extensions.CrashDump/Microsoft.Testing.Extensions.CrashDump.csproj" />
<Project Path="src/Platform/Microsoft.Testing.Extensions.HangDump/Microsoft.Testing.Extensions.HangDump.csproj" />
Expand All @@ -43,19 +44,20 @@
<Project Path="src/Platform/Microsoft.Testing.Extensions.TrxReport.Abstractions/Microsoft.Testing.Extensions.TrxReport.Abstractions.csproj" />
<Project Path="src/Platform/Microsoft.Testing.Extensions.TrxReport/Microsoft.Testing.Extensions.TrxReport.csproj" />
<Project Path="src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Microsoft.Testing.Extensions.VSTestBridge.csproj" />
<Project Path="src/Platform/Microsoft.Testing.Platform.AI/Microsoft.Testing.Platform.AI.csproj" Id="53db5319-243a-4b47-91f1-9b450b4f2917" />
<Project Path="src/Platform/Microsoft.Testing.Platform.MSBuild/Microsoft.Testing.Platform.MSBuild.csproj" />
<Project Path="src/Platform/Microsoft.Testing.Platform/Microsoft.Testing.Platform.csproj" />
</Folder>
<Folder Name="/src/2 - Adapter/" Id="f7cf448e-306d-5d9b-7166-fa7205a8989c">
<Folder Name="/src/2 - Adapter/">
<Project Path="src/Adapter/MSTest.Engine/MSTest.Engine.csproj" />
<Project Path="src/Adapter/MSTest.TestAdapter/MSTest.TestAdapter.csproj" />
<Project Path="src/Adapter/MSTestAdapter.PlatformServices/MSTestAdapter.PlatformServices.csproj" />
</Folder>
<Folder Name="/src/3 - TestFramework/" Id="f28cc185-255f-b581-6ed3-c247f7096eb1">
<Folder Name="/src/3 - TestFramework/">
<Project Path="src/TestFramework/TestFramework.Extensions/TestFramework.Extensions.csproj" />
<Project Path="src/TestFramework/TestFramework/TestFramework.csproj" />
</Folder>
<Folder Name="/src/4 - Analyzers/" Id="9c73ee5c-ce16-2586-eb05-df3b4306d351">
<Folder Name="/src/4 - Analyzers/">
<Project Path="src/Analyzers/MSTest.Analyzers.CodeFixes/MSTest.Analyzers.CodeFixes.csproj" />
<Project Path="src/Analyzers/MSTest.Analyzers.Package/MSTest.Analyzers.Package.csproj">
<BuildDependency Project="src/Analyzers/MSTest.GlobalConfigsGenerator/MSTest.GlobalConfigsGenerator.csproj" />
Expand All @@ -64,7 +66,7 @@
<Project Path="src/Analyzers/MSTest.GlobalConfigsGenerator/MSTest.GlobalConfigsGenerator.csproj" />
<Project Path="src/Analyzers/MSTest.SourceGeneration/MSTest.SourceGeneration.csproj" />
</Folder>
<Folder Name="/src/5 - Package/" Id="87d92690-a0c0-3299-b302-eb18ebf7ffb3">
<Folder Name="/src/5 - Package/">
<Project Path="src/Package/MSTest.Sdk/MSTest.Sdk.csproj" />
<Project Path="src/Package/MSTest/MSTest.csproj" />
</Folder>
Expand All @@ -73,14 +75,14 @@
<File Path="test/Directory.Build.props" />
<File Path="test/Directory.Build.targets" />
</Folder>
<Folder Name="/test/IntegrationTests/" Id="334eb2cc-8f21-7cba-1333-4c64d82c9f9a">
<Folder Name="/test/IntegrationTests/">
<Project Path="test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests.csproj" />
<Project Path="test/IntegrationTests/MSTest.Acceptance.IntegrationTests/MSTest.Acceptance.IntegrationTests.csproj" />
<Project Path="test/IntegrationTests/MSTest.IntegrationTests/MSTest.IntegrationTests.csproj" />
<Project Path="test/IntegrationTests/MSTest.VstestConsoleWrapper.IntegrationTests/MSTest.VstestConsoleWrapper.IntegrationTests.csproj" />
<Project Path="test/IntegrationTests/PlatformServices.Desktop.IntegrationTests/PlatformServices.Desktop.IntegrationTests.csproj" />
</Folder>
<Folder Name="/test/IntegrationTests/TestAssets/" Id="05959510-e531-ecb6-7089-da3b202e43db">
<Folder Name="/test/IntegrationTests/TestAssets/">
<File Path="test/IntegrationTests/TestAssets/Directory.Build.targets" />
<Project Path="test/IntegrationTests/TestAssets/ClsTestProject/ClsTestProject.csproj" />
<Project Path="test/IntegrationTests/TestAssets/DataRowTestProject/DataRowTestProject.csproj" />
Expand Down Expand Up @@ -110,15 +112,15 @@
<Project Path="test/IntegrationTests/TestAssets/TestProject/TestProjectForDiscovery.csproj" />
<Project Path="test/IntegrationTests/TestAssets/TimeoutTestProject/TimeoutTestProject.csproj" />
</Folder>
<Folder Name="/test/Performance/" Id="5e428a24-a249-2472-0469-8a6e9a79c114">
<Folder Name="/test/Performance/">
<Project Path="test/Performance/MSTest.Performance.Runner/MSTest.Performance.Runner.csproj" />
</Folder>
<Folder Name="/test/TestUtilities/" Id="f47f7890-75b5-78d9-9d83-447eee1edf9f">
<Folder Name="/test/TestUtilities/">
<Project Path="test/Utilities/Automation.CLI/Automation.CLI.csproj" />
<Project Path="test/Utilities/Microsoft.Testing.TestInfrastructure/Microsoft.Testing.TestInfrastructure.csproj" />
<Project Path="test/Utilities/TestFramework.ForTestingMSTest/TestFramework.ForTestingMSTest.csproj" />
</Folder>
<Folder Name="/test/UnitTests/" Id="afae3f01-5c40-22b5-606d-a848a5891b0a">
<Folder Name="/test/UnitTests/">
<Project Path="test/UnitTests/Microsoft.Testing.Extensions.UnitTests/Microsoft.Testing.Extensions.UnitTests.csproj" />
<Project Path="test/UnitTests/Microsoft.Testing.Extensions.VSTestBridge.UnitTests/Microsoft.Testing.Extensions.VSTestBridge.UnitTests.csproj" />
<Project Path="test/UnitTests/Microsoft.Testing.Platform.MSBuild.UnitTests/Microsoft.Testing.Platform.MSBuild.UnitTests.csproj" />
Expand Down
2 changes: 2 additions & 0 deletions samples/Playground/Playground.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

<ItemGroup>
<ProjectReference Include="$(RepoRoot)src\Platform\Microsoft.Testing.Platform\Microsoft.Testing.Platform.csproj" />
<ProjectReference Include="$(RepoRoot)src\Platform\Microsoft.Testing.Platform.AI\Microsoft.Testing.Platform.AI.csproj" />
<ProjectReference Include="$(RepoRoot)src\Platform\Microsoft.Testing.Extensions.AzFoundry\Microsoft.Testing.Extensions.AzFoundry.csproj" />
<ProjectReference Include="$(RepoRoot)src\Adapter\MSTest.TestAdapter\MSTest.TestAdapter.csproj" />
<ProjectReference Include="$(RepoRoot)src\Analyzers\MSTest.Analyzers.CodeFixes\MSTest.Analyzers.CodeFixes.csproj" PrivateAssets="all" ReferenceOutputAssembly="false" OutputItemType="Analyzer" />
<ProjectReference Include="$(RepoRoot)src\Analyzers\MSTest.Analyzers\MSTest.Analyzers.csproj" PrivateAssets="all" ReferenceOutputAssembly="false" OutputItemType="Analyzer" />
Expand Down
24 changes: 21 additions & 3 deletions samples/Playground/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,15 @@
using Microsoft.Testing.Platform.Messages;
#if NETCOREAPP
using Microsoft.Testing.Platform.ServerMode.IntegrationTests.Messages.V100;

using MSTest.Acceptance.IntegrationTests.Messages.V100;

#endif
using Microsoft.Extensions.AI;
using Microsoft.Testing.Extensions.AzFoundry;
using Microsoft.Testing.Platform.AI;
using Microsoft.Testing.Platform.Capabilities.TestFramework;
using Microsoft.Testing.Platform.TestHost;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Playground;

Expand All @@ -32,10 +37,13 @@ public static async Task<int> Main(string[] args)
ITestApplicationBuilder testApplicationBuilder = await TestApplication.CreateBuilderAsync(args);

// Test MSTest
testApplicationBuilder.AddMSTest(() => [Assembly.GetEntryAssembly()!]);
// testApplicationBuilder.AddMSTest(() => [Assembly.GetEntryAssembly()!]);

// Add Chat client factory
testApplicationBuilder.AddChatClientFactory(_ => new AzureOpenAIChatClientFactory());

// Test a custom local test framework
// testApplicationBuilder.RegisterTestFramework(_ => new TestFrameworkCapabilities(), (_, _) => new DummyAdapter());
testApplicationBuilder.RegisterTestFramework(_ => new TestFrameworkCapabilities(), (_, s) => new DummyAdapter(s));

// Custom test host controller extension
// testApplicationBuilder.TestHostControllers.AddProcessLifetimeHandler(s => new OutOfProc(s.GetMessageBus()));
Expand Down Expand Up @@ -78,6 +86,10 @@ public static async Task<int> Main(string[] args)

internal sealed class DummyAdapter : ITestFramework, IDataProducer
{
private readonly IServiceProvider _serviceProvider;

public DummyAdapter(IServiceProvider serviceProvider) => _serviceProvider = serviceProvider;

public string Uid => nameof(DummyAdapter);

public string Version => string.Empty;
Expand All @@ -96,6 +108,12 @@ public async Task ExecuteRequestAsync(ExecuteRequestContext context)
{
try
{
using IChatClient? chatClient = _serviceProvider.GetChatClient();
if (chatClient != null)
{
ChatResponse response = await chatClient.GetResponseAsync(chatMessage: "Hello, world!", cancellationToken: context.CancellationToken);
}

MyService.DoSomething();
}
catch (Exception e)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;$(SupportedNetFrameworks)</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.AI.OpenAI" />
<PackageReference Include="Microsoft.Extensions.AI.OpenAI" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="$(RepoRoot)src\Platform\Microsoft.Testing.Platform.AI\Microsoft.Testing.Platform.AI.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System.ClientModel;

using Azure.AI.OpenAI;

using Microsoft.Extensions.AI;
using Microsoft.Testing.Extensions.AzFoundry.Resources;
using Microsoft.Testing.Platform.AI;

namespace Microsoft.Testing.Extensions.AzFoundry;

/// <summary>
/// Factory for creating Azure OpenAI chat clients.
/// </summary>
public sealed class AzureOpenAIChatClientFactory : IChatClientFactory
{
/// <inheritdoc />
public IChatClient CreateChatClient()
{
string? endpoint = Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT");
string? deploymentName = Environment.GetEnvironmentVariable("AZURE_OPENAI_DEPLOYMENT_NAME");
string? apiKey = Environment.GetEnvironmentVariable("AZURE_OPENAI_API_KEY");

if (string.IsNullOrEmpty(endpoint))
{
throw new InvalidOperationException(ExtensionResources.AzureOpenAIEndpointNotSet);
}

if (string.IsNullOrEmpty(deploymentName))
{
throw new InvalidOperationException(ExtensionResources.AzureOpenAIDeploymentNameNotSet);
}

if (string.IsNullOrEmpty(apiKey))
{
throw new InvalidOperationException(ExtensionResources.AzureOpenAIApiKeyNotSet);
}

var client = new AzureOpenAIClient(
new Uri(endpoint),
new ApiKeyCredential(apiKey));

return client.GetChatClient(deploymentName).AsIChatClient();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema

Version 2.0

The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.

Example:

... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>

There are any number of "resheader" rows that contain simple
name/value pairs.

Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.

The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:

Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.

mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.

mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.

mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="AzureOpenAIEndpointNotSet" xml:space="preserve">
<value>AZURE_OPENAI_ENDPOINT environment variable is not set.</value>
</data>
<data name="AzureOpenAIDeploymentNameNotSet" xml:space="preserve">
<value>AZURE_OPENAI_DEPLOYMENT_NAME environment variable is not set.</value>
</data>
<data name="AzureOpenAIApiKeyNotSet" xml:space="preserve">
<value>AZURE_OPENAI_API_KEY environment variable is not set.</value>
</data>
</root>
Loading
Loading