Exemple #1
0
        public void GenerateRandomSequence_GeneralFlow_RandomSequence(int from, int count)
        {
            // Arrange & Act
            var result = RandomUtils.GenerateRandomSequence(from, count);

            // Assert
            result.Should().BeEquivalentTo(Enumerable.Range(from, count));
            result.Should().NotBeInAscendingOrder();
            result.Should().NotBeInDescendingOrder();
        }
        private IList <StudentTestSessionQuestion> GenerateQuestions(TestSessionVariant variant)
        {
            IReadOnlyList <int> orderNumbers = new List <int>(0);

            if (variant.IsRandomOrder)
            {
                orderNumbers = RandomUtils.GenerateRandomSequence(1, variant.Questions.Count);
            }

            return(variant.Questions.Select((e, index) => new StudentTestSessionQuestion
            {
                QuestionId = e.Id,
                Order = variant.IsRandomOrder ? orderNumbers[index] : e.Order.Value,
                Answer = new StudentQuestionAnswer
                {
                    FreeTextAnswer = e.Type == QuestionType.FreeText ? new StudentFreeTextQuestionAnswer() : null,
                    AnswerAssessment = new QuestionAnswerAssessment
                    {
                        // TODO: do it in better way
                        AssessmentId = variant.TestSession.Assessment.Id,
                    },
                },
            }).ToList());
        }