Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
31 changes: 31 additions & 0 deletions Activout.RestClient.Test.Json/Activout.RestClient.Test.Json.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MartinCostello.Logging.XUnit" Version="0.6.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.0" />
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="RichardSzalay.MockHttp" Version="7.0.0" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Activout.RestClient\Activout.RestClient.csproj" />
<ProjectReference Include="..\Activout.RestClient.Json\Activout.RestClient.Json.csproj" />
<ProjectReference Include="..\Activout.RestClient.Newtonsoft.Json\Activout.RestClient.Newtonsoft.Json.csproj" />
</ItemGroup>

</Project>
19 changes: 19 additions & 0 deletions Activout.RestClient.Test.Json/LoggerFactoryHelpers.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Microsoft.Extensions.Logging;
using Xunit.Abstractions;

namespace Activout.RestClient.Test.Json;

public static class LoggerFactoryHelpers
{
public static ILoggerFactory CreateLoggerFactory(ITestOutputHelper outputHelper)
{
return LoggerFactory.Create(builder =>
{
builder
.AddFilter("Microsoft", LogLevel.Warning)
.AddFilter("System", LogLevel.Warning)
.AddFilter("Activout.RestClient", LogLevel.Debug)
.AddXUnit(outputHelper);
});
}
}
12 changes: 12 additions & 0 deletions Activout.RestClient.Test.Json/MovieReviews/ErrorResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace Activout.RestClient.Test.Json.MovieReviews;

public class ErrorResponse
{
public List<Error> Errors { get; set; } = [];

public class Error
{
public string Message { get; set; } = string.Empty;
public int Code { get; set; }
}
}
36 changes: 36 additions & 0 deletions Activout.RestClient.Test.Json/MovieReviews/IMovieReviewService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
namespace Activout.RestClient.Test.Json.MovieReviews;

[Path("movies")]
[ErrorResponse(typeof(ErrorResponse))]
public interface IMovieReviewService
{
[Get]
Task<IEnumerable<Movie>> GetAllMovies();

[Get]
Task<IEnumerable<Movie>> GetAllMoviesCancellable(CancellationToken cancellationToken);

[Get]
[Path("/{movieId}/reviews")]
Task<IEnumerable<Review>> GetAllReviews(string movieId);

[Get("/{movieId}/reviews/{reviewId}")]
Review GetReview(string movieId, string reviewId);

[Post]
[Path("/{movieId}/reviews")]
Task<Review> SubmitReview([PathParam("movieId")] string movieId, Review review);

[Put]
[Path("/{movieId}/reviews/{reviewId}")]
Review UpdateReview(string movieId, [PathParam] string reviewId, Review review);

[Patch]
[Path("/{movieId}/reviews/{reviewId}")]
Review PartialUpdateReview(string movieId, [PathParam] string reviewId, Review review);

[Get]
Task<IEnumerable<Movie>> QueryMoviesByDate(
[QueryParam] DateTime begin,
[QueryParam] DateTime end);
}
9 changes: 9 additions & 0 deletions Activout.RestClient.Test.Json/MovieReviews/Movie.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Diagnostics.CodeAnalysis;

namespace Activout.RestClient.Test.Json.MovieReviews;

[SuppressMessage("ReSharper", "ClassNeverInstantiated.Global")]
public class Movie
{
public string Title { get; set; } = string.Empty;
}
15 changes: 15 additions & 0 deletions Activout.RestClient.Test.Json/MovieReviews/Review.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace Activout.RestClient.Test.Json.MovieReviews;

public class Review
{
public Review(int stars, string text)
{
Stars = stars;
Text = text;
}

public string? MovieId { get; set; }
public string? ReviewId { get; set; }
public int Stars { get; set; }
public string Text { get; set; } = string.Empty;
}
Loading