src/GenFx.Components.Tests/TimeDurationTerminatorTest.cs
/// <summary>
/// Tests that the IsComplete method works correctly.
/// </summary>
Tests that the IsComplete method works correctly.
Tests that the IsComplete method works correctly .
[Fact]
        public void TimeDurationTerminator_IsComplete()
        {
            TimeSpan timeLimit = new TimeSpan(0, 1, 0);
            GeneticAlgorithm algorithm = GetAlgorithm(timeLimit);
            TimeDurationTerminator terminator = new TimeDurationTerminator { TimeLimit = timeLimit };
            terminator.Initialize(algorithm);
            PrivateObject algorithmAccessor = new PrivateObject(algorithm, new PrivateType(typeof(GeneticAlgorithm)));
            algorithmAccessor.Invoke("OnAlgorithmStarting");
            Assert.False(terminator.IsComplete(), "Time limit has not been reached.");
            PrivateObject accessor = new PrivateObject(terminator);
            accessor.SetField("timeStarted", DateTime.Now - new TimeSpan(0, 1, 1));
            Assert.True(terminator.IsComplete(), "Time limit has been reached.");
        }
[ Fact ] public void TimeDurationTerminator_IsComplete ( ) { TimeSpan timeLimit = new TimeSpan ( 0 , 1 , 0 ) ; GeneticAlgorithm algorithm = GetAlgorithm ( timeLimit ) ; TimeDurationTerminator terminator = new TimeDurationTerminator { TimeLimit = timeLimit } ; terminator . Initialize ( algorithm ) ; PrivateObject algorithmAccessor = new PrivateObject ( algorithm , new PrivateType ( typeof ( GeneticAlgorithm ) ) ) ; algorithmAccessor . Invoke ( " " ) ; Assert . False ( terminator . IsComplete ( ) , " " ) ; PrivateObject accessor = new PrivateObject ( terminator ) ; accessor . SetField ( " " , DateTime . Now - new TimeSpan ( 0 , 1 , 1 ) ) ; Assert . True ( terminator . IsComplete ( ) , " " ) ; }
Tests that the IsComplete method works correctly.
Tests that the IsComplete method works correctly .
// "Start" the algorithm to trigger the start time // Make the start time earlier than it really was to simulate passed time.