Last active
July 30, 2023 22:24
-
-
Save andrewjpoole/039ae07be0bc3534cda6383780d5a945 to your computer and use it in GitHub Desktop.
Empty Given, When and Then classes for component testing
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
public class Given | |
{ | |
private readonly XyzApiWebApplicationFactory context; // replace this type with your specific WebApplicationFactory etc | |
public Given(XyzApiWebApplicationFactory context) | |
{ | |
this.context = context; | |
} | |
public static Given UsingThe(XyzApiWebApplicationFactory context) => new(context); | |
public Given And => this; | |
public Given TheServerIsStarted() | |
{ | |
apiWebApplicationFactory.Start(); | |
return this; | |
} | |
} | |
public class When | |
{ | |
private readonly XyzApiWebApplicationFactory context; // replace this type with your specific WebApplicationFactory etc | |
public When(XyzApiWebApplicationFactory context) | |
{ | |
this.context = context; | |
} | |
public static When UsingThe(XyzApiWebApplicationFactory context) => new(context); | |
public When And => this; | |
} | |
public class Then | |
{ | |
private readonly XyzApiWebApplicationFactory context; // replace this type with your specific WebApplicationFactory etc | |
public Then(XyzApiWebApplicationFactory context) | |
{ | |
this.context = context; | |
} | |
public static Then UsingThe(XyzApiWebApplicationFactory context) => new(context); | |
public Then And => this; | |
public Then Assert(Action inlineAssertion) | |
{ | |
inlineAssertion(); | |
return this; | |
} | |
public Then And(Action inlineAssertion) => Assert(inlineAssertion); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment