Skip to content

Commit 0ecc0cf

Browse files
feat: 📚 add comprehensive debugging guide and enhance logging for better troubleshooting
1 parent 0fa5628 commit 0ecc0cf

10 files changed

Lines changed: 256 additions & 243 deletions

File tree

‎DEBUG_LOGGING.md‎

Lines changed: 0 additions & 189 deletions
This file was deleted.

‎JsonApiToolkit.Tests/Controllers/JsonApiControllerTests.cs‎

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,14 @@
66
using JsonApiToolkit.Tests.Models;
77
using Microsoft.AspNetCore.Http;
88
using Microsoft.AspNetCore.Mvc;
9+
using Microsoft.Extensions.DependencyInjection;
910
using Microsoft.Extensions.Logging;
1011
using Moq;
1112

1213
namespace JsonApiToolkit.Tests.Controllers;
1314

1415
public class TestJsonApiController : JsonApiController
1516
{
16-
public TestJsonApiController(ILogger<JsonApiController> logger, IJsonApiQueryParser queryParser)
17-
: base(logger, queryParser) { }
18-
1917
public IActionResult TestJsonApiOk(TestEntity entity)
2018
{
2119
return JsonApiOk(entity, "testEntities");
@@ -48,16 +46,25 @@ public class JsonApiControllerTests
4846

4947
public JsonApiControllerTests()
5048
{
51-
var logger = new Mock<ILogger<JsonApiController>>();
52-
var queryParser = new Mock<IJsonApiQueryParser>();
53-
queryParser
54-
.Setup(x => x.Parse(It.IsAny<Microsoft.AspNetCore.Http.HttpRequest>()))
55-
.Returns(
56-
new JsonApiToolkit.Models.Querying.QueryParameters { Include = new List<string>() }
57-
);
58-
_controller = new TestJsonApiController(logger.Object, queryParser.Object);
59-
60-
var httpContext = new DefaultHttpContext();
49+
var services = new ServiceCollection();
50+
services.AddLogging();
51+
services.AddScoped<IJsonApiQueryParser>(provider =>
52+
{
53+
var mock = new Mock<IJsonApiQueryParser>();
54+
mock.Setup(x => x.Parse(It.IsAny<Microsoft.AspNetCore.Http.HttpRequest>()))
55+
.Returns(
56+
new JsonApiToolkit.Models.Querying.QueryParameters
57+
{
58+
Include = new List<string>(),
59+
}
60+
);
61+
return mock.Object;
62+
});
63+
64+
var serviceProvider = services.BuildServiceProvider();
65+
_controller = new TestJsonApiController();
66+
67+
var httpContext = new DefaultHttpContext { RequestServices = serviceProvider };
6168
httpContext.Request.Scheme = "https";
6269
httpContext.Request.Host = new HostString("api.example.com");
6370
httpContext.Request.Path = "/test-entities";

‎JsonApiToolkit.Tests/Integration/AllowedIncludesIntegrationTests.cs‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,6 @@ public void Dispose()
157157
[Route("api/test")]
158158
public class TestIntegrationController : JsonApiController
159159
{
160-
public TestIntegrationController(
161-
ILogger<JsonApiController> logger,
162-
IJsonApiQueryParser queryParser
163-
)
164-
: base(logger, queryParser) { }
165-
166160
[HttpGet("with-allowed")]
167161
[AllowedIncludes("author", "posts")]
168162
public IActionResult GetWithAllowed()

0 commit comments

Comments
 (0)