Creating Multiple Choice Exam Using DLINQ

Sometime back I wrote an article on how to create a multiple choice exam using NHibernate. The article was supposed to be multi-part series but I got stuck in work and what not. Anyway, very soon I will complete that article and also a new article in which I will descibe how to make multiple choice exams using DLINQ.

I have started working on the DLINQ article. Here are the class diagrams of the Repositories.

DLINQExamApplicationClassView

And here are few tests to get started:

[Test]
        [RollBack]
        public void CanAddQuestionsToExam()
        {
            var exam = new Exam();
            exam.Title = "Fake Exam";
            exam.Questions.Add(new Question() { Text = "What is 2+2?", Point = 10 });
            exam.Questions.Add(new Question() { Text = "What is 1+1?", Point = 20 });

            ExamRepository rep = new ExamRepository();
            rep.Add(exam);
            rep.PersistAll();

            var eVerify = rep.GetById(exam.ExamID);
            Assert.AreEqual(exam.Questions.Count, eVerify.Questions.Count);
        }

        [Test]
        [RollBack]
        public void CanSaveMultipleExams()
        {
            var exam1 = new Exam();
            exam1.Title = "Fake Exam1";

            var exam2 = new Exam();
            exam2.Title = "Fake Exam2";

            ExamRepository rep = new ExamRepository();
            rep.Add(exam1);
            rep.Add(exam2);
            rep.PersistAll();

            var eVerify1 = rep.GetById(exam1.ExamID);
            var eVerify2 = rep.GetById(exam2.ExamID);

            Assert.IsTrue(eVerify1.ExamID != 0);
            Assert.IsTrue(eVerify2.ExamID != 0);
        }

        [Test]
        [RollBack]
        public void CanSaveExam()
        {
            var exam = new Exam();
            exam.Title = "Fake Exam";

            ExamRepository repository = new ExamRepository();
            repository.Add(exam);
            repository.PersistAll();

            var eVerify = repository.GetById(exam.ExamID);

            Assert.IsTrue(eVerify.ExamID != 0);

            Assert.AreEqual(exam.Title, eVerify.Title);

        }

 

I will publish this article very soon!

Print | posted @ Thursday, November 29, 2007 10:26 AM

Twitter