-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add template for CustomAutoDataAttributes (#1)
- Loading branch information
Showing
2 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
content/CustomAutoDataAttributes/.template.config/template.json
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,15 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/template", | ||
"author": "Insight Architectures", | ||
"classifications": ["IA", "Testing", "AutoData"], | ||
"name": "[IA] CustomAutoDataAttributes", | ||
"identity": "InsightArchitectures.Templates.Items.CustomAutoDataAttributes", | ||
"groupIdentity": "InsightArchitectures.Templates.Items.CustomAutoDataAttributes.CSharp", | ||
"shortName": "autodata", | ||
"tags": { | ||
"language": "C#", | ||
"type": "item" | ||
}, | ||
"defaultName": "CustomAutoDataAttributes", | ||
"description": "This templates creates a CustomAutoDataAttributes file that uses AutoFixture AutoData for NUnit3 with AutoFixture.AutoMoq" | ||
} |
39 changes: 39 additions & 0 deletions
39
content/CustomAutoDataAttributes/CustomAutoDataAttributes.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,39 @@ | ||
using System; | ||
using AutoFixture; | ||
using AutoFixture.AutoMoq; | ||
using AutoFixture.NUnit3; | ||
|
||
namespace Tests | ||
{ | ||
[AttributeUsage(AttributeTargets.Method)] | ||
public class CustomAutoDataAttribute : AutoDataAttribute | ||
{ | ||
public CustomAutoDataAttribute() : base(FixtureHelpers.CreateFixture) | ||
{ | ||
} | ||
} | ||
|
||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] | ||
public class CustomInlineAutoDataAttribute : InlineAutoDataAttribute | ||
{ | ||
public CustomInlineAutoDataAttribute(params object[] args) : base(FixtureHelpers.CreateFixture, args) | ||
{ | ||
} | ||
} | ||
|
||
internal static class FixtureHelpers | ||
{ | ||
public static IFixture CreateFixture() | ||
{ | ||
var fixture = new Fixture(); | ||
|
||
fixture.Customize(new AutoMoqCustomization | ||
{ | ||
ConfigureMembers = true, | ||
GenerateDelegates = true | ||
}); | ||
|
||
return fixture; | ||
} | ||
} | ||
} |