Skip to content

Commit

Permalink
Cleanup fault injection
Browse files Browse the repository at this point in the history
  • Loading branch information
mads256h committed Jan 27, 2025
1 parent 0818cd0 commit 141caf0
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,22 @@ namespace Maes.FaultInjections.DestroyRobots
public class DestroyRobotsAtSpecificTickFaultInjection : DestroyRobotBaseFaultInjection
{
private readonly int[] _destroyAtTicks;
private readonly int _currentNumberOfDestroys;
private int _index;

/// <summary>
/// Constructor for DestroyRobotsAtSpecificTickFaultInjection.
/// </summary>
/// <param name="seed">Seed for the random number generator.</param>
/// <param name="destroyAtTicks">Array of ticks at whihch robots should be destroyed.</param>
public DestroyRobotsAtSpecificTickFaultInjection(int seed, int[] destroyAtTicks) : base(seed)
/// <param name="destroyAtTicks">Ticks at which robots should be destroyed.</param>
public DestroyRobotsAtSpecificTickFaultInjection(int seed, params int[] destroyAtTicks) : base(seed)
{
_destroyAtTicks = destroyAtTicks;
Array.Sort(_destroyAtTicks);
_currentNumberOfDestroys = destroyAtTicks.Length;
}

protected override bool ShouldDestroy(int logicTick)
{
if (_index < _currentNumberOfDestroys && logicTick == _destroyAtTicks[_index])
if (_index < _destroyAtTicks.Length && logicTick == _destroyAtTicks[_index])
{
_index++;
return true;
Expand Down

0 comments on commit 141caf0

Please sign in to comment.