public async Task Should_not_track_if_weight_less_than_zero() { await sut.TrackAsync("MyKey1", "MyCategory", -1, 1000); await sut.TrackAsync("MyKey1", "MyCategory", 0, 1000); sut.Next(); sut.Dispose(); A.CallTo(() => usageStore.TrackUsagesAsync(A <DateTime> .Ignored, A <string> .Ignored, A <string> .Ignored, A <double> .Ignored, A <double> .Ignored)).MustNotHaveHappened(); }
private async Task TrackAsync() { try { var today = DateTime.Today; var localUsages = Interlocked.Exchange(ref usages, new ConcurrentDictionary <string, Usage>()); await Task.WhenAll(localUsages.Select(x => usageStore.TrackUsagesAsync( today, x.Key, x.Value.Count, x.Value.ElapsedMs))); } catch (Exception ex) { log.LogError(ex, w => w .WriteProperty("action", "TrackUsage") .WriteProperty("status", "Failed")); } }