-
Notifications
You must be signed in to change notification settings - Fork 3
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
dee881d
commit 3ab0967
Showing
3 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
...pi.Tests.Unit/Tests/Features/Games/GameImportExport/GameImportExportModelsMappingTests.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,43 @@ | ||
using System.ComponentModel.DataAnnotations.Schema; | ||
using System.Reflection; | ||
using Gameboard.Api.Data; | ||
using Gameboard.Api.Features.Games; | ||
using Swashbuckle.AspNetCore.SwaggerGen; | ||
|
||
namespace Gameboard.Api.Tests.Unit; | ||
|
||
public class GameImportExportModelsMappingTests | ||
{ | ||
[Fact] | ||
public void GameImportExportExternalHosts_ExportsProperties() | ||
{ | ||
var allowSkipProperties = new string[] { "HostApiKey", "UsedByGames" }; | ||
var properties = typeof(GameImportExportExternalHost).GetProperties(BindingFlags.Public | BindingFlags.Instance); | ||
var propertyNames = properties.Select(p => p.Name).ToArray(); | ||
var gameProperties = typeof(ExternalGameHost) | ||
.GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly) | ||
.Where(p => !p.HasAttribute<NotMappedAttribute>()); | ||
|
||
gameProperties.Where | ||
( | ||
p => !propertyNames.Contains(p.Name) && !allowSkipProperties.Contains(p.Name) | ||
) | ||
.ToArray() | ||
.Length.ShouldBe(0); | ||
} | ||
|
||
[Fact] | ||
public void GameImportExportExternalHosts_AttributeStrategy_ExportsProperties() | ||
{ | ||
var properties = typeof(GameImportExportExternalHost).GetProperties(BindingFlags.Public | BindingFlags.Instance); | ||
var propertyNames = properties.Select(p => p.Name).ToArray(); | ||
var gameProperties = typeof(ExternalGameHost) | ||
.GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly) | ||
.Where(p => !p.HasAttribute<NotMappedAttribute>()) | ||
.Where(p => !p.HasAttribute<DontExportAttribute>()); | ||
|
||
gameProperties.Where(p => !propertyNames.Contains(p.Name)) | ||
.ToArray() | ||
.Length.ShouldBe(0); | ||
} | ||
} |
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