-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add MockDbDataSource #34
Comments
Hi. I will check how it is possible. But you could create a new PR to improve the lib 😊 |
I published a 2.0.1-preview version, adding a new class [TestMethod]
public async Task Mock_DataSource_Default_Test()
{
await using var dataSource = new MockDbDataSource();
await using var connection = await dataSource.OpenConnectionAsync() as MockDbConnection;
connection.Mocks
.When(c => c.CommandText.Contains("SELECT"))
.ReturnsScalar(14);
using (var cmd = connection.CreateCommand())
{
cmd.CommandText = "SELECT * FROM EMP WHERE ID = @ID";
var result = cmd.ExecuteScalar();
Assert.AreEqual(14, result);
}
} Could you tell me how you use the |
I also use it in this way: [TestMethod]
public async Task Mock_DataSource_CreateCommand_Test()
{
await using var dataSource = new MockDbDataSource();
await using var connection = await dataSource.OpenConnectionAsync() as MockDbConnection;
connection.Mocks
.When(c => c.CommandText.Contains("SELECT"))
.ReturnsScalar(14);
using (var cmd = dataSource.CreateCommand("SELECT * FROM EMP WHERE ID = @ID"))
{
var result = cmd.ExecuteScalar();
Assert.AreEqual(14, result);
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
.NET 7 introduced a new abstraction DbDataSource. Please add possibility to mock it.
dotnet/runtime#64812
The text was updated successfully, but these errors were encountered: