private ILongCounter[] CreateCounters()
 {
     var values = Enum.GetValues(typeof(CounterMetric));
     var counters = new ILongCounter[values.Length];
     foreach (var value in values)
     {
         counters[(int)value] = new InterlockingLongCounter();
     }
     return counters;
 }
        private ILongCounter[] CreateCounters()
        {
            var values   = Enum.GetValues(typeof(CounterMetric));
            var counters = new ILongCounter[values.Length];

            foreach (var value in values)
            {
                counters[(int)value] = new InterlockingLongCounter();
            }
            return(counters);
        }
        public void Stress_Increment_RetainsAccuracy()
        {
            const int iterations = 100000;
            var counter = new InterlockingLongCounter();
            var tasks = new List<Task>();
            for (var i = 0; i < iterations; i++)
            {
                var task = Task.Run(() => counter.Increment());
                tasks.Add(task);
            }

            Task.WaitAll(tasks.ToArray());
            Assert.Equal(iterations, counter.Get());
        }
 public void Increment_Increments()
 {
     var counter = new InterlockingLongCounter();
     counter.Increment();
     Assert.Equal(1, counter.Get());
 }