Exemplo n.º 1
0
                public void CorrigerQuestions_QuestionnaireEffectueFluentAssertion_SommePoints()
                 {
                        // Arranger
                        Mock <IQuestion>  mockQuestion1Point  =  new Mock <IQuestion>();

                        mockQuestion1Point.Setup(q  =>  q.CorrigerReponse()).Returns(1);
                        Mock <IQuestion>  mockQuestion2Point  =  new Mock <IQuestion>();

                        mockQuestion2Point.Setup(q  =>  q.CorrigerReponse()).Returns(2);
                        Mock <IQuestion>  mockQuestion3Point  =  new Mock <IQuestion>();

                        mockQuestion3Point.Setup(q  =>  q.CorrigerReponse()).Returns(4);

                        List <IQuestion>  questions  =  new List <IQuestion>()
                                                                    {
                                mockQuestion1Point.Object,
                                mockQuestion2Point.Object,
                                mockQuestion3Point.Object
                            
            };

                        Questionnaire questionnaire  =  new Questionnaire(questions);
                        int scoreCalculeAttendu      =  7;

                        // Agir
                        questionnaire.CorrigerQuestions();

                        // Assert
                        questionnaire.Score.Should().Be(scoreCalculeAttendu);

                        mockQuestion1Point.Verify(q  =>  q.CorrigerReponse(),  Times.Once);
                        mockQuestion1Point.VerifyNoOtherCalls();

                        mockQuestion2Point.Verify(q  =>  q.CorrigerReponse(),  Times.Once);
                        mockQuestion2Point.VerifyNoOtherCalls();

                        mockQuestion3Point.Verify(q  =>  q.CorrigerReponse(),  Times.Once);
                        mockQuestion3Point.VerifyNoOtherCalls();

                    
        }
Exemplo n.º 2
0
        public void CorrigerQuestions_QuestionnaireEffectueFluentAssertion_SommePoints()
        {
            // Arranger
            Mock <IQuestion> mockQuestion1Point = new Mock <IQuestion>();

            mockQuestion1Point.Setup(q => q.CorrigerReponse()).Returns(1);
            Mock <IQuestion> mockQuestion2Point = new Mock <IQuestion>();

            mockQuestion2Point.Setup(q => q.CorrigerReponse()).Returns(2);
            Mock <IQuestion> mockQuestion3Point = new Mock <IQuestion>();

            mockQuestion3Point.Setup(q => q.CorrigerReponse()).Returns(4);

            List <IQuestion> questions = new List <IQuestion>()
            {
                mockQuestion1Point.Object,
                mockQuestion2Point.Object,
                mockQuestion3Point.Object
            };
            Questionnaire questionnaire       = new Questionnaire(questions);
            int           scoreCalculeAttendu = 7;

            // Agir
            questionnaire.CorrigerQuestions();

            // Assert
            questionnaire.Score.Should().Be(scoreCalculeAttendu);
            mockQuestion1Point.Verify(q => q.CorrigerReponse(), Times.Once);
            mockQuestion1Point.VerifyNoOtherCalls();

            mockQuestion2Point.Verify(q => q.CorrigerReponse(), Times.Once);
            mockQuestion2Point.VerifyNoOtherCalls();

            mockQuestion3Point.Verify(q => q.CorrigerReponse(), Times.Once);
            mockQuestion3Point.VerifyNoOtherCalls();
        }