Skip to content

Instantly share code, notes, and snippets.

@Powerz
Created April 30, 2023 20:39
  • 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
Save Powerz/f20500a16eead6bc591ed99d224700f5 to your computer and use it in GitHub Desktop.
public class MyClassTests
{
public class Method1 : MyClassTestsBase
{
[Theory]
[AutoData]
public async Task Should_return_A_when_X(parameters)
{
//! Arrange
// ...
//! Act
// ...
//! Assert
// ...
}
[Theory]
[AutoData]
public async Task Should_throw_B_when_Y(parameters)
{
//! Arrange
// ...
//! Act
// ...
//! Assert
// ...
}
}
public class Method2 : MyClassTestsBase
{
[Fact]
public async Task Should_return_A_when_X()
{
//! Arrange
// ...
//! Act
// ...
//! Assert
// ...
}
[Fact]
public async Task Should_throw_B_when_Y()
{
//! Arrange
// ...
//! Act
// ...
//! Assert
// ...
}
}
public abstract class MyClassTestsBase
{
protected readonly MyClass Instance;
protected readonly IDependency1 Dependency1;
protected readonly IDependency2 Dependency2;
protected UserManagerTestsBase()
{
Dependency1 = Substitute.For<IDependency1>();
Dependency2 = Substitute.For<IDependency2>();
Instance = new MyClass(IDependency1, IDependency2);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment