diff --git a/src/GitHubActionsDemo.Api/Models/AuthorRequest.cs b/src/GitHubActionsDemo.Api.Contract/AuthorRequest.cs
similarity index 73%
rename from src/GitHubActionsDemo.Api/Models/AuthorRequest.cs
rename to src/GitHubActionsDemo.Api.Contract/AuthorRequest.cs
index 1ab4593..f41a04b 100644
--- a/src/GitHubActionsDemo.Api/Models/AuthorRequest.cs
+++ b/src/GitHubActionsDemo.Api.Contract/AuthorRequest.cs
@@ -1,4 +1,4 @@
-namespace GitHubActionsDemo.Api.Models;
+namespace GitHubActionsDemo.Api.Contract;
public class AuthorRequest
{
diff --git a/src/GitHubActionsDemo.Api/Models/BookRequest.cs b/src/GitHubActionsDemo.Api.Contract/BookRequest.cs
similarity index 78%
rename from src/GitHubActionsDemo.Api/Models/BookRequest.cs
rename to src/GitHubActionsDemo.Api.Contract/BookRequest.cs
index d84d225..6b4fbcf 100644
--- a/src/GitHubActionsDemo.Api/Models/BookRequest.cs
+++ b/src/GitHubActionsDemo.Api.Contract/BookRequest.cs
@@ -1,4 +1,4 @@
-namespace GitHubActionsDemo.Api.Models;
+namespace GitHubActionsDemo.Api.Contract;
public class BookRequest
{
diff --git a/src/GitHubActionsDemo.Api.Contract/GitHubActionsDemo.Api.Contract.csproj b/src/GitHubActionsDemo.Api.Contract/GitHubActionsDemo.Api.Contract.csproj
new file mode 100644
index 0000000..4658cbf
--- /dev/null
+++ b/src/GitHubActionsDemo.Api.Contract/GitHubActionsDemo.Api.Contract.csproj
@@ -0,0 +1,9 @@
+
+
+
+ net7.0
+ enable
+ enable
+
+
+
diff --git a/src/GitHubActionsDemo.Api/Models/PageParameters.cs b/src/GitHubActionsDemo.Api.Contract/PageRequest.cs
similarity index 56%
rename from src/GitHubActionsDemo.Api/Models/PageParameters.cs
rename to src/GitHubActionsDemo.Api.Contract/PageRequest.cs
index c48337b..c024086 100644
--- a/src/GitHubActionsDemo.Api/Models/PageParameters.cs
+++ b/src/GitHubActionsDemo.Api.Contract/PageRequest.cs
@@ -1,6 +1,6 @@
-namespace GitHubActionsDemo.Api.Models;
+namespace GitHubActionsDemo.Api.Contract;
-public class PageParameters
+public class PageRequest
{
public int Page { get; set; } = 1;
public int PageSize { get; set; } = 10;
diff --git a/src/GitHubActionsDemo.Api.Sdk/Class1.cs b/src/GitHubActionsDemo.Api.Sdk/Class1.cs
new file mode 100644
index 0000000..f3cdf9f
--- /dev/null
+++ b/src/GitHubActionsDemo.Api.Sdk/Class1.cs
@@ -0,0 +1,6 @@
+namespace GitHubActionsDemo.Api.Sdk;
+
+public class Class1
+{
+
+}
diff --git a/src/GitHubActionsDemo.Api.Sdk/GitHubActionsDemo.Api.Sdk.csproj b/src/GitHubActionsDemo.Api.Sdk/GitHubActionsDemo.Api.Sdk.csproj
new file mode 100644
index 0000000..4658cbf
--- /dev/null
+++ b/src/GitHubActionsDemo.Api.Sdk/GitHubActionsDemo.Api.Sdk.csproj
@@ -0,0 +1,9 @@
+
+
+
+ net7.0
+ enable
+ enable
+
+
+
diff --git a/src/GitHubActionsDemo.Api/Controllers/AuthorsController.cs b/src/GitHubActionsDemo.Api/Controllers/AuthorsController.cs
index 0703906..3ee84d2 100644
--- a/src/GitHubActionsDemo.Api/Controllers/AuthorsController.cs
+++ b/src/GitHubActionsDemo.Api/Controllers/AuthorsController.cs
@@ -1,4 +1,4 @@
-using GitHubActionsDemo.Api.Models;
+using GitHubActionsDemo.Api.Contract;
using GitHubActionsDemo.Api.Mappers;
using GitHubActionsDemo.Service;
using Microsoft.AspNetCore.Mvc;
@@ -12,12 +12,12 @@ public class AuthorsController : BaseController
{
private readonly ILibraryService _libraryService;
private readonly IValidator _authorValidator;
- private readonly IValidator _pageValidator;
+ private readonly IValidator _pageValidator;
public AuthorsController(
ILibraryService libraryService,
IValidator authorValidator,
- IValidator pageValidator
+ IValidator pageValidator
)
{
_libraryService = libraryService ?? throw new ArgumentNullException(nameof(libraryService));
@@ -53,7 +53,7 @@ public class AuthorsController : BaseController
}
[HttpGet]
- public async Task GetAuthorsAsync([FromQuery] PageParameters parameters)
+ public async Task GetAuthorsAsync([FromQuery] PageRequest parameters)
{
var validationResult = await _pageValidator.ValidateAsync(parameters);
diff --git a/src/GitHubActionsDemo.Api/Controllers/BooksController.cs b/src/GitHubActionsDemo.Api/Controllers/BooksController.cs
index b7bb018..edab700 100644
--- a/src/GitHubActionsDemo.Api/Controllers/BooksController.cs
+++ b/src/GitHubActionsDemo.Api/Controllers/BooksController.cs
@@ -1,4 +1,4 @@
-using GitHubActionsDemo.Api.Models;
+using GitHubActionsDemo.Api.Contract;
using GitHubActionsDemo.Api.Mappers;
using GitHubActionsDemo.Service;
using Microsoft.AspNetCore.Mvc;
@@ -12,12 +12,12 @@ public class BooksController : BaseController
{
private readonly ILibraryService _libraryService;
private readonly IValidator _bookValidator;
- private readonly IValidator _pageValidator;
+ private readonly IValidator _pageValidator;
public BooksController(
ILibraryService libraryService,
IValidator bookValidator,
- IValidator pageValidator
+ IValidator pageValidator
)
{
_libraryService = libraryService ?? throw new ArgumentNullException(nameof(libraryService));
@@ -26,7 +26,7 @@ public class BooksController : BaseController
}
[HttpGet]
- public async Task GetBooksAsync([FromQuery] PageParameters parameters)
+ public async Task GetBooksAsync([FromQuery] PageRequest parameters)
{
var validationResult = await _pageValidator.ValidateAsync(parameters);
diff --git a/src/GitHubActionsDemo.Api/GitHubActionsDemo.Api.csproj b/src/GitHubActionsDemo.Api/GitHubActionsDemo.Api.csproj
index c48f0b4..89cf809 100644
--- a/src/GitHubActionsDemo.Api/GitHubActionsDemo.Api.csproj
+++ b/src/GitHubActionsDemo.Api/GitHubActionsDemo.Api.csproj
@@ -19,6 +19,7 @@
+
diff --git a/src/GitHubActionsDemo.Api/Mappers/AuthorMapper.cs b/src/GitHubActionsDemo.Api/Mappers/AuthorMapper.cs
index a2b42f4..ad925af 100644
--- a/src/GitHubActionsDemo.Api/Mappers/AuthorMapper.cs
+++ b/src/GitHubActionsDemo.Api/Mappers/AuthorMapper.cs
@@ -1,3 +1,4 @@
+using GitHubActionsDemo.Api.Contract;
using GitHubActionsDemo.Api.Models;
using GitHubActionsDemo.Service.Models;
diff --git a/src/GitHubActionsDemo.Api/Mappers/BookMapper.cs b/src/GitHubActionsDemo.Api/Mappers/BookMapper.cs
index f2ac907..92ffbef 100644
--- a/src/GitHubActionsDemo.Api/Mappers/BookMapper.cs
+++ b/src/GitHubActionsDemo.Api/Mappers/BookMapper.cs
@@ -1,3 +1,4 @@
+using GitHubActionsDemo.Api.Contract;
using GitHubActionsDemo.Api.Models;
using GitHubActionsDemo.Service.Models;
diff --git a/src/GitHubActionsDemo.Api/Models/PagedResult.cs b/src/GitHubActionsDemo.Api/Models/PagedResult.cs
deleted file mode 100644
index e69de29..0000000
diff --git a/src/GitHubActionsDemo.Api/Models/Validators/AuthorRequestValidator.cs b/src/GitHubActionsDemo.Api/Models/Validators/AuthorRequestValidator.cs
index 8fa3824..65f41a8 100644
--- a/src/GitHubActionsDemo.Api/Models/Validators/AuthorRequestValidator.cs
+++ b/src/GitHubActionsDemo.Api/Models/Validators/AuthorRequestValidator.cs
@@ -1,5 +1,5 @@
using FluentValidation;
-
+using GitHubActionsDemo.Api.Contract;
namespace GitHubActionsDemo.Api.Models.Validators;
public class AuthorRequestValidator : AbstractValidator
diff --git a/src/GitHubActionsDemo.Api/Models/Validators/BookRequestValidator.cs b/src/GitHubActionsDemo.Api/Models/Validators/BookRequestValidator.cs
index 84a6d31..c77d2ff 100644
--- a/src/GitHubActionsDemo.Api/Models/Validators/BookRequestValidator.cs
+++ b/src/GitHubActionsDemo.Api/Models/Validators/BookRequestValidator.cs
@@ -1,5 +1,5 @@
using FluentValidation;
-
+using GitHubActionsDemo.Api.Contract;
namespace GitHubActionsDemo.Api.Models.Validators;
public class BookRequestValidator : AbstractValidator
diff --git a/src/GitHubActionsDemo.Api/Models/Validators/PageParametersValidator.cs b/src/GitHubActionsDemo.Api/Models/Validators/PageParametersValidator.cs
index dac0bf7..2a09bca 100644
--- a/src/GitHubActionsDemo.Api/Models/Validators/PageParametersValidator.cs
+++ b/src/GitHubActionsDemo.Api/Models/Validators/PageParametersValidator.cs
@@ -1,8 +1,8 @@
using FluentValidation;
-
+using GitHubActionsDemo.Api.Contract;
namespace GitHubActionsDemo.Api.Models.Validators;
-public class PageParametersValidator : AbstractValidator
+public class PageParametersValidator : AbstractValidator
{
public PageParametersValidator()
{
diff --git a/src/GitHubActionsDemo.Api/Program.cs b/src/GitHubActionsDemo.Api/Program.cs
index 090a4b7..c7ef2cb 100644
--- a/src/GitHubActionsDemo.Api/Program.cs
+++ b/src/GitHubActionsDemo.Api/Program.cs
@@ -2,7 +2,7 @@ using GitHubActionsDemo.Service.Infrastructure;
using GitHubActionsDemo.Persistance.Infrastructure;
using Serilog;
using FluentValidation;
-using GitHubActionsDemo.Api.Models;
+using GitHubActionsDemo.Api.Contract;
using GitHubActionsDemo.Api.Models.Validators;
var builder = WebApplication.CreateBuilder(args);
@@ -15,7 +15,7 @@ builder.Logging.AddSerilog(logger);
builder.Services.AddScoped, AuthorRequestValidator>();
builder.Services.AddScoped, BookRequestValidator>();
-builder.Services.AddScoped, PageParametersValidator>();
+builder.Services.AddScoped, PageParametersValidator>();
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
diff --git a/test/GitHubActionsDemo.Api.Tests/AuthorsControllerTests.cs b/test/GitHubActionsDemo.Api.Tests/AuthorsControllerTests.cs
index e6f0102..4da9dc0 100644
--- a/test/GitHubActionsDemo.Api.Tests/AuthorsControllerTests.cs
+++ b/test/GitHubActionsDemo.Api.Tests/AuthorsControllerTests.cs
@@ -1,6 +1,7 @@
using System.Net;
using FluentValidation;
using FluentValidation.Results;
+using GitHubActionsDemo.Api.Contract;
using GitHubActionsDemo.Api.Controllers;
using GitHubActionsDemo.Api.Models;
using GitHubActionsDemo.Service;
@@ -13,7 +14,7 @@ public class AuthorsControllerTests
{
private readonly Mock _libraryService;
private readonly Mock> _authorValidator;
- private readonly Mock> _pageValidator;
+ private readonly Mock> _pageValidator;
private readonly AuthorsController _sut;
@@ -21,7 +22,7 @@ public class AuthorsControllerTests
{
_libraryService = new Mock();
_authorValidator = new Mock>();
- _pageValidator = new Mock>();
+ _pageValidator = new Mock>();
_sut = new AuthorsController(_libraryService.Object, _authorValidator.Object, _pageValidator.Object);
}
diff --git a/test/GitHubActionsDemo.Service.Tests/LibraryServiceTests.cs b/test/GitHubActionsDemo.Service.Tests/LibraryServiceTests.cs
index 67f777d..3c0adbd 100644
--- a/test/GitHubActionsDemo.Service.Tests/LibraryServiceTests.cs
+++ b/test/GitHubActionsDemo.Service.Tests/LibraryServiceTests.cs
@@ -66,4 +66,6 @@ public class LibraryServiceTests
result.AsT0.Value.Title.ShouldBe(newBook.Title);
result.AsT0.Value.Isbn.ShouldBe(newBook.Isbn);
}
+
+ // TODO: Note in a production application there would be a complete set of unit tests here.
}
\ No newline at end of file