public async Task GetAssignmentProgressAsync_ReturnsUnsolvedPriorQuestions() { var database = GetDatabase().Build(); var userId = database.Context.Users.First().Id; var assignmentQuestion = database.Context .AssignmentQuestions .Single(aq => aq.Question.Name == "Question4"); database.Reload(); var assignmentProgressRetriever = new AssignmentProgressRetriever ( database.Context ); var result = await assignmentProgressRetriever.GetAssignmentProgressAsync ( assignmentQuestion.AssignmentId, assignmentQuestion.Id, userId ); var unsolvedPriorQuestions = result.GetUnsolvedPriorQuestions(); Assert.Equal(2, unsolvedPriorQuestions.Count); Assert.Equal("Question2", unsolvedPriorQuestions[0].AssignmentQuestionName); Assert.Equal("Question3", unsolvedPriorQuestions[1].AssignmentQuestionName); }
public async Task GetAssignmentProgressAsync_NotLastQuestion_ReturnsNextQuestion() { var database = GetDatabase().Build(); var userId = database.Context.Users.First().Id; var curQuestion = database.Context .AssignmentQuestions .Single(aq => aq.Question.Name == "Question4"); var nextQuestion = database.Context .AssignmentQuestions .Single(aq => aq.Question.Name == "Question5"); database.Reload(); var assignmentProgressRetriever = new AssignmentProgressRetriever ( database.Context ); var result = await assignmentProgressRetriever.GetAssignmentProgressAsync ( curQuestion.AssignmentId, curQuestion.Id, userId ); Assert.Equal(nextQuestion.Id, result.NextAssignmentQuestionId); }
public async Task GetAssignmentProgressAsync_ReturnsQuestionProgress() { var database = GetDatabase().Build(); var userId = database.Context.Users.First().Id; var curQuestion = database.Context .AssignmentQuestions .Single(aq => aq.Question.Name == "Question2"); var allQuestions = database.Context .AssignmentQuestions .OrderBy(aq => aq.Name) .ToList(); database.Reload(); var assignmentProgressRetriever = new AssignmentProgressRetriever ( database.Context ); var result = await assignmentProgressRetriever.GetAssignmentProgressAsync ( curQuestion.AssignmentId, curQuestion.Id, userId ); Assert.Equal(curQuestion.Id, result.CurrentAssignmentQuestionId); Assert.Equal(5, result.Questions.Count); var progress = result.Questions; Assert.Equal(allQuestions[0].Id, progress[0].AssignmentQuestionId); Assert.Equal("Question1", progress[0].AssignmentQuestionName); Assert.Equal(QuestionCompletion.Completed, progress[0].Completion); Assert.Equal(allQuestions[1].Id, progress[1].AssignmentQuestionId); Assert.Equal("Question2", progress[1].AssignmentQuestionName); Assert.Equal(QuestionCompletion.PartiallyCompleted, progress[1].Completion); Assert.Equal(allQuestions[2].Id, progress[2].AssignmentQuestionId); Assert.Equal("Question3", progress[2].AssignmentQuestionName); Assert.Equal(QuestionCompletion.NotCompleted, progress[2].Completion); Assert.Equal(allQuestions[3].Id, progress[3].AssignmentQuestionId); Assert.Equal("Question4", progress[3].AssignmentQuestionName); Assert.Equal(QuestionCompletion.NotCompleted, progress[3].Completion); Assert.Equal(allQuestions[4].Id, progress[4].AssignmentQuestionId); Assert.Equal("Question5", progress[4].AssignmentQuestionName); Assert.Equal(QuestionCompletion.NotCompleted, progress[4].Completion); }