public void Hysteresis_is_uninitialized_after_construction() { var hysteresis = new Hysteresis(range: 7, phaseCount: 5); Expect(hysteresis.IsInitialized, Is.False); Expect(hysteresis.Phase, Is.Null); }
public void Update_of_large_magnitude_affects_phase([Values(0, 1)] int phase) { var hysteresis = new Hysteresis(range: 1, phaseCount: 2); hysteresis.Initialize(phase); hysteresis.Update(1 - phase, magnitude: 0.7); Expect(hysteresis.Phase, Is.EqualTo(1 - phase)); }
public void Strong_update_towards_middle_phase_doesnt_overshoot_to_far_phase([Values(0, 2)] int phase) { var hysteresis = new Hysteresis(range: 1, phaseCount: 3); hysteresis.Initialize(phase); hysteresis.Update(phase: 1, magnitude: 1); Expect(hysteresis.Phase, Is.EqualTo(1)); }
public void Two_opposite_updates_return_old_phase_when_second_update_magnitude_is_large([Values(0, 1)] int phase) { var hysteresis = new Hysteresis(range: 1, phaseCount: 2); hysteresis.Initialize(phase); hysteresis.Update(1 - phase, magnitude: 0.7); hysteresis.Update(phase, magnitude: 0.4); Expect(hysteresis.Phase, Is.EqualTo(phase)); }
public void Hysteresis_is_initialized_to_specified_phase_after_initialization() { var phase = 3; var hysteresis = new Hysteresis(range: 7, phaseCount: 5); hysteresis.Initialize(phase); Expect(hysteresis.IsInitialized, Is.True); Expect(hysteresis.Phase, Is.EqualTo(phase)); }
public void Strong_reverse_update_after_two_strong_direct_updates_reverts_phase([Values(0, 1)] int phase) { var hysteresis = new Hysteresis(range: 1, phaseCount: 2); hysteresis.Initialize(phase: 0); hysteresis.Update(1 - phase, magnitude: 0.7); hysteresis.Update(1 - phase, magnitude: 0.7); hysteresis.Update(phase, magnitude: 0.7); Expect(hysteresis.Phase, Is.EqualTo(phase)); }
public void Two_small_magnitude_updates_accumulate_to_a_phase_transition([Values(0, 1)] int phase) { var hysteresis = new Hysteresis(range: 1, phaseCount: 2); hysteresis.Initialize(phase); hysteresis.Update(1 - phase, magnitude: 0.4); Expect(hysteresis.Phase, Is.EqualTo(phase)); hysteresis.Update(1 - phase, magnitude: 0.3); Expect(hysteresis.Phase, Is.EqualTo(1 - phase)); }
public void Updating_towards_the_present_state_sets_state_to_equilibrium_which_is_not_enough_to_prevent_subsequent_phase_transition([Values(0, 2)] int phase) { var hysteresis = new Hysteresis(range: 1, phaseCount: 3); hysteresis.Initialize(phase); hysteresis.Update(phase: 1, magnitude: 0.6); Expect(hysteresis.Phase, Is.EqualTo(1)); hysteresis.Update(2 - phase, magnitude: 0.2); Expect(hysteresis.Phase, Is.EqualTo(1)); hysteresis.Update(phase: 1, magnitude: 0.3); Expect(hysteresis.Phase, Is.EqualTo(1)); hysteresis.Update(2 - phase, magnitude: 0.3); Expect(hysteresis.Phase, Is.EqualTo(2 - phase)); }