views:

93

answers:

2

I recently spent a great deal of time pulling out a stored procedure back-end and replaced it with a NHiberante base repository. One test per repository was nice in the stored procedure version because I could verify my stored procedures worked and the class that mapped the returned data to my objects did it's job.

But after I got this up and running with NHibernate I thought to myself "is this really needed?". After all, NHibernate has unit tests all its own to make sure the session knows how to do dirty tracking/mapping work/etc

Am I missing something here or should I toss these tests that offer no real value?

(sample of a repository I would exercise during this integration test)

public class UserRepository : NHibernateRepository<User>, IUserRepository
{
    public UserRepository() : base()
    {
    }

    public void DeleteUser(User User)
    {
        base.Delete(User);
    }

    public User GetUserById(int id)
    {
        return base.Retrieve(id);
    }

    public IQueryable<User> GetUserCollection()
    {
        return base.RetrieveAll();
    }

    public void SaveUser(User User)
    {
        base.Save(User);
    }
}
+3  A: 

At minimum, you should know that your mapping is working. That is possible by creating some simple tests for delete and save.

Paco
+2  A: 

You should also put in some 'Ghost Buster' style tests for your mappings.

John Rayner