3PillarGlobal-Czechia / interview-app-api

API for Interview App.
MIT License
3 stars 1 forks source link

Feature/question list difficulty #63

Closed TerezaSkutova closed 2 years ago

TerezaSkutova commented 2 years ago

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.

PlesnikJakub commented 2 years ago

image

PlesnikJakub commented 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. :)

PlesnikJakub commented 2 years ago

Failing tests issue

Hey @TerezaSkutova, after investigation I found a couple of interesting facts.

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.

PlesnikJakub commented 2 years ago

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());
    }
sonarcloud[bot] commented 2 years ago

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication