Пример #1
0
        private PlacementDescriptionMatch CalculateScore(StudentDetailsDTO student, PlacementDescriptionDetailsDTO description)
        {
            float score = 0;

            score += (float)student.KeywordNames.Where(k => description.KeywordNames.Contains(k)).Count() / 2f;
            score += student.MinSalary >= description.MinSalary ? 1 : 0;
            score += student.MinWorkingHours >= description.MinWorkingHours ? 1 : 0;
            score += student.MaxWorkingHours <= description.MaxWorkingHours ? 1 : 0;
            score += student.Agreement == description.Agreement ? 1 : 0;
            score += student.Location.Equals(description.Location) ? 1 : 0; // Primitive location matching

            return(new PlacementDescriptionMatch
            {
                MatchScore = score,
                Id = description.Id,
                Degree = description.Degree,
                KeywordNames = description.KeywordNames,
                MinSalary = description.MinSalary,
                MinWorkingHours = description.MinWorkingHours,
                MaxWorkingHours = description.MaxWorkingHours,
                Agreement = description.Agreement,
                Location = description.Location,
                LastApplyDate = description.LastApplyDate,
                Email = description.Email,
                Thumbnail = description.Thumbnail,
                Title = description.Title,
                Description = description.Description,
                CompanyName = description.CompanyName
            });
        }
        public async Task Get_given_id_returns_200_and_student()
        {
            var description = new PlacementDescriptionDetailsDTO {
                Id = 1, KeywordNames = new []   {
                    "UML"
                }, Degree = Degree.Bachelor, MinSalary = 100, MinWorkingHours = 5, MaxWorkingHours = 20, Agreement = false, Location = "Nowhere"
            };

            repository.Setup(r => r.GetPlacementDescriptionAsync(description.Id)).ReturnsAsync(description);
            var controller = new PlacementDescriptionRepositoryController(repository.Object);

            var actual = await controller.Get(1, true);

            var actionResult      = Assert.IsType <ActionResult <PlacementDescriptionDetailsDTO> >(actual);
            var okResult          = Assert.IsType <OkObjectResult>(actionResult.Result);
            var actualDescription = Assert.IsType <PlacementDescriptionDetailsDTO>(okResult.Value);

            Assert.Equal(200, okResult.StatusCode);
            Assert.Equal(description, actualDescription);
        }