Beispiel #1
0
        public void TestAddNewTest()
        {
            TestDTO          testDTO          = new TestDTO();
            TestDifficultDTO testDifficultDTO = new TestDifficultDTO();

            // Act
            testService.AddNewTest(testDTO, testDifficultDTO.Id);
            testService.AddNewTest(testDTO, testDifficultDTO.Id);
            testService.AddNewTest(testDTO, testDifficultDTO.Id);
            // Assert
            Assert.AreEqual(3, tests.Count());
        }
Beispiel #2
0
        public void TestMethodSaveChangesDB_ERR()
        {
            TestBusiness test = new TestBusiness()
            {
                Date   = DateTime.Now,
                UserId = 1
            };
            QuestionBusiness question = new QuestionBusiness()
            {
                TestId = 1,
            };
            AnswerBusiness answer = new AnswerBusiness()
            {
                IsCorrect  = true,
                QuestionId = 1,
                Score      = 10,
            };

            TestService testService = new TestService();

            try
            {
                question.Answers.Add(answer);
                test.Questions.Add(question);

                testService.AddNewTest(test);
            }
            catch (Exception ex)
            {
                int g = 0;
            }
        }
Beispiel #3
0
        public void TestMethodSaveChangesDB_ERR()
        {
            UnikeyFactoryTest.Context.Test test = new UnikeyFactoryTest.Context.Test()
            {
                Date   = DateTime.Now,
                UserId = 1
            };
            Question question = new Question()
            {
                TestId = 1,
            };
            Answer answer = new Answer()
            {
                IsCorrect  = true,
                QuestionId = 1,
                Score      = 10,
            };

            TestService testService = new TestService();

            try
            {
                question.Answers.Add(answer);
                test.Questions.Add(question);
                testService.AddNewTest(test);
            }
            catch (Exception ex)
            {
                int g = 0;
            }
        }
Beispiel #4
0
 public ActionResult AddTest(TestModel model)
 {
     test.UserId = UserId;
     test.URL    = _service.GenerateGuid();
     test.Date   = DateTime.Now;
     _service.AddNewTest(TestMapper.MapDalToBiz(test));
     return(View("Index"));
 }
Beispiel #5
0
        private void addTestButton_Click(object sender, EventArgs e)
        {
            int ques = 0,
                time = 0;

            if (Queno.Text != "" && timetext.Text != "")
            {
                ques = Convert.ToInt32(Queno.Text);
                time = Convert.ToInt32(timetext.Text);
            }

            if (testNameText.Text == "" || testCodeText.Text == "" || timetext.Text == "" || Queno.Text == "")
            {
                MessageBox.Show("Fields cannot be empty", "Check Provided Options", MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
            }
            else
            {
                try
                {
                    _testService.AddNewTest(new Test
                    {
                        Name      = testNameText.Text,
                        Testcode  = testCodeText.Text,
                        NumberofQ = ques,
                        Time      = time
                    });


                    MessageBox.Show("Successfully Added Question", "information!", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                    testNameText.Text = "";
                    testCodeText.Text = "";
                    timetext.Text     = "";
                    Queno.Text        = "";
                }
                catch (Exception)
                {
                    MessageBox.Show("All Fields are Required", "information!", MessageBoxButtons.OK,
                                    MessageBoxIcon.Exclamation);
                }
            }
        }