コード例 #1
0
        public void RemoveChunkedDataClearsAlreadyRetrievedChunks()
        {
            // given
            var target = new BeaconCache();

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

            // when retrieving the first chunk and removing retrieved chunks
            var obtained = target.GetNextBeaconChunk(1, "prefix", 10, '&');

            target.RemoveChunkedData(1);

            // then
            Assert.That(obtained, Is.EqualTo("prefix&b&jjj"));

            Assert.That(target.GetActionsBeingSent(1), Is.EqualTo(new[] { new BeaconCacheRecord(1000L, "a"), new BeaconCacheRecord(1001L, "iii") }));
            Assert.That(target.GetEventsBeingSent(1), Is.Empty);

            // when retrieving the second chunk and removing retrieved chunks
            obtained = target.GetNextBeaconChunk(1, "prefix", 10, '&');
            target.RemoveChunkedData(1);

            // then
            Assert.That(obtained, Is.EqualTo("prefix&a&iii"));

            Assert.That(target.GetActionsBeingSent(1), Is.Empty);
            Assert.That(target.GetEventsBeingSent(1), Is.Empty);
        }
コード例 #2
0
        public void RemoveChunkedDataDoesNothingIfCalledWithNonExistingBeaconID()
        {
            // given
            var target = new BeaconCache();

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

            // when retrieving the first chunk and removing the wrong beacon chunk
            target.GetNextBeaconChunk(1, "prefix", 10, '&');
            target.RemoveChunkedData(2);

            // then
            Assert.That(target.GetActionsBeingSent(1), Is.EqualTo(new[] { new BeaconCacheRecord(1000L, "a"), new BeaconCacheRecord(1001L, "iii") }));
            var expectedEventRecords = new[] { new BeaconCacheRecord(1000L, "b"), new BeaconCacheRecord(1001L, "jjj") };

            foreach (BeaconCacheRecord record in expectedEventRecords)
            {
                record.MarkForSending();
            }
            Assert.That(target.GetEventsBeingSent(1), Is.EqualTo(expectedEventRecords));
        }