Beispiel #1
0
        public void GetChunkGetsChunksFromEventDataBeforeActionData()
        {
            // given
            var dataOne   = new BeaconCacheRecord(0L, "One");
            var dataTwo   = new BeaconCacheRecord(0L, "Two");
            var dataThree = new BeaconCacheRecord(1L, "Three");
            var dataFour  = new BeaconCacheRecord(1L, "Four");

            var target = new BeaconCacheEntry();

            target.AddEventData(dataOne);
            target.AddEventData(dataFour);
            target.AddActionData(dataTwo);
            target.AddActionData(dataThree);

            target.CopyDataForSending();

            // when getting data to send
            var obtained = target.GetChunk("a", 2, '&');

            // then it's the first event data
            Assert.That(obtained, Is.EqualTo("a&" + dataOne.Data));

            // and when removing already sent data and getting next chunk
            target.RemoveDataMarkedForSending();
            obtained = target.GetChunk("a", 2, '&');

            // then it's second event data
            Assert.That(obtained, Is.EqualTo("a&" + dataFour.Data));

            // and when removing already sent data and getting next chunk
            target.RemoveDataMarkedForSending();
            obtained = target.GetChunk("a", 2, '&');

            // then it's the first action data
            Assert.That(obtained, Is.EqualTo("a&" + dataTwo.Data));

            // and when removing already sent data and getting next chunk
            target.RemoveDataMarkedForSending();
            obtained = target.GetChunk("a", 2, '&');

            // then it's the second action data
            Assert.That(obtained, Is.EqualTo("a&" + dataThree.Data));

            // and when removing already sent data and getting next chunk
            target.RemoveDataMarkedForSending();
            obtained = target.GetChunk("a", 2, '&');

            // then we get an empty string, since all chunks were sent & deleted
            Assert.That(obtained, Is.Empty);
        }
Beispiel #2
0
        public void RemoveDataMarkedForSendingReturnsIfDataHasNotBeenCopied()
        {
            // given
            var dataOne   = new BeaconCacheRecord(0L, "One");
            var dataTwo   = new BeaconCacheRecord(0L, "Two");
            var dataThree = new BeaconCacheRecord(1L, "Three");
            var dataFour  = new BeaconCacheRecord(1L, "Four");

            var target = new BeaconCacheEntry();

            target.AddEventData(dataOne);
            target.AddEventData(dataFour);
            target.AddActionData(dataTwo);
            target.AddActionData(dataThree);

            // when
            target.RemoveDataMarkedForSending();

            // then
            Assert.That(target.EventData, Is.EqualTo(new[] { dataOne, dataFour }));
            Assert.That(target.ActionData, Is.EqualTo(new[] { dataTwo, dataThree }));
            Assert.That(target.EventDataBeingSent, Is.Null);
            Assert.That(target.ActionDataBeingSent, Is.Null);
        }