コード例 #1
0
        public void Run_WithChromsomeMatchingTerminationCriteria_CallsRightMethods()
        {
            var deploymentModel = CreateDeploymentModel();

            A.CallTo(() => _terminationCondition.HasReached(null, null)).WithAnyArguments().Returns(true);
            ConstructGeneticAlgorithm();

            var bestDeploymentModel = _testGeneticAlgorithm.Run(deploymentModel);

            A.CallTo(() => _deploymentChromosomeFactory.Create(deploymentModel)).MustHaveHappened(Repeated.Exactly.Once);
            A.CallTo(() => _initialPopulationCreator.CreateInitialPopulation(null, 0, 0)).WithAnyArguments().MustHaveHappened(Repeated.Exactly.Once);

            A.CallTo(() => _mutationOperator.Mutate(null)).WithAnyArguments().MustNotHaveHappened();
            A.CallTo(() => _crossoverOperator.Cross(null)).WithAnyArguments().MustNotHaveHappened();
            A.CallTo(() => _selectionStrategy.SelectChromosomes(0, null)).WithAnyArguments().MustNotHaveHappened();
            A.CallTo(() => _reinsertionStrategy.Reinsert(null, null)).WithAnyArguments().MustNotHaveHappened();

            Assert.AreEqual(0, _currentState.Count);
        }
コード例 #2
0
        protected bool IsTerminationConditionReached()
        {
            if (_terminationCondition.HasReached(this))
            {
                RaiseTerminated(_terminationCondition.Description);
                return(true);
            }

            return(false);
        }