You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Often there are many tests for the same subject sharing most of the givens and having different whens. It's convenient to reuse them as a common base class like:
public abstract class Given_a_computer : GivenSubject<IComputer>
{
public Given_a_computer()
{
Given(() =>
{
WithSubject(new Computer());
}
}
}
public class When_Windows_is_installed : Given_a_computer
{
public When_Windows_is_installed()
{
When(() => Subject.InstallWindows());
}
[Fact]
public void Then_it_must_die()
{
Subject.Should().BeDead();
}
}
public class When_Linux_is_installed : Given_a_computer
{
public When_Windows_is_installed()
{
When(() => Subject.InstallLinux());
}
[Fact]
public void Then_it_should_work()
{
Subject.Should().Work();
}
}
However, it's not possible to have a common base class for test with results and without results because they must have different Chill base class (GivenSubject<TSubject> vs GivenSubject<TSubject, TResult>, or GivenWhenThen vs GivenWhenThen<TResult>).
The text was updated successfully, but these errors were encountered:
Often there are many tests for the same subject sharing most of the givens and having different whens. It's convenient to reuse them as a common base class like:
However, it's not possible to have a common base class for test with results and without results because they must have different Chill base class (
GivenSubject<TSubject>
vsGivenSubject<TSubject, TResult>
, orGivenWhenThen
vsGivenWhenThen<TResult>
).The text was updated successfully, but these errors were encountered: