/// <summary> /// Updates this instance based on the values in <paramref name="newDuration"/>. /// If this instance is not enabled then all values will be replaced with those /// in <paramref name="newDuration"/>. /// </summary> /// <param name="newDuration">The duration containing updated values to copy from.</param> public void Update(RandomizedExecutionDuration newDuration) { // if duration not enabled, then there is nothing to update if (newDuration == null || !newDuration.IsEnabled()) { return; } if (!Enabled) { // If this duration is disabled, then we should update // all values Enabled = true; MinInMilliseconds = newDuration.MinInMilliseconds.Value; MaxInMilliseconds = newDuration.MaxInMilliseconds.Value; } if (newDuration.MinInMilliseconds > (MinInMilliseconds ?? 0)) { MinInMilliseconds = newDuration.MinInMilliseconds.Value; } if (newDuration.MaxInMilliseconds > (MaxInMilliseconds ?? 0)) { MaxInMilliseconds = newDuration.MaxInMilliseconds.Value; } }
public ExecutionDurationRandomizerScope( ExecutionDurationRandomizerSettings executionDurationRandomizerSettings, RandomizedExecutionDuration duration ) : this(executionDurationRandomizerSettings) { UpdateDuration(duration); _stopwatch = new Stopwatch(); _stopwatch.Start(); }
public void UpdateDuration(RandomizedExecutionDuration newDuration) { if (newDuration == null || !newDuration.IsEnabled()) { return; } var updatedDuration = Duration == null ? new RandomizedExecutionDuration() : Duration.Clone(); updatedDuration.Update(newDuration); Duration = updatedDuration; }