コード例 #1
0
 public void DistributedCounterInitialCountIsAsIndicated()
 {
     using (var storage = new RedisStorage(Host))
     {
         var id = Guid.NewGuid().ToString();
         var counter = new DistributedCounter(storage, id, 18);
         counter.GetValue().ShouldBe(18);
     }
 }
コード例 #2
0
 public void DistributedCounterSharesStateBetweenInstancesWithTheSameId()
 {
     using(var storage = new RedisStorage(Host))
     {
         var id = Guid.NewGuid().ToString();
         var counter1 = new DistributedCounter(storage, id);
         var counter2 = new DistributedCounter(storage, id);
         counter1.SetValue(23);
         counter2.GetValue().ShouldBe(23);
         counter2.Decrease(1);
         counter1.GetValue().ShouldBe(22);
     }
 }