Пример #1
0
        public async Task TimeBudget_ToString_does_not_change_when_time_passes_but_no_new_entries_are_added()
        {
            var budget = new TimeBudget(2.Seconds());

            await Clock.Current.Wait(1.Seconds());

            budget.RecordEntry();

            var stringAt1Second = budget.ToString();

            await Clock.Current.Wait(2.Seconds());

            var stringAt1Minute = budget.ToString();

            stringAt1Minute.Should().Be(stringAt1Second);
        }
Пример #2
0
        public async Task TimeBudget_ToString_describes_entries()
        {
            var budget = new TimeBudget(5.Seconds());

            await Clock.Current.Wait(1.Seconds());

            budget.RecordEntry("one");

            await Clock.Current.Wait(10.Seconds());

            budget.RecordEntry("two");

            budget.ToString()
            .Should()
            .Be($"TimeBudget: 5 seconds{NewLine}  ✔ one @ 1.00 seconds{NewLine}  ❌ two @ 11.00 seconds (budget of 5 seconds exceeded by 6.00 seconds.)");
        }
Пример #3
0
        public async Task TimeBudget_ToString_truncates_durations_for_readability()
        {
            var budget = new TimeBudget(5.Seconds());

            await Clock.Current.Wait(TimeSpan.FromMilliseconds(1010.235));

            budget.RecordEntry("one");

            await Clock.Current.Wait(10.Seconds());

            await Clock.Current.Wait(TimeSpan.FromMilliseconds(1100.052));

            budget.RecordEntry("two");

            budget.ToString()
            .Should()
            .Be($"TimeBudget: 5 seconds{NewLine}  ✔ one @ 1.01 seconds{NewLine}  ❌ two @ 12.11 seconds (budget of 5 seconds exceeded by 7.11 seconds.)");
        }