-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add security scheme type test (#579)
- Loading branch information
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
...osoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Enums/OpenApiSecuritySchemeTypeTests.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,53 @@ | ||
using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Attributes; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using FluentAssertions; | ||
using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Enums; | ||
using System.Linq; | ||
using System.Reflection; | ||
|
||
namespace Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests.Enums | ||
{ | ||
[TestClass] | ||
public class OpenApiSecuritySchemeTypeTests | ||
{ | ||
[DataTestMethod] | ||
[DataRow("None")] | ||
[DataRow("Basic")] | ||
[DataRow("Bearer")] | ||
public void Given_Enum_Should_Have_Member(string memberName) | ||
{ | ||
var members = typeof(OpenApiSecuritySchemeType).GetMembers().Select(p => p.Name); | ||
|
||
members.Should().Contain(memberName); | ||
} | ||
|
||
[DataTestMethod] | ||
[DataRow("Basic", "basic")] | ||
[DataRow("Bearer", "bearer")] | ||
public void Given_Enum_Should_Have_Decorator(string memberName, string displayName) | ||
{ | ||
var member = this.GetMemberInfo(memberName); | ||
var attribute = member.GetCustomAttribute<DisplayAttribute>(inherit: false); | ||
|
||
attribute.Should().NotBeNull(); | ||
attribute.Name.Should().Be(displayName); | ||
} | ||
|
||
[DataTestMethod] | ||
[DataRow("None", null)] | ||
public void Given_Enum_Should_Have_No_Decorator(string memberName, string displayName) | ||
{ | ||
var member = this.GetMemberInfo(memberName); | ||
var attribute = member.GetCustomAttribute<DisplayAttribute>(inherit: false); | ||
|
||
attribute.Should().BeNull(); | ||
} | ||
|
||
private MemberInfo GetMemberInfo(string name) | ||
{ | ||
var member = typeof(OpenApiSecuritySchemeType).GetMember(name).First(); | ||
|
||
return member; | ||
} | ||
} | ||
} |