Skip to content

Instantly share code, notes, and snippets.

  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Empty Given, When and Then classes for component testing
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