From 167e726d48c9934874239027f9ef172c6b82f98f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20Kirst=C3=A4tter?= <7329802+jochenkirstaetter@users.noreply.github.com> Date: Tue, 26 Mar 2024 21:48:55 +0400 Subject: [PATCH] [skip ci] add tests for interface IGenerativeAI --- .../Mscc.GenerativeAI/GenerativeAI_Should.cs | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 tests/Mscc.GenerativeAI/GenerativeAI_Should.cs diff --git a/tests/Mscc.GenerativeAI/GenerativeAI_Should.cs b/tests/Mscc.GenerativeAI/GenerativeAI_Should.cs new file mode 100644 index 0000000..e6e7a8e --- /dev/null +++ b/tests/Mscc.GenerativeAI/GenerativeAI_Should.cs @@ -0,0 +1,63 @@ +#if NET472_OR_GREATER || NETSTANDARD2_0 +using System.Collections.Generic; +#endif +using FluentAssertions; +using Mscc.GenerativeAI; +using System.Text; +using Xunit; +using Xunit.Abstractions; + +namespace Test.Mscc.GenerativeAI +{ + /// + /// Tests are based on the AIPlatform.Samples repository + /// https://github.com/GoogleCloudPlatform/dotnet-docs-samples/tree/main/aiplatform/api/AIPlatform.Samples + /// + [Collection(nameof(ConfigurationFixture))] + public class GenerativeAI_Should + { + private readonly ITestOutputHelper output; + private readonly ConfigurationFixture fixture; + private readonly string _model = Model.Gemini10ProVision; + + public GenerativeAI_Should(ITestOutputHelper output, ConfigurationFixture fixture) + { + this.output = output; + this.fixture = fixture; + } + + [Fact] + public void Initialize_Interface_GoogleAI() + { + // Arrange + IGenerativeAI genAi; + genAi = new GoogleAI(apiKey: fixture.ApiKey); + var expected = _model.SanitizeModelName(); + + // Act + var model = genAi.GenerativeModel(model: _model); + + // Assert + genAi.Should().NotBeNull(); + model.Should().NotBeNull(); + model.Name.Should().Be($"{expected}"); + } + + [Fact] + public void Initialize_Interface_VertexAI() + { + // Arrange + IGenerativeAI genAi; + genAi = new VertexAI(projectId: fixture.ProjectId, region: fixture.Region); + var expected = _model.SanitizeModelName(); + + // Act + var model = genAi.GenerativeModel(model: _model); + + // Assert + genAi.Should().NotBeNull(); + model.Should().NotBeNull(); + model.Name.Should().Be($"{expected}"); + } + } +} \ No newline at end of file