public void TrafficTicketsCounterFetchAndUpdate() { var fetchCounterOptions = new FetchCounterOptions("counters", "counters", "traffic_tickts"); FetchCounter cmd = new FetchCounter(fetchCounterOptions); // NB: for cleanup on test teardown options = cmd.Options; RiakResult rslt = client.Execute(cmd); CheckResult(rslt); CounterResponse response = cmd.Response; Assert.AreEqual(0, response.Value); UpdateCounter updateCmd = new UpdateCounter.Builder() .WithBucketType("counters") .WithBucket("counters") .WithKey("traffic_tickets") .WithIncrement(1) .Build(); rslt = client.Execute(updateCmd); CheckResult(rslt); response = updateCmd.Response; Assert.AreEqual(1, response.Value); updateCmd = new UpdateCounter.Builder() .WithBucketType("counters") .WithBucket("counters") .WithKey("traffic_tickets") .WithIncrement(-1) .Build(); rslt = client.Execute(updateCmd); CheckResult(rslt); response = updateCmd.Response; Assert.AreEqual(0, response.Value); }
public void WhoopsIGotFiveTrafficTickets() { var fetchCounterOptions = new FetchCounterOptions("counters", "counters", "traffic_tickts"); FetchCounter cmd = new FetchCounter(fetchCounterOptions); // NB: for cleanup options = fetchCounterOptions; RiakResult rslt = client.Execute(cmd); CheckResult(rslt); CounterResponse response = cmd.Response; Assert.AreEqual(0, response.Value); var builder = new UpdateCounter.Builder(); builder.WithBucketType("counters") .WithBucket("counters") .WithKey("traffic_tickets") .WithIncrement(5); UpdateCounter updateCmd = builder.Build(); rslt = client.Execute(updateCmd); CheckResult(rslt); response = updateCmd.Response; Assert.AreEqual(5, response.Value); // Modify the builder's increment, then construct a new command builder.WithIncrement(-5); updateCmd = builder.Build(); rslt = client.Execute(updateCmd); CheckResult(rslt); response = updateCmd.Response; Assert.AreEqual(0, response.Value); }