Shared test suite for ADO.NET providers.
$ dotnet add package AdoNet.Specification.TestsThis package provides base classes that let you test your ADO.NET library for conformance to common ADO.NET patterns. ADO.NET doesn't have a formal specification for ADO.NET providers, but many libraries (such as Microsoft.Data.SqlClient, Npgsql, and MySqlConnector) exhibit similar behavior.
Create a test project that uses xunit.
Write a class that implements IDbFactoryFixture:
public class DbFactoryFixture : IDbFactoryFixture
{
public DbFactoryFixture()
{
ConnectionString ="your test connection string";
}
public string ConnectionString { get; }
public DbProviderFactory Factory => YourDbProviderFactory.Instance;
}
Then write test classes that inherit from the classes in this package, e.g.,
public sealed class ConnectionTests : ConnectionTestBase<DbFactoryFixture>
{
public ConnectionTests(DbFactoryFixture fixture)
: base(fixture)
{
}
[Fact(Skip = "Override a method and provide a 'Skip' reason to opt out of a test.")]
public override void Set_ConnectionString_throws_when_invalid()
{
}
}