-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tests to demonstrate declaring enums in requests. And updated O…
…penAPI to shows values for all enums. Closes #42
- Loading branch information
1 parent
c218c3d
commit 70eb23c
Showing
7 changed files
with
109 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/src/.idea/.idea.SaaStack/.idea/markdown.xml |
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
33 changes: 33 additions & 0 deletions
33
src/Infrastructure.Web.Api.IntegrationTests/GeneralApiSpec.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,33 @@ | ||
#if TESTINGONLY | ||
using System.Net; | ||
using FluentAssertions; | ||
using Infrastructure.Web.Api.Operations.Shared.TestingOnly; | ||
using IntegrationTesting.WebApi.Common; | ||
using JetBrains.Annotations; | ||
using Xunit; | ||
|
||
namespace Infrastructure.Web.Api.IntegrationTests; | ||
|
||
[UsedImplicitly] | ||
[Trait("Category", "Integration.API")] | ||
[Collection("API")] | ||
public class GeneralApiSpec : WebApiSpec<ApiHost1.Program> | ||
{ | ||
public GeneralApiSpec(WebApiSetup<ApiHost1.Program> setup) : base(setup) | ||
{ | ||
} | ||
|
||
[Fact] | ||
public async Task WhenGetError_ThenReturnsError() | ||
{ | ||
var result = await Api.PostAsync(new PostWithEnumTestingOnlyRequest | ||
{ | ||
AnEnum = TestEnum.Value1, | ||
AProperty = null | ||
}); | ||
|
||
result.StatusCode.Should().Be(HttpStatusCode.Created); | ||
result.Content.Value.Message.Should().Be("amessageValue1"); | ||
} | ||
} | ||
#endif |
25 changes: 25 additions & 0 deletions
25
src/Infrastructure.Web.Api.Operations.Shared/TestingOnly/PostWithEnumTestingOnlyRequest.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,25 @@ | ||
#if TESTINGONLY | ||
using System.Text.Json.Serialization; | ||
using Infrastructure.Web.Api.Interfaces; | ||
|
||
namespace Infrastructure.Web.Api.Operations.Shared.TestingOnly; | ||
|
||
/// <summary> | ||
/// Tests the use of enums in the request | ||
/// </summary> | ||
[Route("/testingonly/general/enum", OperationMethod.Post, isTestingOnly: true)] | ||
public class PostWithEnumTestingOnlyRequest : IWebRequest<StringMessageTestingOnlyResponse> | ||
{ | ||
[JsonConverter(typeof(JsonStringEnumConverter))] | ||
public TestEnum? AnEnum { get; set; } | ||
|
||
public string? AProperty { get; set; } | ||
} | ||
|
||
public enum TestEnum | ||
{ | ||
Value1, | ||
Value2, | ||
Value3 | ||
} | ||
#endif |
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
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