-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
24,131 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
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,60 @@ | ||
using System.Collections.Immutable; | ||
using System.Runtime.CompilerServices; | ||
using OpenApiGenerator.Core.Generators; | ||
using OpenApiGenerator.Core.Models; | ||
|
||
namespace OpenApiGenerator.UnitTests; | ||
|
||
[TestClass] | ||
public class ModelTests : | ||
VerifyBase | ||
{ | ||
private Settings DefaultSettings => new( | ||
TargetFramework: "netstandard2.0", | ||
Namespace: "G", | ||
ClassName: "Api", | ||
NamingConvention: default, | ||
IncludeOperationIds: [], | ||
GenerateModels: true, | ||
ModelStyle: default, | ||
IncludeModels: [] | ||
); | ||
|
||
private Task VerifyAsync( | ||
ImmutableArray<ModelData> models, | ||
[CallerMemberName] string? callerName = null) | ||
{ | ||
return Verify(models | ||
.Select(x => x with { Parents = [] }) | ||
.ToArray()) | ||
.UseDirectory($"Snapshots/{callerName}") | ||
.UseFileName("_") | ||
//.AutoVerify() | ||
; | ||
} | ||
|
||
[TestMethod] | ||
public Task OpenAi() | ||
{ | ||
var yaml = H.Resources.openai_yaml.AsString(); | ||
var settings = DefaultSettings with | ||
{ | ||
//IncludeModels = ["CreateCompletionResponse"], | ||
}; | ||
|
||
var models = ModelGeneratorMethods.PrepareData((yaml, settings)); | ||
|
||
return VerifyAsync(models); | ||
} | ||
|
||
[TestMethod] | ||
public Task Ollama() | ||
{ | ||
var yaml = H.Resources.ollamacurated_yaml.AsString(); | ||
var settings = DefaultSettings; | ||
|
||
var models = ModelGeneratorMethods.PrepareData((yaml, settings)); | ||
|
||
return VerifyAsync(models); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/tests/OpenApiGenerator.UnitTests/OpenApiGenerator.UnitTests.csproj
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,41 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup Label="Base packages"> | ||
<PackageReference Include="GitHubActionsTestLogger" Version="2.3.3"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" /> | ||
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" /> | ||
<PackageReference Include="MSTest.TestFramework" Version="3.2.0" /> | ||
<PackageReference Include="FluentAssertions" Version="6.12.0" /> | ||
<PackageReference Include="Verify.MSTest" Version="23.1.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup Label="GlobalUsings"> | ||
<Using Include="Microsoft.VisualStudio.TestTools.UnitTesting" /> | ||
<Using Include="FluentAssertions" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="H.Resources.Generator" Version="1.6.0"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\libs\OpenApiGenerator.Core\OpenApiGenerator.Core.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Folder Include="Snapshots\Models\" /> | ||
<Folder Include="Snapshots\Ollama\" /> | ||
<Folder Include="Snapshots\OpenAi\" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Oops, something went wrong.