I'm trying to write some integration tests for a part of our site that uses a stored procedure instead of running through EF.
We just want to ensure that the data that we get back from the stored procedure is actually correct and integrates correctly with our code.
Our basic setup for the integration tests is that we are doing them all within a transaction scope so the process is:
- Wipe the data from the relevant tables
- Insert appropriate test data
- Run our stored procedure
- Assert the results
Part of the stored procedure we are testing runs on the full text catalog for the table, part of it just queries the table.
This is all running fine for the parts of the stored procedure that don't use the full text index but for the ones that do I get some interesting results.
If I don't clear out the data manually before the tests (ie through sql server explorer) because our mock data is very similar to our seed data the tests all pass.
However if I clear the data manually first so it's essentially starting from an empty full text catalog the tests all fail. What I figure is that the full text index is probably not getting cleared properly in the test but then it's also not getting populated before my stored procedure runs. I've tried adding a wait in (in both code and also similar to this stackoverflow post: How can I know when SQL Full Text Index Population is finished?) but neither seem to allow the full text index to be populated first.
My knowledge on full text indexing is not massive so I'm not sure if it's the way I'm doing or the fact that it's within a transactional scope or what I'm doing wrong.
Interestingly if I don't run it within a transactional scope once (so it populates the database) and then run it the second time it'll pass, so I know that if the full text catalog is there/working the tests will work.
Anyone got any ideas? Am happy to post parts of code if need be.
Thanks, MD