예제 #1
0
        public void ResetChunkedDoesNothingIfEntryDoesNotExist()
        {
            // given
            var target = new BeaconCache();

            target.AddActionData(1, 1000L, "a");
            target.AddActionData(1, 1001L, "iii");
            target.AddEventData(1, 1000L, "b");
            target.AddEventData(1, 1001L, "jjj");

            // do same step we'd do when we send the
            target.GetNextBeaconChunk(1, "prefix", 10, '&');

            // data has been copied, but still add some new event & action data
            target.AddActionData(1, 6666L, "123");
            target.AddEventData(1, 6666L, "987");

            var notifyCount = 0;

            target.RecordAdded += (s, a) => { notifyCount += 1; };

            // and when resetting the previously copied data
            target.ResetChunkedData(666);

            // then
            Assert.That(target.NumBytesInCache, Is.EqualTo(12L));
            Assert.That(notifyCount, Is.EqualTo(0));
        }
예제 #2
0
        public void ResetChunkedRaisesEvent()
        {
            // given
            var key = new BeaconKey(1, 0);

            var target = new BeaconCache(logger);

            target.AddActionData(key, 1000L, "a");
            target.AddActionData(key, 1001L, "iii");
            target.AddEventData(key, 1000L, "b");
            target.AddEventData(key, 1001L, "jjj");

            // do same step we'd do when we send the
            target.GetNextBeaconChunk(key, "prefix", 10, '&');

            // data has been copied, but still add some new event & action data
            target.AddActionData(key, 6666L, "123");
            target.AddEventData(key, 6666L, "987");

            var notifyCount = 0;

            target.RecordAdded += (s, a) => { notifyCount += 1; };

            // and when resetting the previously copied data
            target.ResetChunkedData(key);

            // then
            Assert.That(notifyCount, Is.EqualTo(1));
        }
예제 #3
0
        public void ResetChunkedRestoresData()
        {
            // given
            var target = new BeaconCache();

            target.AddActionData(1, 1000L, "a");
            target.AddActionData(1, 1001L, "iii");
            target.AddEventData(1, 1000L, "b");
            target.AddEventData(1, 1001L, "jjj");

            // do same step we'd do when we send the
            target.GetNextBeaconChunk(1, "prefix", 10, '&');

            // data has been copied, but still add some new event & action data
            target.AddActionData(1, 6666L, "123");
            target.AddEventData(1, 6666L, "987");

            // and when resetting the previously copied data
            target.ResetChunkedData(1);

            // then
            Assert.That(target.GetActionsBeingSent(1), Is.Null);
            Assert.That(target.GetEventsBeingSent(1), Is.Null);
            Assert.That(target.GetActions(1), Is.EqualTo(new[] { new BeaconCacheRecord(1000L, "a"), new BeaconCacheRecord(1001L, "iii"), new BeaconCacheRecord(6666L, "123") }));
            Assert.That(target.GetEvents(1), Is.EqualTo(new[] { new BeaconCacheRecord(1000L, "b"), new BeaconCacheRecord(1001L, "jjj"), new BeaconCacheRecord(6666L, "987") }));
        }
예제 #4
0
        public void ResetChunkedRestoresCacheSize()
        {
            // given
            var key = new BeaconKey(1, 0);

            var target = new BeaconCache(logger);

            target.AddActionData(key, 1000L, "a");
            target.AddActionData(key, 1001L, "iii");
            target.AddEventData(key, 1000L, "b");
            target.AddEventData(key, 1001L, "jjj");

            // do same step we'd do when we send the
            target.GetNextBeaconChunk(key, "prefix", 10, '&');

            // data has been copied, but still add some new event & action data
            target.AddActionData(key, 6666L, "123");
            target.AddEventData(key, 6666L, "987");

            // and when resetting the previously copied data
            target.ResetChunkedData(key);

            // then
            Assert.That(target.NumBytesInCache, Is.EqualTo(28L));
        }