47 lines
1.2 KiB
C#
47 lines
1.2 KiB
C#
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 = "" }));
|
|
}
|
|
}
|