Unit testing collections

Posts   
 
    
trancehead
User
Posts: 137
Joined: 03-Dec-2007
# Posted on: 21-Jul-2009 12:38:23   

I am very new to unit testing but have been using LLBLGen for almost 2 years already. I have decided to start unit testing projects for the obvious benefits that introduces.

Lets say I have implemented a call to a collection like this


// Get logs for the last 30 days
public void Fetch(int pageSize, int pageIndex, bool GetVirtualRecordCount)
        {
            IPredicateExpression Filter = new PredicateExpression();
            Filter.Add(EventLogFields.Timestamp > DateTime.Now.AddDays(30));
            EventLogs.GetMulti(Filter, 0, this.SortExpression, null, this.PrefetchPath, pageIndex, pageSize);
            if (GetVirtualRecordCount)
                this.VirtualRecordCount = DataHelper.GetVirtualCount(Filter, null, EventLogFields.Id);
        }

I don't want to unit test LLBLGen but I would like to know if in future someone (or me) changes this call that the unit test will let them know that they have broken it.

How do other people do this?

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 21-Jul-2009 17:40:49   

There is quite a big discussion on Unit Testing here

In addition searching the forums for "unit testing" throws up a number of other threads worth a read.

Matt