-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added test that shows that a couple of JobRunStates are missing and h…
…ave shifted. relates to #42
- Loading branch information
1 parent
eae67e1
commit 1d525a4
Showing
2 changed files
with
47 additions
and
0 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,46 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace Jobbr.Tests.Integration | ||
{ | ||
[TestClass] | ||
public class MappingTests | ||
{ | ||
[TestMethod] | ||
public void CoreRunStateNames_IfExistInComponentModels_NameHasSameValue() | ||
{ | ||
var coreType = typeof(Jobbr.Server.Core.Models.JobRunStates); | ||
var coreMembers = Enum.GetNames(coreType); | ||
|
||
var errors = new List<string>(); | ||
|
||
var allJobJobRunEnumTypes = AppDomain.CurrentDomain.GetAssemblies().SelectMany(asm => asm.GetTypes().Where(t => t.Namespace != null && t.IsEnum && t.Namespace.Contains("ComponentModel"))); | ||
|
||
foreach (var enumType in allJobJobRunEnumTypes) | ||
{ | ||
var remoteMembers = Enum.GetNames(enumType); | ||
|
||
foreach (var coreName in coreMembers) | ||
{ | ||
if (remoteMembers.Contains(coreName)) | ||
{ | ||
// AutoMapper maps by using the index/value of the enum so we do | ||
var coreValue = (int)Enum.Parse(coreType, coreName); | ||
var remoteVaue = (int)Enum.Parse(enumType, coreName); | ||
|
||
if (remoteVaue != coreValue) | ||
{ | ||
var err = $"{enumType.FullName} contains a member for {coreName} but its value is different. CoreValue: {coreValue}, RemoteValue: {remoteVaue}"; | ||
errors.Add(err); | ||
} | ||
} | ||
} | ||
} | ||
|
||
Assert.AreEqual(0, errors.Count, $"One or more errors found while comparing component model values for {coreType}\n\n" + string.Join("\n", errors)); | ||
|
||
} | ||
} | ||
} |
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