diff --git a/dotnet/tests/AnthropicChatCompletion.IntegrationTests/AnthropicChatCompletionChatClientAgentRunStreamingTests.cs b/dotnet/tests/AnthropicChatCompletion.IntegrationTests/AnthropicChatCompletionChatClientAgentRunStreamingTests.cs index 4a95ace16e..86b07a30f9 100644 --- a/dotnet/tests/AnthropicChatCompletion.IntegrationTests/AnthropicChatCompletionChatClientAgentRunStreamingTests.cs +++ b/dotnet/tests/AnthropicChatCompletion.IntegrationTests/AnthropicChatCompletionChatClientAgentRunStreamingTests.cs @@ -1,30 +1,13 @@ // Copyright (c) Microsoft. All rights reserved. -using System; -using System.Threading.Tasks; using AgentConformance.IntegrationTests; namespace AnthropicChatCompletion.IntegrationTests; -public abstract class SkipAllChatClientRunStreaming(Func func) : ChatClientAgentRunStreamingTests(func) -{ - public override Task RunWithFunctionsInvokesFunctionsAndReturnsExpectedResultsAsync() - { - Assert.SkipWhen(AnthropicChatCompletionFixture.SkipReason is not null, AnthropicChatCompletionFixture.SkipReason!); - return base.RunWithFunctionsInvokesFunctionsAndReturnsExpectedResultsAsync(); - } +public class AnthropicBetaChatCompletionChatClientAgentReasoningRunStreamingTests() : ChatClientAgentRunStreamingTests(() => new(useReasoningChatModel: true, useBeta: true)); - public override Task RunWithInstructionsAndNoMessageReturnsExpectedResultAsync() - { - Assert.SkipWhen(AnthropicChatCompletionFixture.SkipReason is not null, AnthropicChatCompletionFixture.SkipReason!); - return base.RunWithInstructionsAndNoMessageReturnsExpectedResultAsync(); - } -} +public class AnthropicBetaChatCompletionChatClientAgentRunStreamingTests() : ChatClientAgentRunStreamingTests(() => new(useReasoningChatModel: false, useBeta: true)); -public class AnthropicBetaChatCompletionChatClientAgentReasoningRunStreamingTests() : SkipAllChatClientRunStreaming(() => new(useReasoningChatModel: true, useBeta: true)); +public class AnthropicChatCompletionChatClientAgentRunStreamingTests() : ChatClientAgentRunStreamingTests(() => new(useReasoningChatModel: false, useBeta: false)); -public class AnthropicBetaChatCompletionChatClientAgentRunStreamingTests() : SkipAllChatClientRunStreaming(() => new(useReasoningChatModel: false, useBeta: true)); - -public class AnthropicChatCompletionChatClientAgentRunStreamingTests() : SkipAllChatClientRunStreaming(() => new(useReasoningChatModel: false, useBeta: false)); - -public class AnthropicChatCompletionChatClientAgentReasoningRunStreamingTests() : SkipAllChatClientRunStreaming(() => new(useReasoningChatModel: true, useBeta: false)); +public class AnthropicChatCompletionChatClientAgentReasoningRunStreamingTests() : ChatClientAgentRunStreamingTests(() => new(useReasoningChatModel: true, useBeta: false)); diff --git a/dotnet/tests/AnthropicChatCompletion.IntegrationTests/AnthropicChatCompletionChatClientAgentRunTests.cs b/dotnet/tests/AnthropicChatCompletion.IntegrationTests/AnthropicChatCompletionChatClientAgentRunTests.cs index 98ff9b6448..db150a2605 100644 --- a/dotnet/tests/AnthropicChatCompletion.IntegrationTests/AnthropicChatCompletionChatClientAgentRunTests.cs +++ b/dotnet/tests/AnthropicChatCompletion.IntegrationTests/AnthropicChatCompletionChatClientAgentRunTests.cs @@ -1,34 +1,17 @@ // Copyright (c) Microsoft. All rights reserved. -using System; -using System.Threading.Tasks; using AgentConformance.IntegrationTests; namespace AnthropicChatCompletion.IntegrationTests; -public abstract class SkipAllChatClientAgentRun(Func func) : ChatClientAgentRunTests(func) -{ - public override Task RunWithFunctionsInvokesFunctionsAndReturnsExpectedResultsAsync() - { - Assert.SkipWhen(AnthropicChatCompletionFixture.SkipReason is not null, AnthropicChatCompletionFixture.SkipReason!); - return base.RunWithFunctionsInvokesFunctionsAndReturnsExpectedResultsAsync(); - } - - public override Task RunWithInstructionsAndNoMessageReturnsExpectedResultAsync() - { - Assert.SkipWhen(AnthropicChatCompletionFixture.SkipReason is not null, AnthropicChatCompletionFixture.SkipReason!); - return base.RunWithInstructionsAndNoMessageReturnsExpectedResultAsync(); - } -} - public class AnthropicBetaChatCompletionChatClientAgentRunTests() - : SkipAllChatClientAgentRun(() => new(useReasoningChatModel: false, useBeta: true)); + : ChatClientAgentRunTests(() => new(useReasoningChatModel: false, useBeta: true)); public class AnthropicBetaChatCompletionChatClientAgentReasoningRunTests() - : SkipAllChatClientAgentRun(() => new(useReasoningChatModel: true, useBeta: true)); + : ChatClientAgentRunTests(() => new(useReasoningChatModel: true, useBeta: true)); public class AnthropicChatCompletionChatClientAgentRunTests() - : SkipAllChatClientAgentRun(() => new(useReasoningChatModel: false, useBeta: false)); + : ChatClientAgentRunTests(() => new(useReasoningChatModel: false, useBeta: false)); public class AnthropicChatCompletionChatClientAgentReasoningRunTests() - : SkipAllChatClientAgentRun(() => new(useReasoningChatModel: true, useBeta: false)); + : ChatClientAgentRunTests(() => new(useReasoningChatModel: true, useBeta: false)); diff --git a/dotnet/tests/AnthropicChatCompletion.IntegrationTests/AnthropicChatCompletionFixture.cs b/dotnet/tests/AnthropicChatCompletion.IntegrationTests/AnthropicChatCompletionFixture.cs index 8048d86dee..4cf232f7d8 100644 --- a/dotnet/tests/AnthropicChatCompletion.IntegrationTests/AnthropicChatCompletionFixture.cs +++ b/dotnet/tests/AnthropicChatCompletion.IntegrationTests/AnthropicChatCompletionFixture.cs @@ -20,7 +20,6 @@ public class AnthropicChatCompletionFixture : IChatClientAgentFixture // All tests for Anthropic are intended to be ran locally as the CI pipeline for Anthropic is not setup. internal const string SkipReason = "Integrations tests for local execution only"; - private static readonly AnthropicConfiguration s_config = TestConfiguration.LoadSection(); private readonly bool _useReasoningModel; private readonly bool _useBeta; @@ -53,7 +52,8 @@ public Task CreateChatClientAgentAsync( string instructions = "You are a helpful assistant.", IList? aiTools = null) { - var anthropicClient = new AnthropicClient() { ApiKey = s_config.ApiKey }; + AnthropicConfiguration config = TestConfiguration.LoadSection(); + var anthropicClient = new AnthropicClient() { ApiKey = config.ApiKey }; IChatClient? chatClient = this._useBeta ? anthropicClient @@ -64,7 +64,7 @@ public Task CreateChatClientAgentAsync( => options.RawRepresentationFactory = _ => new Anthropic.Models.Beta.Messages.MessageCreateParams() { - Model = options.ModelId ?? (this._useReasoningModel ? s_config.ChatReasoningModelId : s_config.ChatModelId), + Model = options.ModelId ?? (this._useReasoningModel ? config.ChatReasoningModelId : config.ChatModelId), MaxTokens = options.MaxOutputTokens ?? 4096, Messages = [], Thinking = this._useReasoningModel @@ -79,7 +79,7 @@ public Task CreateChatClientAgentAsync( => options.RawRepresentationFactory = _ => new Anthropic.Models.Messages.MessageCreateParams() { - Model = options.ModelId ?? (this._useReasoningModel ? s_config.ChatReasoningModelId : s_config.ChatModelId), + Model = options.ModelId ?? (this._useReasoningModel ? config.ChatReasoningModelId : config.ChatModelId), MaxTokens = options.MaxOutputTokens ?? 4096, Messages = [], Thinking = this._useReasoningModel @@ -102,8 +102,11 @@ public Task DeleteSessionAsync(AgentSession session) => // Chat Completion does not require/support deleting sessions, so this is a no-op. Task.CompletedTask; - public async ValueTask InitializeAsync() => + public async ValueTask InitializeAsync() + { + Assert.SkipWhen(SkipReason is not null, SkipReason ?? string.Empty); this._agent = await this.CreateChatClientAgentAsync(); + } public ValueTask DisposeAsync() { diff --git a/dotnet/tests/AnthropicChatCompletion.IntegrationTests/AnthropicChatCompletionRunStreamingTests.cs b/dotnet/tests/AnthropicChatCompletion.IntegrationTests/AnthropicChatCompletionRunStreamingTests.cs index 7bc187f03f..ee39281ba6 100644 --- a/dotnet/tests/AnthropicChatCompletion.IntegrationTests/AnthropicChatCompletionRunStreamingTests.cs +++ b/dotnet/tests/AnthropicChatCompletion.IntegrationTests/AnthropicChatCompletionRunStreamingTests.cs @@ -1,52 +1,17 @@ // Copyright (c) Microsoft. All rights reserved. -using System; -using System.Threading.Tasks; using AgentConformance.IntegrationTests; namespace AnthropicChatCompletion.IntegrationTests; -public abstract class SkipAllRunStreaming(Func func) : RunStreamingTests(func) -{ - public override Task RunWithChatMessageReturnsExpectedResultAsync() - { - Assert.SkipWhen(AnthropicChatCompletionFixture.SkipReason is not null, AnthropicChatCompletionFixture.SkipReason!); - return base.RunWithChatMessageReturnsExpectedResultAsync(); - } - - public override Task RunWithNoMessageDoesNotFailAsync() - { - Assert.SkipWhen(AnthropicChatCompletionFixture.SkipReason is not null, AnthropicChatCompletionFixture.SkipReason!); - return base.RunWithNoMessageDoesNotFailAsync(); - } - - public override Task RunWithChatMessagesReturnsExpectedResultAsync() - { - Assert.SkipWhen(AnthropicChatCompletionFixture.SkipReason is not null, AnthropicChatCompletionFixture.SkipReason!); - return base.RunWithChatMessagesReturnsExpectedResultAsync(); - } - - public override Task RunWithStringReturnsExpectedResultAsync() - { - Assert.SkipWhen(AnthropicChatCompletionFixture.SkipReason is not null, AnthropicChatCompletionFixture.SkipReason!); - return base.RunWithStringReturnsExpectedResultAsync(); - } - - public override Task SessionMaintainsHistoryAsync() - { - Assert.SkipWhen(AnthropicChatCompletionFixture.SkipReason is not null, AnthropicChatCompletionFixture.SkipReason!); - return base.SessionMaintainsHistoryAsync(); - } -} - public class AnthropicBetaChatCompletionRunStreamingTests() - : SkipAllRunStreaming(() => new(useReasoningChatModel: false, useBeta: true)); + : RunStreamingTests(() => new(useReasoningChatModel: false, useBeta: true)); public class AnthropicBetaChatCompletionReasoningRunStreamingTests() - : SkipAllRunStreaming(() => new(useReasoningChatModel: true, useBeta: true)); + : RunStreamingTests(() => new(useReasoningChatModel: true, useBeta: true)); public class AnthropicChatCompletionRunStreamingTests() - : SkipAllRunStreaming(() => new(useReasoningChatModel: false, useBeta: false)); + : RunStreamingTests(() => new(useReasoningChatModel: false, useBeta: false)); public class AnthropicChatCompletionReasoningRunStreamingTests() - : SkipAllRunStreaming(() => new(useReasoningChatModel: true, useBeta: false)); + : RunStreamingTests(() => new(useReasoningChatModel: true, useBeta: false)); diff --git a/dotnet/tests/AnthropicChatCompletion.IntegrationTests/AnthropicChatCompletionRunTests.cs b/dotnet/tests/AnthropicChatCompletion.IntegrationTests/AnthropicChatCompletionRunTests.cs index 6c664d65fc..6cf514e695 100644 --- a/dotnet/tests/AnthropicChatCompletion.IntegrationTests/AnthropicChatCompletionRunTests.cs +++ b/dotnet/tests/AnthropicChatCompletion.IntegrationTests/AnthropicChatCompletionRunTests.cs @@ -1,52 +1,17 @@ // Copyright (c) Microsoft. All rights reserved. -using System; -using System.Threading.Tasks; using AgentConformance.IntegrationTests; namespace AnthropicChatCompletion.IntegrationTests; -public abstract class SkipAllRun(Func func) : RunTests(func) -{ - public override Task RunWithChatMessageReturnsExpectedResultAsync() - { - Assert.SkipWhen(AnthropicChatCompletionFixture.SkipReason is not null, AnthropicChatCompletionFixture.SkipReason!); - return base.RunWithChatMessageReturnsExpectedResultAsync(); - } - - public override Task RunWithNoMessageDoesNotFailAsync() - { - Assert.SkipWhen(AnthropicChatCompletionFixture.SkipReason is not null, AnthropicChatCompletionFixture.SkipReason!); - return base.RunWithNoMessageDoesNotFailAsync(); - } - - public override Task RunWithChatMessagesReturnsExpectedResultAsync() - { - Assert.SkipWhen(AnthropicChatCompletionFixture.SkipReason is not null, AnthropicChatCompletionFixture.SkipReason!); - return base.RunWithChatMessagesReturnsExpectedResultAsync(); - } - - public override Task RunWithStringReturnsExpectedResultAsync() - { - Assert.SkipWhen(AnthropicChatCompletionFixture.SkipReason is not null, AnthropicChatCompletionFixture.SkipReason!); - return base.RunWithStringReturnsExpectedResultAsync(); - } - - public override Task SessionMaintainsHistoryAsync() - { - Assert.SkipWhen(AnthropicChatCompletionFixture.SkipReason is not null, AnthropicChatCompletionFixture.SkipReason!); - return base.SessionMaintainsHistoryAsync(); - } -} - public class AnthropicBetaChatCompletionRunTests() - : SkipAllRun(() => new(useReasoningChatModel: false, useBeta: true)); + : RunTests(() => new(useReasoningChatModel: false, useBeta: true)); public class AnthropicBetaChatCompletionReasoningRunTests() - : SkipAllRun(() => new(useReasoningChatModel: true, useBeta: true)); + : RunTests(() => new(useReasoningChatModel: true, useBeta: true)); public class AnthropicChatCompletionRunTests() - : SkipAllRun(() => new(useReasoningChatModel: false, useBeta: false)); + : RunTests(() => new(useReasoningChatModel: false, useBeta: false)); public class AnthropicChatCompletionReasoningRunTests() - : SkipAllRun(() => new(useReasoningChatModel: true, useBeta: false)); + : RunTests(() => new(useReasoningChatModel: true, useBeta: false)); diff --git a/dotnet/tests/AnthropicChatCompletion.IntegrationTests/AnthropicSkillsIntegrationTests.cs b/dotnet/tests/AnthropicChatCompletion.IntegrationTests/AnthropicSkillsIntegrationTests.cs index a6a96bd234..105793c709 100644 --- a/dotnet/tests/AnthropicChatCompletion.IntegrationTests/AnthropicSkillsIntegrationTests.cs +++ b/dotnet/tests/AnthropicChatCompletion.IntegrationTests/AnthropicSkillsIntegrationTests.cs @@ -22,14 +22,15 @@ public sealed class AnthropicSkillsIntegrationTests // All tests for Anthropic are intended to be ran locally as the CI pipeline for Anthropic is not setup. private const string SkipReason = "Integrations tests for local execution only"; - private static readonly AnthropicConfiguration s_config = TestConfiguration.LoadSection(); - - [Fact(Skip = SkipReason)] + [Fact] public async Task CreateAgentWithPptxSkillAsync() { + Assert.SkipWhen(SkipReason is not null, SkipReason ?? string.Empty); + // Arrange - AnthropicClient anthropicClient = new() { ApiKey = s_config.ApiKey }; - string model = s_config.ChatModelId; + AnthropicConfiguration config = TestConfiguration.LoadSection(); + AnthropicClient anthropicClient = new() { ApiKey = config.ApiKey }; + string model = config.ChatModelId; BetaSkillParams pptxSkill = new() { @@ -53,11 +54,14 @@ public async Task CreateAgentWithPptxSkillAsync() Assert.NotEmpty(response.Text); } - [Fact(Skip = SkipReason)] + [Fact] public async Task ListAnthropicManagedSkillsAsync() { + Assert.SkipWhen(SkipReason is not null, SkipReason ?? string.Empty); + // Arrange - AnthropicClient anthropicClient = new() { ApiKey = s_config.ApiKey }; + AnthropicConfiguration config = TestConfiguration.LoadSection(); + AnthropicClient anthropicClient = new() { ApiKey = config.ApiKey }; // Act SkillListPage skills = await anthropicClient.Beta.Skills.List( diff --git a/dotnet/tests/AzureAIAgentsPersistent.IntegrationTests/AzureAIAgentsPersistentStructuredOutputRunTests.cs b/dotnet/tests/AzureAIAgentsPersistent.IntegrationTests/AzureAIAgentsPersistentStructuredOutputRunTests.cs index 7aa6e3251d..0fa20f18ac 100644 --- a/dotnet/tests/AzureAIAgentsPersistent.IntegrationTests/AzureAIAgentsPersistentStructuredOutputRunTests.cs +++ b/dotnet/tests/AzureAIAgentsPersistent.IntegrationTests/AzureAIAgentsPersistentStructuredOutputRunTests.cs @@ -11,19 +11,19 @@ namespace AzureAIAgentsPersistent.IntegrationTests; public override Task RunWithResponseFormatReturnsExpectedResultAsync() { - Assert.SkipWhen(SkipReason is not null, SkipReason!); + Assert.SkipWhen(SkipReason is not null, SkipReason ?? string.Empty); return base.RunWithResponseFormatReturnsExpectedResultAsync(); } public override Task RunWithGenericTypeReturnsExpectedResultAsync() { - Assert.SkipWhen(SkipReason is not null, SkipReason!); + Assert.SkipWhen(SkipReason is not null, SkipReason ?? string.Empty); return base.RunWithGenericTypeReturnsExpectedResultAsync(); } public override Task RunWithPrimitiveTypeReturnsExpectedResultAsync() { - Assert.SkipWhen(SkipReason is not null, SkipReason!); + Assert.SkipWhen(SkipReason is not null, SkipReason ?? string.Empty); return base.RunWithPrimitiveTypeReturnsExpectedResultAsync(); } } diff --git a/dotnet/tests/CopilotStudio.IntegrationTests/CopilotStudioRunStreamingTests.cs b/dotnet/tests/CopilotStudio.IntegrationTests/CopilotStudioRunStreamingTests.cs index d583ddf563..cd482ee748 100644 --- a/dotnet/tests/CopilotStudio.IntegrationTests/CopilotStudioRunStreamingTests.cs +++ b/dotnet/tests/CopilotStudio.IntegrationTests/CopilotStudioRunStreamingTests.cs @@ -18,25 +18,25 @@ public override Task SessionMaintainsHistoryAsync() public override Task RunWithChatMessageReturnsExpectedResultAsync() { - Assert.SkipWhen(ManualVerification is not null, ManualVerification!); + Assert.SkipWhen(ManualVerification is not null, ManualVerification ?? string.Empty); return base.RunWithChatMessageReturnsExpectedResultAsync(); } public override Task RunWithChatMessagesReturnsExpectedResultAsync() { - Assert.SkipWhen(ManualVerification is not null, ManualVerification!); + Assert.SkipWhen(ManualVerification is not null, ManualVerification ?? string.Empty); return base.RunWithChatMessagesReturnsExpectedResultAsync(); } public override Task RunWithNoMessageDoesNotFailAsync() { - Assert.SkipWhen(ManualVerification is not null, ManualVerification!); + Assert.SkipWhen(ManualVerification is not null, ManualVerification ?? string.Empty); return base.RunWithNoMessageDoesNotFailAsync(); } public override Task RunWithStringReturnsExpectedResultAsync() { - Assert.SkipWhen(ManualVerification is not null, ManualVerification!); + Assert.SkipWhen(ManualVerification is not null, ManualVerification ?? string.Empty); return base.RunWithStringReturnsExpectedResultAsync(); } } diff --git a/dotnet/tests/CopilotStudio.IntegrationTests/CopilotStudioRunTests.cs b/dotnet/tests/CopilotStudio.IntegrationTests/CopilotStudioRunTests.cs index 612ccd27e7..b927b1bfc5 100644 --- a/dotnet/tests/CopilotStudio.IntegrationTests/CopilotStudioRunTests.cs +++ b/dotnet/tests/CopilotStudio.IntegrationTests/CopilotStudioRunTests.cs @@ -18,25 +18,25 @@ public override Task SessionMaintainsHistoryAsync() public override Task RunWithChatMessageReturnsExpectedResultAsync() { - Assert.SkipWhen(ManualVerification is not null, ManualVerification!); + Assert.SkipWhen(ManualVerification is not null, ManualVerification ?? string.Empty); return base.RunWithChatMessageReturnsExpectedResultAsync(); } public override Task RunWithChatMessagesReturnsExpectedResultAsync() { - Assert.SkipWhen(ManualVerification is not null, ManualVerification!); + Assert.SkipWhen(ManualVerification is not null, ManualVerification ?? string.Empty); return base.RunWithChatMessagesReturnsExpectedResultAsync(); } public override Task RunWithNoMessageDoesNotFailAsync() { - Assert.SkipWhen(ManualVerification is not null, ManualVerification!); + Assert.SkipWhen(ManualVerification is not null, ManualVerification ?? string.Empty); return base.RunWithNoMessageDoesNotFailAsync(); } public override Task RunWithStringReturnsExpectedResultAsync() { - Assert.SkipWhen(ManualVerification is not null, ManualVerification!); + Assert.SkipWhen(ManualVerification is not null, ManualVerification ?? string.Empty); return base.RunWithStringReturnsExpectedResultAsync(); } }