Closed TerezaSkutova closed 2 years ago
Hey, don't mind my simple joke above, your code looks well structured and there is not much to criticize. 😊
After lengthy consideration, I would change "QuestionSetList" to "QuestionSetListITem" since it's not the whole list but literally one item. We are picking names on a very small number of classes and that causes all these kinds of debates. With time, domain will consist of more items and it will make much more sense.
⚠️ Unit tests are failing(compilation issue) probably due to changes in return types. ⚠️ Coverage is lowered probably by the extension of existing methods. Look for uncovered lines, If you don't know how to address them we can work this out together through a pair programming session.
I am sorry for pipelines providing false positives, there is an issue with it and I hope it will be fixed soon. :)
Hey @TerezaSkutova, after investigation I found a couple of interesting facts.
Get_ValidRequest_ReturnsAllLists
- less visible in the pipeline log :( The root cause is in GetQuestionSetsUseCase.cs line 41
- repository returned empty list of questions. causes difficulty to be calculated as null and the code throws an exception.
Try this test :)
[Fact]
public async Task Execute_RepositoryReturnsNoQuestions_Ok()
{
var questionSetRepositoryMock = new Mock<IQuestionSetRepository>();
questionSetRepositoryMock.Setup(x => x.GetAll().Result).Returns(QuesionSets);
var questionRepositoryMock = new Mock<IQuestionRepository>();
var outputPortMock = new Mock<IOutputPort>();
outputPortMock.Setup(x => x.Ok(It.IsAny<IEnumerable<QuestionSetListItem>>()))
.Callback<IEnumerable<QuestionSetListItem>>(result => Assert.Equal(0, result.First().Difficulty.value));
var input = new GetQuestionSetsInput();
var useCase = new GetQuestionSetsUseCase(questionSetRepositoryMock.Object, questionRepositoryMock.Object);
useCase.SetOutputPort(outputPortMock.Object);
await useCase.Execute(input);
outputPortMock.Verify(x => x.Ok(It.IsAny<IEnumerable<QuestionSetListItem>>()), Times.Once());
outputPortMock.Verify(x => x.Invalid(), Times.Never());
outputPortMock.Verify(x => x.NotFound(), Times.Never());
}
Kudos, SonarCloud Quality Gate passed!
Summary
🚨 Provide a brief summary of your work.
Types of changes
Testing
🚨 Provide info about the new tests and tests result
Notes
🚨 QuestionSetModel is extended by Difficulty value object calculated in usecase.