I have one web service method that returns product changes history, it signature looks like this:
List<MyProduct> GetProductHistory(int iProductId);
I would like to create an INTEGRATION test for this method. For that I need to create some data in DB. Here I can create a function that writes some ‘hard-coded’ records in DB that will simulate product changes history.
I also need to test other function (int GetProductAverageValue(int iProductId)) which should do some data processing using product history information. In order to test this function I need to have few sets of records (few different history types). And here I have few choices:
- Create a few different hard-coded sets of data (each per test case) (there are a lot of data there, so these sets are a little bit scary);
- Create some functionality inside of my integration tests that will create required history for product…
1st option is scary huge, 2nd – leads to duplication of business logic on the Integration Tests layer…
Please advise. Any thoughts are welcome…
Here is my 2nd question today… in which I found solution myself when completed question writing.
To create ‘good set of product changes history’ I need to use service methods that actually change products. Easy and quick 🙂
P.S. anyway, any comments and suggestions are welcome.