public void TimeBudget_allows_cancellation() { var budget = new TimeBudget(30.Seconds()); budget.Cancel(); budget.IsExceeded.Should().BeTrue(); }
public async Task When_a_time_budget_is_canceled_before_expiration_then_the_elapsed_duration_at_cancellation_is_captured() { var budget = new TimeBudget(3.Seconds()); await Clock.Current.Wait(2.Seconds()); budget.Cancel(); await Clock.Current.Wait(2.Seconds()); budget.ElapsedDurationAtCancellation.Should().Be(2.Seconds()); }
public async Task When_a_time_budget_is_canceled_then_the_remaining_duration_is_zero() { var budget = new TimeBudget(3.Seconds()); await Clock.Current.Wait(2.Seconds()); budget.Cancel(); await Clock.Current.Wait(2.Seconds()); budget.RemainingDuration.Should().Be(TimeSpan.Zero); }
public async Task Adding_entries_after_cancellation_captures_elapsed_duration_relative_to_budget_start() { var budget = new TimeBudget(3.Seconds()); await Clock.Current.Wait(2.Seconds()); budget.Cancel(); await Clock.Current.Wait(2.Seconds()); budget.RecordEntry(); var lastEntry = budget.Entries.Last(); lastEntry.BudgetWasExceeded.Should().BeTrue(); lastEntry.ElapsedDuration.Should().Be(4.Seconds()); }