Skip to content
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

implemented API for set dbconnection #111

Open
wants to merge 2 commits into
base: 3.x
Choose a base branch
from
Open

implemented API for set dbconnection #111

wants to merge 2 commits into from

Conversation

unby
Copy link

@unby unby commented Dec 8, 2021

Hi @rgvlee
Implemented a feature to set a specific DbConnection.
It allows testing dapper extensions with mock connection

@rgvlee
Copy link
Owner

rgvlee commented Dec 8, 2021

Hi @unby, thanks for the contribution, it's much appreciated.

What is the use case here? Using EFCore and Dapper at the same time? (not an arrangement that I've used before). I'd have thought it'd one or the other in most cases. Can you elaborate on the use case/s?

Was it intentional that you've modified the EFCore 5 branch? Or should this be targeting EFCore 6?

@unby
Copy link
Author

unby commented Dec 9, 2021

I want to use native API which can me get a lot of control

  1. Output parameters when I work with legacy code
  2. Multiple results when I optimize SQL query
  3. And there are other reasons when we work with Context.Database.GetDbConnection() directly

It does not have to be only Dapper

I modified EFCore 5 branch because I tested the feature on my job project. I am ready to merge to EFCore 6 branch after code review

@rgvlee
Copy link
Owner

rgvlee commented Dec 10, 2021

Thanks, so it seems that provided Context.Database.GetDbConnection() returns something, it'd satisfy the use case?

Do you find you have to do further set up on the mocked DbConnection? Or just having an object rather than null suffices.

There may be several approaches to support the use case.

@unby
Copy link
Author

unby commented Dec 10, 2021

I want to emulate the database behind via DbConnection. I need to configure mock DbConnection

@unby
Copy link
Author

unby commented Dec 16, 2021

@rgvlee, what do you think about the feature?

@rgvlee
Copy link
Owner

rgvlee commented Dec 17, 2021

I'm open to a change to the mock, but cautious about a change to the mock builder.

The library provides functionality to extend the mock for supported relational operations. What we're saying here is that we're providing support for a mock db connection, but pushing any set up back on to the user rather than via the library. That in itself isn't a deal breaker, but how we deliver that needs to be considered.

As this isn't a case that I have used personally, I'd like to try the use cases and assess what the MVP state of the db connection needs to be. From there I'll make a decision about whether we modify the mock itself, or the mock and the mock builder.

@unby
Copy link
Author

unby commented Dec 25, 2021

I prepared full sample for continetue discussion
https://github.com/unby/EntityFrameworkCore.Testing/blob/dbConnection_case/src/EntityFrameworkCore.Testing.Moq.Tests/FullCaseSample.cs#L26

@unby
Copy link
Author

unby commented Jun 7, 2022

Hi @rgvlee, can I prepare PR for 4.x brunch?

@rgvlee
Copy link
Owner

rgvlee commented Jun 7, 2022

I'm working my way through some bugfixes and enhancements, this is on my list of things to look into. Hold off on updating another branch just yet.

@rgvlee rgvlee added the enhancement New feature or request label Jun 7, 2022
@rgvlee rgvlee self-assigned this Jun 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants