예제 #1
0
        public void Should_persist_tags_and_checkpoints()
        {
            WithRfidService((storageService, rfidService) =>
            {
                storageService.UpdateRfidOptions(x => x.PersistTags = true);
                var tagListHandler = new SimulatorBuilder(storageService).Build();
                tagListHandler.ReturnOnce(new Tag {
                    TagId = "1"
                });
                new Timing()
                .FailureDetails(() => storageService.ListCheckpoints().Count.ToString())
                .Expect(() => storageService.ListCheckpoints().Count(y => !y.Aggregated) == 1);
                // Need to wait before advance, to prevent race between Advance and checkpoint code in RfidService
                SystemClock.Advance();
                tagListHandler.ReturnOnce(new Tag {
                    TagId = "1"
                });
                new Timing()
                .FailureDetails(() => storageService.ListCheckpoints().Count.ToString())
                .Expect(() => storageService.ListCheckpoints().Count(y => !y.Aggregated) == 2);

                new Timing()
                .FailureDetails(() => storageService.ListTags().Count.ToString())
                .Expect(() => storageService.ListTags().Count == 2);
            });
        }
예제 #2
0
 public void Should_disable_stale_rfid()
 {
     WithCheckpointStorageService(s => { s.UpdateRfidOptions(o => o.Enabled = true); });
     SystemClock.Advance(TimeSpan.FromDays(1.2));
     WithRfidService((s, r) =>
     {
         var o = s.GetRfidOptions();
         o.Enabled.Should().BeFalse();
         o.Timestamp.Should().Be(SystemClock.UtcNow.UtcDateTime);
     });
 }
예제 #3
0
        public void StatsWithCounterUpdate()
        {
            stats.Increment("tps", 10);

            collector.Periodic(null);
            SystemClock.Advance(TimeSpan.FromMinutes(1));
            stats.Increment("tps", 5);
            collector.Periodic(null);

            var series = collector.Get("counter:tps", null);

            Assert.NotNull(series);
            Assert.That(series.Count(), Is.EqualTo(60));
            var seconds = SystemClock.Minus(TimeSpan.FromMinutes(2d)).MillisFromEpoch() / 1000;

            AssertClose(new List <long>(new[] { seconds, 0 }), series.ElementAt(57));
            seconds = SystemClock.Minus(TimeSpan.FromMinutes(1d)).MillisFromEpoch() / 1000;
            AssertClose(new List <long>(new[] { seconds, 10 }), series.ElementAt(58));
            AssertClose(new List <long>(new[] { SystemClock.Seconds(), 5 }), series.ElementAt(59));
        }
예제 #4
0
        public void StatsIncr()
        {
            stats.Increment("cats");
            stats.Increment("dogs", 3);

            collector.Periodic(null);

            stats.Increment("dogs", 60000);
            SystemClock.Advance(TimeSpan.FromMinutes(1));

            collector.Periodic(null);

            var series = collector.Get("counter:dogs", null);

            series.ShouldNotBe(null);
            series.Count().ShouldBe(60);

            var seconds = SystemClock.Minus(TimeSpan.FromMinutes(2d)).MillisFromEpoch() / 1000;

            AssertClose(new List <long>(new[] { seconds, 0 }), series.ElementAt(57));
            seconds = SystemClock.Minus(TimeSpan.FromMinutes(1d)).MillisFromEpoch() / 1000;
            AssertClose(new List <long>(new[] { seconds, 3 }), series.ElementAt(58));
            AssertClose(new List <long>(new[] { SystemClock.Seconds(), 60000 }), series.ElementAt(59));
        }