/// <summary>
        /// Evaluates test completed by user.
        /// </summary>
        /// <param name="completedTest"> Test completed by user.</param>
        /// <returns> TestResult instance.</returns>
        /// <exception> System.ArgumentNullException if completedTest is null.</exception>
        public BllTestResult EvaluateTest(BllCompletedTest completedTest)
        {
            if (completedTest == null)
            {
                throw new ArgumentNullException(nameof(completedTest));
            }
            int numberOfCorrectAnswers = 0;

            foreach (var question in completedTest.Test.Questions)
            {
                int count = 0;
                foreach (var answer in question.CorrectAnswers)
                {
                    if (completedTest.ChoosenAnswers.Select(a => a.Id).Contains(answer.Id))
                    {
                        count++;
                    }
                }
                if (count == question.CorrectAnswers.Count())
                {
                    numberOfCorrectAnswers++;
                }
            }

            var testResult = new BllTestResult
            {
                DateTime  = DateTime.Now,
                Grade     = GradeTest(numberOfCorrectAnswers, completedTest.Test.Questions.Count),
                TimeSpent = completedTest.TimeSpent,
                UserId    = completedTest.UserId,
                Test      = completedTest.Test
            };

            repository.Create(testResult.ToDalTestResult());
            service.Save();
            return(testResult);
        }
 /// <summary>
 /// Deletes test results
 /// </summary>
 /// <param name="entity">Test result</param>
 public void Delete(BllTestResult entity)
 {
     testResultRepository.Delete(entity.ToDalTestResult());
     unitOfWork.Commit();
 }