Ejemplo n.º 1
0
        public async Task Shoud_Get_EcartType_In_CandidateService(double ecartType)
        {
            var testModel = new List <TestModel>();

            testModel.Add(new TestModel("c#a", 1, 10));
            testModel.Add(new TestModel("c#b", 2, 10));
            testModel.Add(new TestModel("c#c", 3, 10));
            testModel.Add(new TestModel("c#d", 4, 10));

            var answers = new List <AnswerModel>();

            answers.Add(new AnswerModel(1, 1, "1", "a", 1));
            answers.Add(new AnswerModel(2, 2, "2", "b", 0));
            answers.Add(new AnswerModel(3, 3, "3", "c", 1));
            answers.Add(new AnswerModel(4, 4, "4", "d", 0));

            var results = new List <ResultModel>();

            results.Add(new ResultModel(1, true));
            results.Add(new ResultModel(2, false));
            results.Add(new ResultModel(3, true));
            results.Add(new ResultModel(4, false));

            var candidates = new List <Candidate>()
            {
                new Candidate("minamba", "camara", testModel[0], results),
                new Candidate("naruto", "uzumaki", testModel[1], results),
                new Candidate("sasuke", "uchiha", testModel[2], results),
                new Candidate("madara", "uchiha", testModel[3], results),
            };


            var mockRepository = Substitute.For <ICandidatesRepository>();
            var logger         = Substitute.For <ILog>();

            mockRepository.GetCandidatesAsync().Returns(candidates);
            mockRepository.GetTestsAsync().Returns(testModel);
            mockRepository.GetAnswersAsync().Returns(answers);

            var    candidateService = new CandidatesService(mockRepository, logger);
            double result           = await candidateService.GetEcartTypeAsync();

            Assert.AreEqual(ecartType, result);
        }