Developer forum

Forum » Development » Unit testing custommodules

Unit testing custommodules


Reply
Hi

I just downloaded and installed Nunit in order to be able to test my Custommodules.dll.



I wanted to test something specific sp I wrote a testing class as so:



namespace CustomModules.BookingModule

{

    [TestFixture]

    public class UnitTestBookingModule

    {

        BookingFunk bf;

        [SetUp]

        public void Init()

        {

           

            bf = new BookingFunk();           

        }

      

        [Test]

        public void TestWeekend()

        {

            DateTime from = bf.ProperDateTime("12-10-2007 16:00");

            DateTime to = bf.ProperDateTime("13-10-2007 10:00");          

            double price = bf.CalculatePrice(from, to, 4);

            Assert.AreEqual(price, 450);

        }

    }   

}



for some reason I Nunit doesnt instatiate Dynamic.dll classes (I think).

I keep getting and error:



CustomModules.BookingModule.UnitTestBookingModule.TestWeekend : System.NullReferenceException : Objektreferencen er ikke indstillet til en forekomst af et objekt.



and it appears that it happens when i open a database connection like this:



DataSet ds = Database.getDataSet(sql, "rentamini.mdb");



The system works fine in the browser but it would be a huge help to have these unittests to run through the system once in a while.



Can you perhaps provide any help in setting it up properly?



- Sune

Replies

 
Nicolai Høeg Pedersen
Reply

Unit testing with database driven code is not allways that easy. But try reading this:


http://www.codeproject.com/cs/database/UnitTestDbAppsWithNDbUnit.asp


 

 

You must be logged in to post in the forum