-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* create specification trait * rename to specification
- Loading branch information
Showing
3 changed files
with
59 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,28 @@ | ||
using System; | ||
using Xunit.Sdk; | ||
|
||
namespace Xunit.Categories | ||
{ | ||
[TraitDiscoverer(SpecificationDiscoverer.DiscovererTypeName, DiscovererUtil.AssemblyName)] | ||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)] | ||
public class SpecificationAttribute:Attribute, ITraitAttribute | ||
{ | ||
public SpecificationAttribute() | ||
{ | ||
|
||
} | ||
|
||
public SpecificationAttribute(string id) | ||
{ | ||
this.Identifier = id; | ||
} | ||
|
||
public SpecificationAttribute(long id) | ||
{ | ||
this.Identifier = id.ToString(); | ||
} | ||
|
||
public string Identifier { get; private set; } | ||
|
||
} | ||
} |
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,21 @@ | ||
using System.Collections.Generic; | ||
using Xunit.Abstractions; | ||
using Xunit.Sdk; | ||
|
||
namespace Xunit.Categories | ||
{ | ||
public class SpecificationDiscoverer:ITraitDiscoverer | ||
{ | ||
internal const string DiscovererTypeName = DiscovererUtil.AssemblyName + "." + nameof(SpecificationDiscoverer); | ||
|
||
public IEnumerable<KeyValuePair<string, string>> GetTraits(IAttributeInfo traitAttribute) | ||
{ | ||
var name = traitAttribute.GetNamedArgument<string>("Identifier"); | ||
|
||
yield return new KeyValuePair<string, string>("Category", "Specification"); | ||
|
||
if (!string.IsNullOrWhiteSpace(name)) | ||
yield return new KeyValuePair<string, string>("Specification", name); | ||
} | ||
} | ||
} |
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