I have a WCF service that accesses the database and adds data to it. now, I want to do some integration and/or system tests (automated).
How do I do it ?
I have to access the database, load initial data, call the service and then verify whether the data expected was actually loaded in the table.
is there any strategy for doing that you would recommend ?
I'm using WCF, Entity Framework, SQL Server, MSTests.
If you don't mind your test project taking a dependency on Entity Framework then here's how I would approach this.
You should also consider using a lightweight file-based/in-memory database such as SQLite for this task. One simple way of achieving this would be to use EF to generate a model from your DB, then use the Update Database From Model tool to generate the SQL that will create the appropriate tables and constraints in your SQLite instance. This means no risk of munting the data in your main/dev DB and potentially faster tests.
Also regarding steps 3 and 6, some people would advocate using the setup/clean-up/tear-down affordance built in to MSTest. I generally don't start using these until I can see them helping with reducing code duplication, because in my opinion they make tests less clear and readable, but that's a personal thing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With