public void ShouldPublishEvent() { var ringBuffer = ValueRingBuffer <long> .CreateSingleProducer(() => - 1L, 4); using (var scope = ringBuffer.PublishEvent()) { scope.Event() = scope.Sequence; } using (var scope = ringBuffer.TryPublishEvent()) { Assert.IsTrue(scope.HasEvent); Assert.IsTrue(scope.TryGetEvent(out var e)); e.Event() = e.Sequence; } Assert.That(ringBuffer, ValueRingBufferEqualsConstraint.IsValueRingBufferWithEvents(0L, 1L)); }
public void ShouldPublishEvents() { var ringBuffer = CreateSingleProducer(() => - 1L, 4); using (var scope = ringBuffer.PublishEvents(2)) { scope.Event(0) = scope.StartSequence; scope.Event(1) = scope.StartSequence + 1; } Assert.That(ringBuffer, ValueRingBufferEqualsConstraint.IsValueRingBufferWithEvents(0L, 1L, -1, -1)); using (var scope = ringBuffer.TryPublishEvents(2)) { Assert.IsTrue(scope.HasEvents); Assert.IsTrue(scope.TryGetEvents(out var e)); e.Event(0) = e.StartSequence; e.Event(1) = e.StartSequence + 1; } Assert.That(ringBuffer, ValueRingBufferEqualsConstraint.IsValueRingBufferWithEvents(0L, 1L, 2L, 3L)); }
public Result(ValueRingBufferEqualsConstraint constraint, object actualValue, bool isSuccess) : base(constraint, actualValue, isSuccess) { _constraint = constraint; }