public static async Task CanRecordStatInAsyncAction() { var publisher = new FakeStatsPublisher(); await publisher.Time("statOverAsyncAction", async t => await DelayAsync()); PublisherAssertions.SingleStatNameIs(publisher, "statOverAsyncAction"); }
public static async Task CanRecordStatInAsyncFunction() { var publisher = new FakeStatsPublisher(); var answer = await publisher.Time("statOverAsyncFunc", async t => await DelayedAnswerAsync()); answer.ShouldBe(42); PublisherAssertions.SingleStatNameIs(publisher, "statOverAsyncFunc"); }
public static void CanRecordStatInFunction() { var publisher = new FakeStatsPublisher(); var answer = publisher.Time("statOverFunc", t => DelayedAnswer()); answer.ShouldBe(42); PublisherAssertions.SingleStatNameIs(publisher, "statOverFunc"); PublisherAssertions.LastDurationIs(publisher, TimingConstants.DelayMilliseconds); }
public static void CanRecordStatInAction() { var publisher = new FakeStatsPublisher(); publisher.Time("statOverAction", t => Delay()); PublisherAssertions.SingleStatNameIs(publisher, "statOverAction"); PublisherAssertions.LastDurationIs(publisher, TimingConstants.DelayMilliseconds); }
public static void DefaultIsToKeepStatName() { var publisher = new FakeStatsPublisher(); using (var timer = publisher.StartTimer("initialStat")) { Delay(); } PublisherAssertions.SingleStatNameIs(publisher, "initialStat"); }
public static void StatNameCanBeAppended() { var publisher = new FakeStatsPublisher(); using (var timer = publisher.StartTimer("Some.")) { Delay(); timer.StatName += "More"; } PublisherAssertions.SingleStatNameIs(publisher, "Some.More"); }
public static void CanChangeStatNameDuringOperation() { var publisher = new FakeStatsPublisher(); using (var timer = publisher.StartTimer("initialStat")) { Delay(); timer.StatName = "changedValue"; } PublisherAssertions.SingleStatNameIs(publisher, "changedValue"); }
public static async Task CanRecordStatAsync() { var publisher = new FakeStatsPublisher(); using (publisher.StartTimer("statWithAsync")) { await DelayAsync(); } PublisherAssertions.SingleStatNameIs(publisher, "statWithAsync"); PublisherAssertions.LastDurationIs(publisher, TimingConstants.DelayMilliseconds); }
public static async Task CanChangeStatNameInAsyncFunction() { var publisher = new FakeStatsPublisher(); await publisher.Time("defaultName", async t => { var result = await DelayedAnswerAsync(); t.StatName = "afterTheAwait"; return(result); }); PublisherAssertions.SingleStatNameIs(publisher, "afterTheAwait"); }
public static void CanRecordStat() { var publisher = new FakeStatsPublisher(); using (publisher.StartTimer("stat")) { Delay(); } PublisherAssertions.SingleStatNameIs(publisher, "stat"); PublisherAssertions.LastDurationIs(publisher, TimingConstants.DelayMilliseconds); }
public static void CanChangeStatName() { var publisher = new FakeStatsPublisher(); using (var timer = publisher.StartTimer("defaultName")) { Delay(); timer.StatName = "otherStat"; } PublisherAssertions.SingleStatNameIs(publisher, "otherStat"); PublisherAssertions.LastDurationIs(publisher, TimingConstants.DelayMilliseconds); }
public static void CanChangeStatNameInAction() { var publisher = new FakeStatsPublisher(); publisher.Time("defaultName", t => { Delay(); t.StatName = "otherStat"; }); PublisherAssertions.SingleStatNameIs(publisher, "otherStat"); PublisherAssertions.LastDurationIs(publisher, TimingConstants.DelayMilliseconds); }
public static void StatNameIsInitialValueWhenExceptionIsThrown() { var publisher = new FakeStatsPublisher(); var failCount = 0; try { using (var timer = publisher.StartTimer("initialStat")) { Fail(); timer.StatName = "changedValue"; } } catch (Exception) { failCount++; } failCount.ShouldBe(1); PublisherAssertions.SingleStatNameIs(publisher, "initialStat"); }
public static void StatNameIsInitialValueWhenExceptionIsThrown() { var publisher = new FakeStatsPublisher(); var failCount = 0; try { using var timer = publisher.StartTimer("initialStat"); Fail(); timer.Bucket = "changedValue"; } #pragma warning disable CA1031 catch (InvalidOperationException) #pragma warning restore CA1031 { failCount++; } failCount.ShouldBe(1); PublisherAssertions.SingleStatNameIs(publisher, "initialStat"); }