Example #1
0
        public void GetCorrectListOfNames_and_result_is_cached()
        {
            //Arrange
            var answer = new List <string> {
                "Русский", "Математика", "Информатика"
            };

            var queryBuilder = Substitute.For <IQueryBuilder>();

            queryBuilder
            .For <IEnumerable <string> >()
            .With(Arg.Any <GetEducationCharacterisitcNamesCriterion>()).ReturnsForAnyArgs(answer);

            queryBuilder.ClearReceivedCalls();

            //Act
            var helper = new EducationCharacteristicNamesHelper(queryBuilder);
            var result = helper.Names;

            //Assert
            Assert.AreEqual(answer, result);
            //cache test
            queryBuilder.Received(1).For <IEnumerable <string> >();
        }
Example #2
0
        //Критерий совпадения кластеров - заполнение направлений во временный список
        private async Task InitialiseSecondCriterion()
        {
            var totalAvailLines = 0;
            var queryBuilder    = new QueryBuilder();
            var educationCharacteristicNamesHelper = new EducationCharacteristicNamesHelper(queryBuilder);
            var entrantSummator      = new EntrantSummator(educationCharacteristicNamesHelper);
            var entrantCharacterizer = new EntrantCharacterizer(educationCharacteristicNamesHelper, entrantSummator,
                                                                new IdealEntrantResult(entrantSummator, queryBuilder));

            _entrantCharacteristics = await entrantCharacterizer.Calculate(_entrant);

            _maxEntrantClusterSum = _entrantCharacteristics.Values.Max();
            var educationLineSummator = new EducationLineSummator(educationCharacteristicNamesHelper);
            var edLineClusterizer     = new EducationLineCharacterizer(educationCharacteristicNamesHelper,
                                                                       educationLineSummator, new IdealEducationLineResult(educationLineSummator, queryBuilder));

            foreach (var edLine in _educationLines)
            {
                var edLineAcceptable = true;

                var edLineResult = await edLineClusterizer.Calculate(edLine);

                if (!edLineResult.Any())
                {
                    edLineAcceptable = false;
                }

                foreach (var item in edLineResult)
                {
                    if (!_entrantCharacteristics.ContainsKey(item.Key))
                    {
                        edLineAcceptable = false;
                    }
                }

                if (edLineAcceptable == false)
                {
                    var educationLine = new SecondCriterionUnit();
                    educationLine.DatabaseId = Convert.ToInt32(edLine.Id);
                    educationLine.SecondCriterionAcceptable = false;
                    educationLine.LocalPriority             = 0;

                    _secondCriterionContainer.Add(educationLine);
                }
                else
                {
                    var educationLine = new SecondCriterionUnit();
                    educationLine.DatabaseId = Convert.ToInt32(edLine.Id);
                    educationLine.SecondCriterionAcceptable = true;
                    educationLine.MatrixId = totalAvailLines;
                    educationLine.EducationLineClusters = edLineResult;
                    educationLine.LocalPriority         = 0;

                    totalAvailLines++;

                    _secondCriterionContainer.Add(educationLine);
                }
            }
            _secondCriterionMatrixSize = totalAvailLines;

            if (_secondCriterionContainer.Count > _totalEducationLines)
            {
                _totalEducationLines = _secondCriterionContainer.Count;
            }
        }
Example #3
0
        //Критерий совпадения кластеров - заполнение направлений во временный список
        private async void InitialiseSecondCriterion()
        {
            var totalAvailLines = 0;
            var queryBuilder    = new QueryBuilder();
            var educationCharacteristicNamesHelper = new EducationCharacteristicNamesHelper(queryBuilder);
            var educationLineSummator = new EducationLineSummator(educationCharacteristicNamesHelper);
            var edLineClusterizer     = new EducationLineCharacterizer(educationCharacteristicNamesHelper,
                                                                       educationLineSummator, new IdealEducationLineResult(educationLineSummator, queryBuilder));

            _educationLineClusters = await edLineClusterizer.Calculate(_educationLine);

            _maxEdLineClusterSum = _educationLineClusters.Values.Max();

            var entrantSummator      = new EntrantSummator(educationCharacteristicNamesHelper);
            var entrantCharacterizer = new EntrantCharacterizer(educationCharacteristicNamesHelper, entrantSummator,
                                                                new IdealEntrantResult(entrantSummator, queryBuilder));

            foreach (var entrant in _entrants)
            {
                var userAcceptable = true;

                var entrantCharacteristics = await entrantCharacterizer.Calculate(entrant);

                if (!entrantCharacteristics.Any())
                {
                    userAcceptable = false;
                }

                foreach (var item in _educationLineClusters)
                {
                    if (!entrantCharacteristics.ContainsKey(item.Key))
                    {
                        userAcceptable = false;
                    }
                }

                if (userAcceptable == false)
                {
                    var entant = new SecondCriterionUnit
                    {
                        DatabaseId = Convert.ToInt32(entrant.Id),
                        SecondCriterionAcceptable = false,
                        LocalPriority             = 0
                    };

                    _secondCriterionContainer.Add(entant);
                }
                else
                {
                    var entant = new SecondCriterionUnit();
                    entant.DatabaseId = Convert.ToInt32(entrant.Id);
                    entant.SecondCriterionAcceptable = true;
                    entant.MatrixId        = totalAvailLines;
                    entant.EntrantClusters = entrantCharacteristics;
                    entant.LocalPriority   = 0;

                    totalAvailLines++;

                    _secondCriterionContainer.Add(entant);
                }
            }
            _secondCriterionMatrixSize = totalAvailLines;
        }