Geeks With Blogs
AzamSharp Some day I will know everything. I hope that day never comes.

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!

Posted on Thursday, November 29, 2007 10:26 AM | Back to top


Comments on this post: Creating Multiple Choice Exam Using DLINQ

# re: Creating Multiple Choice Exam Using DLINQ
Requesting Gravatar...
Isn't DLINQ called LINQ to SQL now?
Left by Chris Eargle on Nov 29, 2007 2:20 PM

# re: Creating Multiple Choice Exam Using DLINQ
Requesting Gravatar...
Yes!

DLINQ = LINQ to SQL = LINQ to SQL Classes
Left by Mohammad Azam on Nov 29, 2007 3:04 PM

Your comment:
 (will show your gravatar)


Copyright © Mohammad Azam | Powered by: GeeksWithBlogs.net