Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
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
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
- name: 🛠️ Build
run: dotnet build -c Release src/Refitter.sln -p:UseSourceLink=true -p:PackageVersion="${{ env.VERSION }}" -p:Version="${{ env.VERSION }}"
- name: 🧪 Test
run: dotnet test src/Refitter.sln -c Release
run: dotnet test --solution src/Refitter.sln -c Release
Comment thread
christianhelle marked this conversation as resolved.
- name: 🗳️ Upload
uses: actions/upload-artifact@v5
with:
Expand Down
10 changes: 10 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"sdk": {
"version": "10.0.0",
"rollForward": "latestFeature",
"testingPlatform": true
},
"test": {
"runner": "Microsoft.Testing.Platform"
}
}
4 changes: 3 additions & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<LangVersion>preview</LangVersion>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UseTestingPlatform>true</UseTestingPlatform>
<TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>
</PropertyGroup>

<PropertyGroup Label="Nuget">
Expand Down Expand Up @@ -37,4 +39,4 @@
<EnableNETAnalyzers>true</EnableNETAnalyzers>
</PropertyGroup>

</Project>
</Project>
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
using FluentAssertions;
using Refit;
using Refitter.Tests.CustomGenerated;
using Xunit;
using TUnit.Core;

namespace Refitter.SourceGenerators.Tests;

public class CustomOutputFolderGeneratorTests
{
[Fact]
[Test]
public void Can_Create_File_In_Custom_Path() =>
File.Exists("../../../CustomGenerated/CustomGenerated.cs").Should().BeTrue();

[Fact]
[Test]
public void Can_Resolve_Refit_Interface() =>
RestService.For<IApiInCustomGeneratedFolder>("https://petstore3.swagger.io/api/v3")
.Should()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
using FluentAssertions;
using Refit;
using Refitter.Tests.AdditionalFiles.ByTag;
using Xunit;
using TUnit.Core;

namespace Refitter.SourceGenerators.Tests;

public class MultipleInterfaceByTagGeneratorTests
{
[Theory]
[InlineData(typeof(IPetApi))]
[InlineData(typeof(IUserApi))]
[InlineData(typeof(IStoreApi))]
[Test]
[Arguments(typeof(IPetApi))]
[Arguments(typeof(IUserApi))]
[Arguments(typeof(IStoreApi))]
public void Should_Generate_Interface(Type type) =>
type
.Namespace
.Should()
.Be("Refitter.Tests.AdditionalFiles.ByTag");

[Theory]
[InlineData(typeof(IPetApi))]
[InlineData(typeof(IUserApi))]
[InlineData(typeof(IStoreApi))]
[Test]
[Arguments(typeof(IPetApi))]
[Arguments(typeof(IUserApi))]
[Arguments(typeof(IStoreApi))]
public void Can_Resolve_Refit_Interface(Type type) =>
RestService.For(type, "https://petstore3.swagger.io/api/v3")
.Should()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,58 +1,58 @@
using FluentAssertions;
using Refit;
using Refitter.Tests.AdditionalFiles.ByEndpoint;
using Xunit;
using TUnit.Core;

namespace Refitter.SourceGenerators.Tests;

public class MultipleInterfaceGeneratorTests
{
[Theory]
[InlineData(typeof(IAddPetEndpoint))]
[InlineData(typeof(IUpdatePetEndpoint))]
[InlineData(typeof(IDeletePetEndpoint))]
[InlineData(typeof(ICreateUserEndpoint))]
[InlineData(typeof(IUpdateUserEndpoint))]
[InlineData(typeof(IDeleteUserEndpoint))]
[InlineData(typeof(ILoginUserEndpoint))]
[InlineData(typeof(ILogoutUserEndpoint))]
[InlineData(typeof(IPlaceOrderEndpoint))]
[InlineData(typeof(IGetOrderByIdEndpoint))]
[InlineData(typeof(IDeleteOrderEndpoint))]
[InlineData(typeof(IGetInventoryEndpoint))]
[InlineData(typeof(IGetPetByIdEndpoint))]
[InlineData(typeof(IUploadFileEndpoint))]
[InlineData(typeof(IFindPetsByStatusEndpoint))]
[InlineData(typeof(IFindPetsByTagsEndpoint))]
[InlineData(typeof(IGetUserByNameEndpoint))]
[InlineData(typeof(IUpdatePetWithFormEndpoint))]
[InlineData(typeof(ICreateUsersWithListInputEndpoint))]
[Test]
[Arguments(typeof(IAddPetEndpoint))]
[Arguments(typeof(IUpdatePetEndpoint))]
[Arguments(typeof(IDeletePetEndpoint))]
[Arguments(typeof(ICreateUserEndpoint))]
[Arguments(typeof(IUpdateUserEndpoint))]
[Arguments(typeof(IDeleteUserEndpoint))]
[Arguments(typeof(ILoginUserEndpoint))]
[Arguments(typeof(ILogoutUserEndpoint))]
[Arguments(typeof(IPlaceOrderEndpoint))]
[Arguments(typeof(IGetOrderByIdEndpoint))]
[Arguments(typeof(IDeleteOrderEndpoint))]
[Arguments(typeof(IGetInventoryEndpoint))]
[Arguments(typeof(IGetPetByIdEndpoint))]
[Arguments(typeof(IUploadFileEndpoint))]
[Arguments(typeof(IFindPetsByStatusEndpoint))]
[Arguments(typeof(IFindPetsByTagsEndpoint))]
[Arguments(typeof(IGetUserByNameEndpoint))]
[Arguments(typeof(IUpdatePetWithFormEndpoint))]
[Arguments(typeof(ICreateUsersWithListInputEndpoint))]
public void Should_Generate_Interface(Type type) =>
type
.Namespace
.Should()
.Be("Refitter.Tests.AdditionalFiles.ByEndpoint");

[Theory]
[InlineData(typeof(IAddPetEndpoint))]
[InlineData(typeof(IUpdatePetEndpoint))]
[InlineData(typeof(IDeletePetEndpoint))]
[InlineData(typeof(ICreateUserEndpoint))]
[InlineData(typeof(IUpdateUserEndpoint))]
[InlineData(typeof(IDeleteUserEndpoint))]
[InlineData(typeof(ILoginUserEndpoint))]
[InlineData(typeof(ILogoutUserEndpoint))]
[InlineData(typeof(IPlaceOrderEndpoint))]
[InlineData(typeof(IGetOrderByIdEndpoint))]
[InlineData(typeof(IDeleteOrderEndpoint))]
[InlineData(typeof(IGetInventoryEndpoint))]
[InlineData(typeof(IGetPetByIdEndpoint))]
[InlineData(typeof(IUploadFileEndpoint))]
[InlineData(typeof(IFindPetsByStatusEndpoint))]
[InlineData(typeof(IFindPetsByTagsEndpoint))]
[InlineData(typeof(IGetUserByNameEndpoint))]
[InlineData(typeof(IUpdatePetWithFormEndpoint))]
[InlineData(typeof(ICreateUsersWithListInputEndpoint))]
[Test]
[Arguments(typeof(IAddPetEndpoint))]
[Arguments(typeof(IUpdatePetEndpoint))]
[Arguments(typeof(IDeletePetEndpoint))]
[Arguments(typeof(ICreateUserEndpoint))]
[Arguments(typeof(IUpdateUserEndpoint))]
[Arguments(typeof(IDeleteUserEndpoint))]
[Arguments(typeof(ILoginUserEndpoint))]
[Arguments(typeof(ILogoutUserEndpoint))]
[Arguments(typeof(IPlaceOrderEndpoint))]
[Arguments(typeof(IGetOrderByIdEndpoint))]
[Arguments(typeof(IDeleteOrderEndpoint))]
[Arguments(typeof(IGetInventoryEndpoint))]
[Arguments(typeof(IGetPetByIdEndpoint))]
[Arguments(typeof(IUploadFileEndpoint))]
[Arguments(typeof(IFindPetsByStatusEndpoint))]
[Arguments(typeof(IFindPetsByTagsEndpoint))]
[Arguments(typeof(IGetUserByNameEndpoint))]
[Arguments(typeof(IUpdatePetWithFormEndpoint))]
[Arguments(typeof(ICreateUsersWithListInputEndpoint))]
public void Can_Resolve_Refit_Interface(Type type) =>
RestService.For(type, "https://petstore3.swagger.io/api/v3")
.Should()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
using FluentAssertions;
using Refit;
using Refitter.Tests.AdditionalFiles.OptionalParameters;
using Xunit;
using TUnit.Core;

namespace Refitter.SourceGenerators.Tests;

public class OperationalParametersGeneratorTest
{
[Fact]
[Test]
public void Should_Type_Exist() =>
typeof(ISwaggerPetstoreWithOptionalParameters)
.Namespace
.Should()
.Be("Refitter.Tests.AdditionalFiles.OptionalParameters");

[Fact]
[Test]
public void Can_Resolve_Refit_Interface() =>
RestService.For<ISwaggerPetstoreWithOptionalParameters>("https://petstore3.swagger.io/api/v3")
.Should()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,18 @@
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
<OutputType>Exe</OutputType>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateProgramFile>false</GenerateProgramFile>
<RootNamespace>Refitter.SourceGenerators.Tests</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="10.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
<PackageReference Include="FluentAssertions" Version="7.2.0" />
<PackageReference Include="System.Text.Json" Version="10.0.0" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="TUnit" Version="1.3.25" />
<PackageReference Include="coverlet.collector" Version="6.0.4">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
Expand All @@ -42,9 +41,9 @@
</ItemGroup>

<ItemGroup>
<ProjectReference
Include="..\Refitter.SourceGenerator\Refitter.SourceGenerator.csproj"
OutputItemType="Analyzer"
<ProjectReference
Include="..\Refitter.SourceGenerator\Refitter.SourceGenerator.csproj"
OutputItemType="Analyzer"
ReferenceOutputAssembly="false" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
using FluentAssertions;
using Refit;
using Refitter.Tests.AdditionalFiles.SingeInterface;
using Xunit;
using TUnit.Core;

namespace Refitter.SourceGenerators.Tests;

public class SingleInterfaceGeneratorTest
{
[Fact]
[Test]
public void Should_Type_Exist() =>
typeof(ISwaggerPetstoreInterface)
.Namespace
.Should()
.Be("Refitter.Tests.AdditionalFiles.SingeInterface");

[Fact]
[Test]
public void Can_Resolve_Refit_Interface() =>
RestService.For<ISwaggerPetstoreInterface>("https://petstore3.swagger.io/api/v3")
.Should()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
using FluentAssertions;
using Refitter.Tests.UseJsonInheritanceConverter;
using Xunit;
using TUnit.Core;

namespace Refitter.SourceGenerators.Tests;

public class UseJsonInheritanceConverterTests
{
[Theory]
[InlineData(typeof(SomeComponent))]
[Test]
[Arguments(typeof(SomeComponent))]
public void Should_Generate_JsonInheritanceConverter_Usage(Type type) =>
type
.GetCustomAttributes(typeof(JsonInheritanceConverterAttribute), false)
.Should()
.HaveCount(1);

[Theory]
[InlineData(typeof(SomeComponent))]
[Test]
[Arguments(typeof(SomeComponent))]
public void Should_Generate_JsonInheritanceAttribute_Usage(Type type) =>
type
.GetCustomAttributes(typeof(JsonInheritanceAttribute), false)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
using System.Text.Json.Serialization;
using FluentAssertions;
using Refitter.Tests.UsePolymorphicSerialization;
using Xunit;
using TUnit.Core;

namespace Refitter.SourceGenerators.Tests;

public class UsePolymorphicSerializationTests
{
[Theory]
[InlineData(typeof(SomeComponent))]
[Test]
[Arguments(typeof(SomeComponent))]
public void Should_Generate_JsonPolymorphicAttribute_Usage(Type type) =>
type
.GetCustomAttributes(typeof(JsonPolymorphicAttribute), false)
.Should()
.HaveCount(1);

[Theory]
[InlineData(typeof(SomeComponent))]
[Test]
[Arguments(typeof(SomeComponent))]
public void Should_Generate_JsonDerivedTypeAttribute_Usage(Type type) =>
type
.GetCustomAttributes(typeof(JsonDerivedTypeAttribute), false)
Expand Down
Loading
Loading