-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[skip ci] add tests for interface IGenerativeAI
- Loading branch information
1 parent
3aaaeae
commit 167e726
Showing
1 changed file
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
{ | ||
/// <summary> | ||
/// Tests are based on the AIPlatform.Samples repository | ||
/// https://github.com/GoogleCloudPlatform/dotnet-docs-samples/tree/main/aiplatform/api/AIPlatform.Samples | ||
/// </summary> | ||
[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}"); | ||
} | ||
} | ||
} |