Esempio n. 1
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;
            }
        }
        public void TestMethodSaveChangesDB_OK()
        {
            UnikeyFactoryTest.Context.Test test = new UnikeyFactoryTest.Context.Test()
            {
                Date   = DateTime.Now,
                URL    = "Test URL",
                UserId = 1
            };

            Question question = new Question()
            {
                TestId = 1,
                Text   = "Question Test"
            };
            Answer answer = new Answer()
            {
                IsCorrect  = true,
                QuestionId = 1,
                Score      = 10,
                Text       = "Answer Test"
            };

            TestRepository testRepository = new TestRepository();

            try
            {
                question.Answers.Add(answer);
                test.Questions.Add(question);
                testRepository.SaveTest(test);
            }
            catch (Exception ex)
            {
                int gg = 0;
            }

            TestPlatformDBEntities _ctx = new TestPlatformDBEntities();

            Assert.AreEqual(1, _ctx.Tests.Count());

            int g = 0;
        }