Implement persistent review queue
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
using QuestionsApi.Models;
|
||||
using QuestionsApi.Services;
|
||||
using Xunit;
|
||||
|
||||
namespace QuestionsApi.Tests;
|
||||
|
||||
public sealed class ReviewQueueTests
|
||||
{
|
||||
[Fact]
|
||||
public void SubmittedWrongFirstAttemptEntersQueue()
|
||||
{
|
||||
var attempt = new QuestionAttempt
|
||||
{
|
||||
UserId = "user-1",
|
||||
QuestionExternalId = "question-1",
|
||||
ChoiceId = "B",
|
||||
IsCorrect = false,
|
||||
IsSkip = false
|
||||
};
|
||||
|
||||
Assert.True(ReviewQueueStore.ShouldQueue(attempt));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(true, false)]
|
||||
[InlineData(false, true)]
|
||||
public void CorrectAndSkippedFirstAttemptsDoNotEnterQueue(bool isCorrect, bool isSkip)
|
||||
{
|
||||
var attempt = new QuestionAttempt
|
||||
{
|
||||
UserId = "user-1",
|
||||
QuestionExternalId = "question-1",
|
||||
IsCorrect = isCorrect,
|
||||
IsSkip = isSkip
|
||||
};
|
||||
|
||||
Assert.False(ReviewQueueStore.ShouldQueue(attempt));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void QueueRequiresUserAndQuestionIdentity()
|
||||
{
|
||||
Assert.False(ReviewQueueStore.ShouldQueue(new QuestionAttempt { UserId = "", QuestionExternalId = "question-1" }));
|
||||
Assert.False(ReviewQueueStore.ShouldQueue(new QuestionAttempt { UserId = "user-1", QuestionExternalId = "" }));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user