Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
CoreBDD C# Snippets for VSCode
"CoreBDD Fixture": {
"prefix": "fix",
"body": [
"[CollectionDefinition(\"CoreBDD\")]",
" public class Collection : ICollectionFixture<GenerateSpecsFixture> { }",
" public class GenerateSpecsFixture : IDisposable",
" {",
" public void Dispose()",
" {",
" GenerateSpecs.OutputFeatureSpecs(this.GetType().Assembly.Location, @\"..\\..\\..\\Specs\\\");",
" }",
" }"
],
"description": "Create CoreBDD Fixture"
},
"CoreBDD Feature": {
"prefix": "feat",
"body": [
"\t[Feature(\"${1:Calculator}\",",
"\t@\"${2: In order to avoid silly mistakes",
"\tAs a math idiot",
"\tI want to be told the sum of two numbers}\")]",
"\tpublic class ${TM_FILENAME_BASE}: Specification",
"\t{",
"\t\t",
"\t\tpublic ${1:Calculator}(SpecFixture context):base(context)",
"\t\t{",
"\t\t",
"\t\t",
"\t\t}",
"\t\tpublic ${1:Calculator}()",
"\t\t{",
"\t\t",
"\t\t",
"\t\t}",
"\t}"
],
"description": "Create CoreBDD Feature"
},
"CoreBDD Spec": {
"prefix": "scenario",
"body": [
"[Scenario(\"${1:Multiply two numbers}\")]",
"public void ${2:MultiplyTwoNumbers}()",
"{",
"\tGiven(\"${3:I have a calculator}\", () => { });",
"\tWhen(\"${4:I key in 10}\", () => { });",
"\tAnd(\"${5:I key in 5 and press multiply}\", () => { });",
"\tThen(\"${6:It sets the Total to 50}\", () => { });",
"\tAnd(\"${7:It sets the equation to 10 x 5}\", () => { });",
"}"
],
"description": "Create CoreBDD Spec"
},
"CoreBDD Data Driven Scenario": {
"prefix": "scenario-data",
"body": [
"[ScenarioOutline(\"${1:Multiply two numbers}\")]",
"[Examples(20, 4, 5)]",
"[Examples(10, 2, 5)]",
"public void ${2:MultiplyTwoNumbers}(int number, int divideby, int result)",
"{",
"\tGiven($\"I have a calculator\", () => { });",
"\tWhen($\"I key in {number}\", () => { });",
"\tAnd($\"I key in {divideby} and press divide\", () => { });",
"\tThen($\"It sets the Total to {result}\", () => { });",
"\tAnd($\"It sets the equation to {number} / {divideby}\", () => { });",
"}"
],
"description": "Create CoreBDD Data Driven Spec"
},
"CoreBDD Scenario": {
"prefix": "scenario-class",
"body": [
" [Example(\"${1:Scenario Description}\")]",
" public class ${TM_FILENAME_BASE} : ${2:BaseFeature}",
" {",
"\tpublic ${TM_FILENAME_BASE}(SpecFixture context) : base(context)",
"\t{",
"\tcalc = new Calculator();",
"\t}",
"\t[Given(\"I have entered {0} into the calculator\", 5)]",
"\tpublic void Given(int first)",
"\t{",
"\t\tContext.Given.First = first;",
"\t}",
"\t[And(\"I have also entered {0} into the calculator\", 2)]",
"\tpublic void And(int second)",
"\t{",
"\t\tContext.Given.Second = second;",
"\t}",
"\t[When(\"I press minus\")]",
"\tpublic void When()",
"\t{",
"\t\tContext.When = calc.Subtract(Context.Given.First, Context.Given.Second);",
"\t}",
"\t[Then(\"the result should be {0}\", 3)]",
"\tpublic void Then(int result)",
"\t{",
"\t\tContext.Result.ShouldBe(result);",
"\t}",
" }"
],
"description": "Create CoreBDD Data Driven Spec"
},
"CoreBDD Given": {
"prefix": "given",
"body": [
"Given(\"${1:I have...}\", () => {});"
],
"description": "Create Core BDD Given statement (method style)"
},
"CoreBDD When": {
"prefix": "when",
"body": [
"When(\"${1:I ...}\", () => {});"
],
"description": "Create Core BDD When statement (method style)"
},
"CoreBDD Then": {
"prefix": "then",
"body": [
"Then(\"${1:I ...}\", () => {});"
],
"description": "Create Core BDD Then statement (method style)"
},
"CoreBDD And": {
"prefix": "and",
"body": [
"And(\"${1:I ...}\", () => {});"
],
"description": "Create Core BDD And statement (method style)"
},
"CoreBDD But": {
"prefix": "but",
"body": [
"But(\"${1:I ...}\", () => {});"
],
"description": "Create Core BDD But statement (method style)"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.