This repository has been archived by the owner on Aug 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(#771) Tests to show read-only controllers work now. (#778)
- Loading branch information
1 parent
8bff35a
commit 7693ea9
Showing
7 changed files
with
471 additions
and
12 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
45 changes: 45 additions & 0 deletions
45
sdk/dotnet/test/Microsoft.AspNetCore.Datasync.NSwag.Test/Service/KitchenReaderController.cs
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,45 @@ | ||
using Microsoft.AspNetCore.Datasync.EFCore; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace Microsoft.AspNetCore.Datasync.NSwag.Test.Service; | ||
|
||
[ExcludeFromCodeCoverage] | ||
public abstract class ReadonlyTableController<TData> : TableController<TData> where TData : class, ITableData | ||
{ | ||
[NonAction] | ||
public override Task<IActionResult> CreateAsync([FromBody] TData item, CancellationToken token = default) | ||
{ | ||
return base.CreateAsync(item, token); | ||
} | ||
|
||
[NonAction] | ||
public override Task<IActionResult> DeleteAsync([FromRoute] string id, CancellationToken token = default) | ||
{ | ||
return base.DeleteAsync(id, token); | ||
} | ||
|
||
[NonAction] | ||
public override Task<IActionResult> PatchAsync([FromRoute] string id, CancellationToken token = default) | ||
{ | ||
return base.PatchAsync(id, token); | ||
} | ||
|
||
[NonAction] | ||
public override Task<IActionResult> ReplaceAsync([FromRoute] string id, [FromBody] TData item, CancellationToken token = default) | ||
{ | ||
return base.ReplaceAsync(id, item, token); | ||
} | ||
} | ||
|
||
[Route("tables/kitchenreader")] | ||
[ExcludeFromCodeCoverage] | ||
public class KitchenReaderController : ReadonlyTableController<KitchenSink> | ||
{ | ||
public KitchenReaderController(ServiceDbContext context, ILogger<KitchenSink> logger) : base() | ||
{ | ||
Repository = new EntityTableRepository<KitchenSink>(context); | ||
Logger = logger; | ||
} | ||
} | ||
|
Oops, something went wrong.