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."); }
/// <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."); }
/// <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); }
public void ClearIsDelegatedToTheTransportClient() { var mockBatch = new MockTransportBatch(); var batch = new EventDataBatch(mockBatch, "ns", "eh", new SendEventOptions()); batch.Clear(); Assert.That(mockBatch.ClearInvoked, Is.True); }
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."); }
/// <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."); }
/// <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."); }
/// <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."); }
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."); }
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."); }
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."); }
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."); }