예제 #1
0
        /// <summary>
        /// This method used for creating a test.
        /// </summary>
        /// <returns></returns>
        private async Task <DomainModel.Models.Test.Test> CreateTestAsync()
        {
            var test = new DomainModel.Models.Test.Test()
            {
                TestName         = "GK",
                Duration         = 70,
                BrowserTolerance = BrowserTolerance.High,
                CorrectMarks     = 4,
                IncorrectMarks   = 1
            };

            _globalUtil.Setup(x => x.GenerateRandomString(10)).Returns(_stringConstants.MagicString);
            string          userName = "******";
            ApplicationUser user     = new ApplicationUser()
            {
                Email = userName, UserName = userName
            };
            await _userManager.CreateAsync(user);

            var applicationUser = await _userManager.FindByEmailAsync(user.Email);

            await _testRepository.CreateTestAsync(test, applicationUser.Id);

            return(test);
        }
예제 #2
0
        private DomainModel.Models.Test.Test CreateTest(string testName)
        {
            var test = new DomainModel.Models.Test.Test
            {
                TestName         = testName,
                BrowserTolerance = 0
            };

            return(test);
        }
예제 #3
0
        /// <summary>
        /// Creates a test
        /// </summary>
        /// <param name="testName">Contains the name of the test created</param>
        /// <returns>Object of Test</returns>
        private DomainModel.Models.Test.Test CreateTest(string testName)
        {
            var test = new DomainModel.Models.Test.Test
            {
                TestName         = testName,
                IncorrectMarks   = 1,
                BrowserTolerance = BrowserTolerance.Medium,
            };

            return(test);
        }
예제 #4
0
        /// <summary>
        /// Test case for getting the details of code snippet question
        /// </summary>
        //[Fact]
        //public async Task GetCodeSnippetDetailsAsync()
        //{
        //    var test = CreateTest("Coding Test1");
        //    await _testRepository.CreateTestAsync(test, "5");
        //    var testAttendee = CreateTestAttendee(test.Id);
        //    await _testConductRepository.RegisterTestAttendeesAsync(testAttendee, "Added");
        //    //create category
        //    var category = CreateCategory("coding question");
        //    await _categoryRepository.AddCategoryAsync(category);
        //    //create coding question
        //    var question = CreateCodingQuestionAc(true, category.Id, 2, QuestionType.Programming);
        //    await _questionRepository.AddCodeSnippetQuestionAsync(question, test.CreatedByUserId);
        //    var questionId = (await _trappistDbContext.Question.SingleAsync(x => x.QuestionDetail == question.Question.QuestionDetail)).Id;

        //    var answer = new TestAnswerAC()
        //    {
        //        OptionChoice = new List<int>(),
        //        QuestionId = questionId,
        //        Code = new Code()
        //        {
        //            Input = "input",
        //            Source = "source",
        //            Language = ProgrammingLanguage.C
        //        },
        //        QuestionStatus = QuestionStatus.answered
        //    };
        //    await _testConductRepository.AddAnswerAsync(testAttendee.Id, answer,0.0);
        //    var testCaseResultList = new List<TestCaseResult>();
        //    //add test code solution
        //    var codeSolution1 = new TestCodeSolution()
        //    {
        //        Id = 1,
        //        TestAttendeeId = testAttendee.Id,
        //        QuestionId = questionId,
        //        Solution = answer.Code.Source,
        //        Language = answer.Code.Language,
        //        Score = 1
        //    };
        //    var codeSolution2 = new TestCodeSolution()
        //    {
        //        Id = 2,
        //        TestAttendeeId = testAttendee.Id,
        //        QuestionId = questionId,
        //        Solution = answer.Code.Source,
        //        Language = answer.Code.Language,
        //        Score = 0
        //    };
        //    await _trappistDbContext.TestCodeSolution.AddAsync(codeSolution1);
        //    await _trappistDbContext.TestCodeSolution.AddAsync(codeSolution2);
        //    await _trappistDbContext.SaveChangesAsync();
        //    //add test case result
        //    var testCaseResult1 = new TestCaseResult()
        //    {
        //        Id = 1,
        //        Processing = 180,
        //        Memory = 50,
        //        Output = "5",
        //        CodeSnippetQuestionTestCasesId = question.CodeSnippetQuestion.CodeSnippetQuestionTestCases[0].CodeSnippetQuestionId,
        //        TestCodeSolutionId = codeSolution1.Id
        //    };
        //    var testCaseResult2 = new TestCaseResult()
        //    {
        //        Id = 2,
        //        Processing = 190,
        //        Memory = 70,
        //        Output = "Hello World",
        //        CodeSnippetQuestionTestCasesId = question.CodeSnippetQuestion.CodeSnippetQuestionTestCases[0].CodeSnippetQuestionId,
        //        TestCodeSolutionId = codeSolution2.Id
        //    };
        //    await _trappistDbContext.TestCaseResult.AddAsync(testCaseResult1);
        //    await _trappistDbContext.TestCaseResult.AddAsync(testCaseResult2);
        //    await _trappistDbContext.SaveChangesAsync();
        //    testCaseResultList.Add(testCaseResult1);
        //    testCaseResultList.Add(testCaseResult2);
        //    codeSolution1.TestCaseResultCollection = testCaseResultList;
        //    codeSolution2.TestCaseResultCollection = testCaseResultList;
        //    var codeSnippetDetailsObject = await _reportRepository.GetCodeSnippetDetailsAsync(testAttendee.Id, questionId);
        //    Assert.Equal(2, codeSnippetDetailsObject.Count());
        //}
        #endregion

        #region Private Methods
        /// <summary>
        /// This method is used to create a test with the given testname
        /// </summary>
        /// <param name="testName">Name of the test that needs to be created</param>
        /// <returns>Returns the object of type Test</returns>
        private DomainModel.Models.Test.Test CreateTest(string testName)
        {
            var test = new DomainModel.Models.Test.Test
            {
                TestName       = testName,
                CorrectMarks   = 3,
                IncorrectMarks = 1
            };

            return(test);
        }