Esempio n. 1
0
        public void Terminator_Ctor()
        {
            GeneticAlgorithm algorithm = new MockGeneticAlgorithm
            {
                GeneticEntitySeed = new MockEntity(),
                PopulationSeed    = new MockPopulation(),
                SelectionOperator = new MockSelectionOperator(),
                FitnessEvaluator  = new MockFitnessEvaluator(),
                Terminator        = new MockTerminator()
            };
            MockTerminator terminator = new MockTerminator();

            terminator.Initialize(algorithm);
            PrivateObject accessor = new PrivateObject(terminator, new PrivateType(typeof(Terminator)));

            Assert.Same(algorithm, accessor.GetProperty("Algorithm"));
        }
        public void RequiredComponentTypeValidator_IsValid_WithNonAlgorithmComponent()
        {
            MockGeneticAlgorithm algorithm = new MockGeneticAlgorithm();

            CustomValidator validator = new CustomValidator(typeof(MockEntity), typeof(GeneticEntity))
            {
                HasRequiredComponentReturnValue = true,
                ExpectedGeneticAlgorithm        = algorithm
            };

            MockTerminator terminator = new MockTerminator();

            terminator.Initialize(algorithm);

            bool result = validator.IsValid(terminator, out string errorMessage);

            Assert.True(result);
            Assert.Null(errorMessage);
        }
Esempio n. 3
0
        public void Terminator_Ctor_NullAlgorithm()
        {
            MockTerminator terminator = new MockTerminator();

            Assert.Throws <ArgumentNullException>(() => terminator.Initialize(null));
        }