-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #254 from OctopusDeploy/enh-accountscope
Enh accountscope
- Loading branch information
Showing
37 changed files
with
1,475 additions
and
8 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
source/Octopus.Client.Tests/Conventions/AccountTypeConventions.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,41 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Reflection; | ||
using NUnit.Framework; | ||
using Octopus.Client.Extensions; | ||
using Octopus.Client.Model.Accounts; | ||
|
||
namespace Octopus.Client.Tests.Conventions | ||
{ | ||
[TestFixture] | ||
public class AccountTypeConventions | ||
{ | ||
private static readonly TypeInfo[] ExportedTypes = typeof(AccountResource).GetTypeInfo().Assembly.GetExportedTypes().Select(t => t.GetTypeInfo()).ToArray(); | ||
|
||
[Test] | ||
public void AllAccountResourceTypeCanBeMappedToAnAccountType() | ||
{ | ||
var derivedAccountTypes = ExportedTypes | ||
.Where(t => !t.IsAbstract) | ||
.Where(t => typeof(AccountResource).IsAssignableFrom(t)) | ||
.ToArray(); | ||
|
||
var typesThatCannotBeMapped = derivedAccountTypes.Where(t => | ||
{ | ||
try | ||
{ | ||
t.DetermineAccountType(); | ||
return false; | ||
} | ||
catch (ArgumentException) | ||
{ | ||
return true; | ||
} | ||
}) | ||
.ToArray(); | ||
|
||
if (typesThatCannotBeMapped.Any()) | ||
Assert.Fail($"The following AccountResource types cannot be mapped to an AccountType: " + typesThatCannotBeMapped.CommaSeperate()); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.