public void HasReached_LessThan2Terminations_Exception() { var target = new OrTermination(); target.AddTermination(MockRepository.GenerateMock<ITermination>()); ExceptionAssert.IsThrowing(new InvalidOperationException("The OrTermination needs at least 2 terminations to perform. Please, add the missing terminations."), () => { target.HasReached(MockRepository.GenerateMock<IGeneticAlgorithm>()); }); }
public void HasReached_OnlyOneTerminationsHasReached_True() { var target = new OrTermination(); var ga = MockRepository.GenerateMock<IGeneticAlgorithm>(); var t1 = MockRepository.GenerateMock<ITermination>(); t1.Expect(t => t.HasReached(ga)).IgnoreArguments().Return(false); target.AddTermination(t1); var t2 = MockRepository.GenerateMock<ITermination>(); t2.Expect(t => t.HasReached(ga)).IgnoreArguments().Return(true); target.AddTermination(t2); var t3 = MockRepository.GenerateMock<ITermination>(); t3.Expect(t => t.HasReached(ga)).IgnoreArguments().Return(false); target.AddTermination(t3); Assert.IsTrue(target.HasReached(ga)); }