コード例 #1
0
        public void TestIsValidComponentsAreMissing()
        {
            ClimberConfiguration <TestIntegerEvaluableState, int> config = ClimberConfiguration <TestIntegerEvaluableState, int> .Create();


            Assert.IsNotNull(config);
            Assert.IsFalse(config.IsValid());
        }
コード例 #2
0
        public void TestCreateFromConfigurationWithDefinedDirection()
        {
            ClimberConfiguration <TestIntegerEvaluableState, int> config = ClimberConfiguration <TestIntegerEvaluableState, int> .Create()
                                                                           .GeneratesSuccessorsWith(generator)
                                                                           .ClimbsInDirection(ClimberDirection.Maximize);

            Assert.IsNotNull(config);
            Assert.IsTrue(config.IsValid());
        }
コード例 #3
0
        public void TestCreateFromConfigurationWithCustomComparer()
        {
            IComparer <TestIntegerEvaluableState> comparer = new MinimizingComparer <TestIntegerEvaluableState>();
            ClimberConfiguration <TestIntegerEvaluableState, int> config = ClimberConfiguration <TestIntegerEvaluableState, int> .Create()
                                                                           .GeneratesSuccessorsWith(generator)
                                                                           .ComparesUsing(comparer);

            Assert.IsNotNull(config);
            Assert.IsTrue(config.IsValid());
        }
コード例 #4
0
        public void TestCreateFromConfigurationWithDefaults()
        {
            ClimberConfiguration <TestIntegerEvaluableState, int> config = ClimberConfiguration <TestIntegerEvaluableState, int> .Create()
                                                                           .GeneratesSuccessorsWith(generator);

            IComparer <TestIntegerEvaluableState> expectedComparer = new MaximizingComparer <TestIntegerEvaluableState>();

            Assert.IsNotNull(config);
            Assert.IsTrue(config.IsValid());
        }
コード例 #5
0
        public void TestBuildCreatesClimberWhenValid()
        {
            IComparer <TestIntegerEvaluableState> comparer = new MinimizingComparer <TestIntegerEvaluableState>();
            ClimberConfiguration <TestIntegerEvaluableState, int> config = ClimberConfiguration <TestIntegerEvaluableState, int> .Create()
                                                                           .GeneratesSuccessorsWith(generator)
                                                                           .ComparesUsing(comparer);

            IHillClimber <TestIntegerEvaluableState, int> climber = null;

            try
            {
                climber = config.Build();
            }
            catch
            {
                Assert.Fail("Build threw an exception");
            }

            Assert.IsNotNull(climber);
        }
コード例 #6
0
        public void TestBuildThrowsCorrectExceptionWhenInvalid()
        {
            IComparer <TestIntegerEvaluableState> comparer = new MinimizingComparer <TestIntegerEvaluableState>();
            ClimberConfiguration <TestIntegerEvaluableState, int> config = ClimberConfiguration <TestIntegerEvaluableState, int> .Create();

            IHillClimber <TestIntegerEvaluableState, int> climber = null;

            bool caught = false;

            try
            {
                climber = config.Build();
            }
            catch (ConfigurationException)
            {
                caught = true;
            }

            Assert.IsTrue(caught);
            Assert.IsNull(climber);
        }