Need some guidance on how to go about unit testing a shopping cart (.net mvc, c#).
I want to use sqllite as I am using nhibernate so I can create an in-memory version of my database for integration testing.
So I have a Cart object:
public class Cart
{
void Add(Item item);
void Delete(Item item);
void CalculateTotalBLah();
}
so the method Add might look like:
public void Add(Item item)
{
ItemDAO item = new SomeFactory();
item.Add(item);
}
So there are 2 things I have to test I guess:
- that the in-memory representation of the Cart object adds the item to the cart.
- the database is correctly in synch. with the in-memory object.
The database test I believe is fairly straight forward.
How do I test #1, how do I remove the dependancy of the db operations? Does nunit do this for me somehow?