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.

  • 5
    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. Apr 2, 2013 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, 2013 at 3:05
  • 8
    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. Apr 2, 2013 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, 2013 at 3:13
  • 2

1 Answer 1


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);

Your Answer

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

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