Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a3ac584
commit 4caddac
Showing
7 changed files
with
61 additions
and
36 deletions.
There are no files selected for viewing
14 changes: 0 additions & 14 deletions
14
test/Swashbuckle.AspNetCore.SwaggerGen.Test/Fixtures/Types/AnAnnotatedEnum.cs
This file was deleted.
Oops, something went wrong.
25 changes: 25 additions & 0 deletions
25
test/Swashbuckle.AspNetCore.SwaggerGen.Test/Fixtures/Types/Enums.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 @@ | ||
using System.Runtime.Serialization; | ||
|
||
namespace Swashbuckle.AspNetCore.SwaggerGen.Test | ||
{ | ||
public enum ShortEnum:short | ||
{ | ||
Value2 = 2, | ||
Value4 = 4, | ||
Value8 = 8, | ||
} | ||
|
||
public enum IntEnum:int | ||
{ | ||
Value2 = 2, | ||
Value4 = 4, | ||
Value8 = 8, | ||
} | ||
|
||
public enum LongEnum:long | ||
{ | ||
Value2 = 2, | ||
Value4 = 4, | ||
Value8 = 8, | ||
} | ||
} |
9 changes: 0 additions & 9 deletions
9
test/Swashbuckle.AspNetCore.SwaggerGen.Test/Fixtures/Types/IntEnum.cs
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
test/Swashbuckle.AspNetCore.SwaggerGen.Test/Fixtures/Types/LongEnum.cs
This file was deleted.
Oops, something went wrong.
35 changes: 35 additions & 0 deletions
35
test/Swashbuckle.AspNetCore.SwaggerGen.Test/Generator/OpenApiAnyFactoryTests.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,35 @@ | ||
using System; | ||
using Microsoft.OpenApi.Any; | ||
using Microsoft.OpenApi.Models; | ||
using Xunit; | ||
|
||
namespace Swashbuckle.AspNetCore.SwaggerGen.Test | ||
{ | ||
public class OpenApiAnyFactoryTests | ||
{ | ||
[Theory] | ||
[InlineData("boolean", null, true, typeof(OpenApiBoolean))] | ||
[InlineData("integer", "int32", (short)10, typeof(OpenApiInteger))] | ||
[InlineData("integer", "int32", ShortEnum.Value2, typeof(OpenApiInteger))] | ||
[InlineData("integer", "int32", 10, typeof(OpenApiInteger))] | ||
[InlineData("integer", "int32", IntEnum.Value2, typeof(OpenApiInteger))] | ||
[InlineData("integer", "int64", 4294967295L, typeof(OpenApiLong))] | ||
[InlineData("number", "float", 1.2F, typeof(OpenApiFloat))] | ||
[InlineData("number", "double", 1.25D, typeof(OpenApiDouble))] | ||
[InlineData("string", "uuid", "d3966535-2637-48fa-b911-e3c27405ee09", typeof(OpenApiString))] | ||
[InlineData("string", null, "foobar", typeof(OpenApiString))] | ||
public void TryCreateFor_CreatesAnInstance_ForProvidedSchemaAndValue( | ||
string schemaType, | ||
string schemaFormat, | ||
object value, | ||
Type expectedInstanceType) | ||
{ | ||
var schema = new OpenApiSchema { Type = schemaType, Format = schemaFormat }; | ||
|
||
OpenApiAnyFactory.TryCreateFor(schema, value, out IOpenApiAny instance); | ||
|
||
Assert.NotNull(instance); | ||
Assert.IsType(expectedInstanceType, instance); | ||
} | ||
} | ||
} |
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