コード例 #1
0
        public void StartingPublishedSequenceNumberValidatesOnSet(int value)
        {
            var mockBatch = new MockTransportBatch();
            var batch     = new EventDataBatch(mockBatch, "ns", "eh", new SendEventOptions());

            Assert.That(() => batch.StartingPublishedSequenceNumber = value, Throws.InstanceOf <ArgumentException>(), "Negative values should not be allowed.");
        }
コード例 #2
0
        /// <summary>
        ///   Verifies property accessors for the <see cref="EventDataBatch.AsEnumerable" />
        ///   method.
        /// </summary>
        ///
        public void AsEnumerableIsDelegatedToTheTransportClient()
        {
            var mockBatch = new MockTransportBatch();
            var batch     = new EventDataBatch(mockBatch, new SendEventOptions());

            batch.AsEnumerable <string>();
            Assert.That(mockBatch.AsEnumerableCalledWith, Is.EqualTo(typeof(string)), "The enumerable should delegated the requested type parameter.");
        }
コード例 #3
0
        /// <summary>
        ///   Verifies property accessors for the <see cref="EventDataBatch.TryAdd" />
        ///   method.
        /// </summary>
        ///
        public void DisposeIsDelegatedToTheTransportClient()
        {
            var mockBatch = new MockTransportBatch();
            var batch     = new EventDataBatch(mockBatch, new SendEventOptions());

            batch.Dispose();
            Assert.That(mockBatch.DisposeInvoked, Is.True);
        }
コード例 #4
0
        public void ClearIsDelegatedToTheTransportClient()
        {
            var mockBatch = new MockTransportBatch();
            var batch     = new EventDataBatch(mockBatch, "ns", "eh", new SendEventOptions());

            batch.Clear();
            Assert.That(mockBatch.ClearInvoked, Is.True);
        }
コード例 #5
0
        public void StartingPublishedSequenceNumberValidatesAllowsValidValues(int?value)
        {
            var mockBatch = new MockTransportBatch();
            var batch     = new EventDataBatch(mockBatch, "ns", "eh", new SendEventOptions());

            batch.StartingPublishedSequenceNumber = value;
            Assert.That(batch.StartingPublishedSequenceNumber, Is.EqualTo(value), "The value should have been accepted.");
        }
コード例 #6
0
        /// <summary>
        ///   Verifies property accessors for the <see cref="EventDataBatch.TryAdd" />
        ///   method.
        /// </summary>
        ///
        public void TryAddIsDelegatedToTheTransportClient()
        {
            var mockBatch = new MockTransportBatch();
            var batch     = new EventDataBatch(mockBatch, new SendEventOptions());
            var eventData = new EventData(new byte[] { 0x21 });

            Assert.That(batch.TryAdd(eventData), Is.True, "The event should have been accepted.");
            Assert.That(mockBatch.TryAddCalledWith, Is.SameAs(eventData), "The event data should have been passed with delegation.");
        }
コード例 #7
0
        /// <summary>
        ///   Verifies property accessors for the <see cref="EventDataBatch" />
        ///   class.
        /// </summary>
        ///
        public void PropertyAccessIsDelegatedToTheTransportClient()
        {
            var mockBatch = new MockTransportBatch();
            var batch     = new EventDataBatch(mockBatch, new SendEventOptions());

            Assert.That(batch.MaximumSizeInBytes, Is.EqualTo(mockBatch.MaximumSizeInBytes), "The maximum size should have been delegated.");
            Assert.That(batch.SizeInBytes, Is.EqualTo(mockBatch.SizeInBytes), "The size should have been delegated.");
            Assert.That(batch.Count, Is.EqualTo(mockBatch.Count), "The count should have been delegated.");
        }
コード例 #8
0
        /// <summary>
        ///   Verifies property accessors for the <see cref="EventDataBatch" />
        ///   constructor.
        /// </summary>
        ///
        public void ConstructorUpdatesState()
        {
            var sendOptions = new SendEventOptions();
            var mockBatch   = new MockTransportBatch();
            var batch       = new EventDataBatch(new MockTransportBatch(), null);

            Assert.That(batch.SendOptions, Is.SameAs(sendOptions), "The send options should have been set.");
            Assert.That(GetInnerBatch(batch), Is.SameAs(mockBatch), "The inner transport batch should have been set.");
        }
コード例 #9
0
        public void TryAddClonesTheEvent()
        {
            var mockBatch = new MockTransportBatch();
            var batch     = new EventDataBatch(mockBatch, "ns", "eh", new SendEventOptions());
            var eventData = new EventData(new byte[] { 0x21 });

            Assert.That(batch.TryAdd(eventData), Is.True, "The event should have been accepted.");
            Assert.That(mockBatch.TryAddCalledWith.IsEquivalentTo(eventData), Is.True, "The event data should have been passed with delegation.");
            Assert.That(mockBatch.TryAddCalledWith, Is.Not.SameAs(eventData), "The event data should have been cloned.");
        }
コード例 #10
0
        public void PropertyAccessIsDelegatedToTheTransportClient()
        {
            var mockBatch = new MockTransportBatch();
            var batch     = new EventDataBatch(mockBatch, "ns", "eh", new SendEventOptions());

            Assert.That(batch.MaximumSizeInBytes, Is.EqualTo(mockBatch.MaximumSizeInBytes), "The maximum size should have been delegated.");
            Assert.That(batch.SizeInBytes, Is.EqualTo(mockBatch.SizeInBytes), "The size should have been delegated.");
            Assert.That(batch.Count, Is.EqualTo(mockBatch.Count), "The count should have been delegated.");
            Assert.That(batch.StartingPublishedSequenceNumber, Is.EqualTo(mockBatch.StartingPublishedSequenceNumber), "The starting published sequence number should have been delegated.");
        }
コード例 #11
0
        public void TryAddRespectsTheBatchLock()
        {
            var mockBatch = new MockTransportBatch();
            var batch     = new EventDataBatch(mockBatch, "ns", "eh", new SendEventOptions());
            var eventData = new EventData(new byte[] { 0x21 });

            Assert.That(batch.TryAdd(new EventData(new byte[] { 0x21 })), Is.True, "The event should have been accepted before locking.");

            batch.Lock();
            Assert.That(() => batch.TryAdd(new EventData(new BinaryData(Array.Empty <byte>()))), Throws.InstanceOf <InvalidOperationException>(), "The batch should not accept events when locked.");

            batch.Unlock();
            Assert.That(batch.TryAdd(new EventData(new BinaryData(Array.Empty <byte>()))), Is.True, "The event should have been accepted after unlocking.");
        }
コード例 #12
0
        public void DisposeRespectsTheBatchLock()
        {
            var mockBatch = new MockTransportBatch();
            var batch     = new EventDataBatch(mockBatch, "ns", "eh", new SendEventOptions());
            var eventData = new EventData(new byte[] { 0x21 });

            Assert.That(batch.TryAdd(new EventData(new byte[] { 0x21 })), Is.True, "The event should have been accepted before locking.");

            batch.Lock();
            Assert.That(() => batch.Dispose(), Throws.InstanceOf <InvalidOperationException>(), "The batch should not accept events when locked.");
            Assert.That(mockBatch.DisposeInvoked, Is.False, "The batch should not have permitted the operation while locked.");

            batch.Unlock();
            batch.Dispose();

            Assert.That(mockBatch.DisposeInvoked, Is.True, "The batch should have been disposed after unlocking.");
        }