Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My design doesn't allow me to mock the data so I am using sqlite as test database that has minimum data to run the unit tests. Below is the pseudo code

//Method to be tested
public IList<Funds> GetFunds()
  List<Funds> objFundsList = //gets two records from sqlite db;
  return objFundsList;

//Test Method
public void Check_If_Get_Funds_Returns_List_of_Funds()
      FundsService obj = new FundsService();
      var lstFunds =   obj.GetFunds();
      //Do I need to get first item here to check if bindings for fund is successful
      var fund = obj.GetFunds().First();

Since I am not using in-memory mock objects, I can't do sequenceequal. In this scenario, which other tests I can include.

share|improve this question
If your design doesn't allow you to test easily then that is an indication that your design needs work. You should listen to this instead of fighting it. – Rein Henrichs Apr 2 '13 at 3:02
I mean it is not about our design, but other framework which we are using. It doesn't allow to mock data unless we create a wrapper around that. But again it violates DRY principle. Since its just select statements in our application, we decided with light-weight test database. – Sunny Apr 2 '13 at 3:05
Using a facade does not violate DRY. Wrapping external dependencies that are difficult to test with your own adapter/driver that is testable is a good practice. Your entire test suite shouldn't suffer because one component is hard to test. – Rein Henrichs Apr 2 '13 at 3:06
Yes, you're right. But this application is light-weight in the sense, we can convince ourselves for a mini test db. It has limited functionality. I appreciate your inputs which will be useful in my future implementations. – Sunny Apr 2 '13 at 3:13
up vote 0 down vote accepted

If the order of the result set is undefined by the implementation, then you'll need to write an assertion that's not dependent on the order of the results. CollectionAssert.AreEquivalent is one such method. Here's an example:

// I'm assuming that you've written a helper method to get each fund's name
var actualNames = GetFundNamesFrom(obj);
var expectedNames = ["test1", "test2"];
CollectionAssert.AreEquivalent(expectedNames, actualNames);
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.