コード例 #1
0
        public void TestExamResult()
        {
            int userId = 1;

            QuestionAnswer answer1  = new QuestionAnswer("Ostrava", true);
            QuestionAnswer answer2  = new QuestionAnswer("Praha", false);
            Question       question = QuestionTable.InsertQuestion(this.connection, userId, "test", "closed", new List <QuestionAnswer>()
            {
                answer1, answer2
            });

            Exam exam = ExamTable.InsertExam(this.connection, userId, "test exam", 10, 1, 1, DateTime.Now.AddDays(-1), DateTime.Now.AddDays(1));

            exam.AddQuestion(question.Id, 20);
            ExamTable.UpdateExam(this.connection, exam);

            int        examResultId = ExamResultTable.InsertExamResult(this.connection, exam.Id, userId);
            ExamResult examResult   = ExamResultTable.GetExamResultById(this.connection, examResultId);

            Assert.AreEqual(examResultId, examResult.Id);
            Assert.AreEqual(userId, examResult.OwnerId);
            Assert.AreEqual("created", examResult.State);

            ExamAnswer answer = new ExamAnswer(question.Id, "Ostrava");

            Assert.IsTrue(ExamResultTable.HandInExamResult(this.connection, examResult, new List <ExamAnswer>()
            {
                answer
            }));

            examResult = ExamResultTable.GetExamResultById(this.connection, examResult.Id);

            Assert.AreEqual("finished", examResult.State);
            Assert.AreEqual(exam.Questions[0].Points, examResult.Points);
        }
コード例 #2
0
ファイル: ExamTest.cs プロジェクト: Kobzol/dais-project
        public void TestExamCreation()
        {
            Exam exam   = ExamTable.InsertExam(this.connection, 1, "test", 10, 10, 3, DateTime.Now, DateTime.Now.AddDays(1));
            Exam dbExam = ExamTable.GetExamById(this.connection, exam.Id);

            Assert.AreEqual(exam.Id, dbExam.Id);
            Assert.AreEqual(exam.OwnerId, dbExam.OwnerId);
            Assert.AreEqual(exam.Name, dbExam.Name);
            Assert.AreEqual(exam.Timelimit, dbExam.Timelimit);
            Assert.AreEqual(exam.MinimumPoints, dbExam.MinimumPoints);
            Assert.AreEqual(exam.MaximumAttempts, dbExam.MaximumAttempts);
            Assert.AreEqual(exam.StartDate, dbExam.StartDate);
            Assert.AreEqual(exam.EndDate, dbExam.EndDate);

            Assert.IsTrue(ExamTable.DeleteExam(this.connection, exam, 1));

            try
            {
                exam = ExamTable.GetExamById(this.connection, exam.Id);
                Assert.Fail("Test pořád existuje");
            }
            catch (DatabaseException)
            {
            }
        }
コード例 #3
0
ファイル: ExamTest.cs プロジェクト: Kobzol/dais-project
        public void TestExamActiveList()
        {
            Exam exam = ExamTable.InsertExam(this.connection, 1, "test", 10, 10, 10, DateTime.Now.AddDays(-1), DateTime.Now.AddDays(1));

            Assert.IsTrue(ExamTable.GetActiveExams(this.connection).Contains(exam.Id));

            Assert.IsTrue(ExamTable.DeleteExam(this.connection, exam, exam.OwnerId));
        }
コード例 #4
0
ファイル: ExamTest.cs プロジェクト: Kobzol/dais-project
        public void TestExamActive()
        {
            Exam activeExam = ExamTable.InsertExam(this.connection, 1, "test", 10, 10, 10, DateTime.Now.AddDays(-1), DateTime.Now.AddDays(1));

            Assert.IsTrue(ExamTable.IsExamActive(this.connection, activeExam));

            Exam inactiveExam = ExamTable.InsertExam(this.connection, 1, "test", 10, 10, 10, DateTime.Now.AddDays(1), DateTime.Now.AddDays(2));

            Assert.IsFalse(ExamTable.IsExamActive(this.connection, inactiveExam));

            Assert.IsTrue(ExamTable.DeleteExam(this.connection, activeExam, activeExam.OwnerId));
            Assert.IsTrue(ExamTable.DeleteExam(this.connection, inactiveExam, inactiveExam.OwnerId));
        }
コード例 #5
0
ファイル: ExamTest.cs プロジェクト: Kobzol/dais-project
        public void TestExamQuestions()
        {
            Exam exam = ExamTable.InsertExam(this.connection, 1, "test", 10, 10, 10, DateTime.Now, DateTime.Now.AddDays(1));

            exam.AddQuestion(new ExamQuestion(1, exam.Id, 0, 5.5m));

            ExamTable.UpdateExam(this.connection, exam);

            Exam dbExam = ExamTable.GetExamById(this.connection, exam.Id);

            Assert.AreEqual(exam.Questions.Count, dbExam.Questions.Count);
            Assert.AreEqual(exam.Questions[0].Points, dbExam.Questions[0].Points);

            Assert.IsTrue(ExamTable.DeleteExam(this.connection, exam, exam.OwnerId));
        }