0

I need to test a relatively large ASP.NET MVC based project. One of the modules is responsible for user details and to be more specific its orders. The workflow of the user registration requires in some point a set of free product IDs. They must be extracted from a table in the project actual database.

Table looks like this:

Numbers

| ID | Product | Status   
_______________________
 1     Some         1
 2     Some         2
 3     Some         1

I need only one single query, that will take first 10 records with Status equal to 1.

Here is pseudo:

SELECT TOP 10 *
FROM Numbers
WHERE Status = '1'

To me, it's seems overkill to use Entity Framework / ADO.NET or any complex ORM. At this point I did it manually, pausing the tests to this point, populate the required numbers and resuming test.

What simple solution can be applied here?

Thanks for your answers.

2 Answers 2

1

I don't think you can "underkill" with ADO.net, it's already pretty close to metal, and since you mentioned that it's a relatively large project, why not use Entity Framework? It's designed to help developers get quick and dirty from my experience, until you have performance issue.. then you would move closer to metal

Sign up to request clarification or add additional context in comments.

5 Comments

My test project is separate one, form theirs. So they have Entity framework. But at this point, I need just this simple query. And that's it. Any additional libs (for just 10 records) seems like a burden :)
If you are tasked to do the unit testing, you should grab the data from their repository libraries? If you are manually executing those queries, what happens when the core project members rename the table or columns?
The App Project is in final stage, so no DB schemes will be changed. Its E2E testing
To future proof your tests, I still suggest using some mini ORM like dapper, (stackoverflow runs on this & it's open sourced by them) it's really easy to use. To go back to your question, a simple solution can be interpreted in many ways. How thorough or future proof you want to be? Is it just a one-off test which you will never revisit, or do you need a simple yet elegant way of testing?
Simple test, that I don't need to extend any further in time. I'll take a look at this mini ORM. Thanks.
0

In scenarios like this, IMO what matters is how comfortable are you using 'Method1' over 'Method2'.

I would still use Entity Framework to do task as simple as this.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.