public void initial_position_cannot_be_set_twice() { var newTag = CheckpointTag.FromStreamPosition("stream1", 1, 50); _positionTracker.UpdateByCheckpointTagForward(newTag); _positionTracker.UpdateByCheckpointTagForward(newTag); }
public void it_cannot_be_updated_with_other_stream() { Assert.Throws <InvalidOperationException>(() => { var newTag = CheckpointTag.FromStreamPosition(0, "other_stream1", 1); _positionTracker.UpdateByCheckpointTagInitial(newTag); }); }
public void is_message_after_checkpoint_tag_equal_case() { var t = new StreamPositionTagger(0, "stream1"); var result = t.IsMessageAfterCheckpointTag(CheckpointTag.FromStreamPosition(0, "stream1", 1), _firstEvent); Assert.IsFalse(result); }
public void it_cannot_be_updated_with_other_stream() { // even not initialized (UpdateToZero can be removed) var newTag = CheckpointTag.FromStreamPosition(0, "other_stream1", 2); _positionTracker.UpdateByCheckpointTagForward(newTag); }
public void adjust_compatible_tag_returns_the_same_tag() { var t = new StreamPositionTagger(0, "stream1"); var tag = CheckpointTag.FromStreamPosition(0, "stream1", 1); Assert.AreEqual(tag, t.AdjustTag(tag)); }
public void setup() { _exception = null; try { _point = new HeadingEventDistributionPoint(10); } catch (Exception ex) { _exception = ex; } _distibutionPointCorrelationId = Guid.NewGuid(); _point.Start( _distibutionPointCorrelationId, new TransactionFileReaderEventDistributionPoint( _bus, _distibutionPointCorrelationId, new EventPosition(0, -1))); _point.Handle( new ProjectionMessage.Projections.CommittedEventDistributed( _distibutionPointCorrelationId, new EventPosition(20, 10), "stream", 10, false, new Event(Guid.NewGuid(), "type", false, new byte[0], new byte[0]))); _point.Handle( new ProjectionMessage.Projections.CommittedEventDistributed( _distibutionPointCorrelationId, new EventPosition(40, 30), "stream", 11, false, new Event(Guid.NewGuid(), "type", false, new byte[0], new byte[0]))); _subscription = new FakeProjectionSubscription(); _projectionSubscriptionId = Guid.NewGuid(); var subscribed = _point.TrySubscribe( _projectionSubscriptionId, _subscription, CheckpointTag.FromStreamPosition("stream", 100, prepaprePosition: 30)); }
public void event_processed_throws_invalid_operation_exception() { // _manager.StateUpdated("", @"{""state"":""state""}"); Assert.Throws <InvalidOperationException>(() => { _manager.EventProcessed(CheckpointTag.FromStreamPosition(0, "stream", 10), 77.7f); }); }
public void cannot_update_to_the_same_postion() { Assert.Throws <InvalidOperationException>(() => { var newTag = CheckpointTag.FromStreamPosition(0, "stream1", 2); _positionTracker.UpdateByCheckpointTagForward(newTag); }); }
protected override void When() { base.When(); _exception = null; try { _checkpointReader.BeginLoadState(); var checkpointLoaded = _consumer.HandledMessages.OfType <CoreProjectionProcessingMessage.CheckpointLoaded>().First(); _checkpointWriter.StartFrom(checkpointLoaded.CheckpointTag, checkpointLoaded.CheckpointEventNumber); _manager.BeginLoadPrerecordedEvents(checkpointLoaded.CheckpointTag); _manager.Start(CheckpointTag.FromStreamPosition(0, "stream", 10)); // _manager.StateUpdated("", @"{""state"":""state1""}"); _manager.EventProcessed(CheckpointTag.FromStreamPosition(0, "stream", 11), 77.7f); // _manager.StateUpdated("", @"{""state"":""state2""}"); _manager.EventProcessed(CheckpointTag.FromStreamPosition(0, "stream", 12), 77.8f); _manager.CheckpointSuggested(CheckpointTag.FromStreamPosition(0, "stream", 12), 77.8f); _manager.Stopping(); } catch (Exception ex) { _exception = ex; } }
public void it_cannot_be_updated_forward() { Assert.Throws <InvalidOperationException>(() => { var newTag = CheckpointTag.FromStreamPosition(0, "stream1", 1); _positionTracker.UpdateByCheckpointTagForward(newTag); }); }
public void it_can_be_updated_with_correct_stream() { // even not initialized (UpdateToZero can be removed) var newTag = CheckpointTag.FromStreamPosition("stream1", 1, 50); _positionTracker.UpdateByCheckpointTagInitial(newTag); }
public void cannot_be_started_from_incompatible_checkpoint_tag() { //TODO: move to when loaded Assert.Throws <InvalidOperationException>(() => { _manager.Start(CheckpointTag.FromStreamPosition(0, "stream1", 10), null); }); }
public void it_cannot_be_updated_with_other_stream() { Assert.Throws <InvalidOperationException>(() => { // even not initialized (UpdateToZero can be removed) var newTag = CheckpointTag.FromStreamPosition(0, "other_stream1", 2); _positionTracker.UpdateByCheckpointTagForward(newTag); }); }
public void is_message_after_checkpoint_tag_incompatible_case() { // events from other streams are not after any tag var t = new StreamPositionTagger("stream-other"); var result = t.IsMessageAfterCheckpointTag(CheckpointTag.FromStreamPosition("stream1", 1), _firstEvent); Assert.IsFalse(result); }
protected override void Given() { _correlationId = Guid.NewGuid(); _projectionId = Guid.NewGuid(); _state = "{\"a\":1}"; _partition = "partition"; _position = CheckpointTag.FromStreamPosition(1, "stream", 10); }
public void a_projection_cannot_be_subscribed_at_earlier_position() { var subscribed = _point.TrySubscribe( Guid.NewGuid(), new FakeProjectionSubscription(), CheckpointTag.FromStreamPosition("stream", 50, prepaprePosition: 10)); Assert.AreEqual(false, subscribed); }
public void projection_can_resubscribe_with() { var subscribed = _point.TrySubscribe( _projectionSubscriptionId, _subscription, CheckpointTag.FromStreamPosition("stream", 100, prepaprePosition: 30)); Assert.AreEqual(true, subscribed); }
public void a_projection_can_be_subscribed_after_event_position() { var subscribed = _point.TrySubscribe( Guid.NewGuid(), new FakeProjectionSubscription(), CheckpointTag.FromStreamPosition("stream", 100, prepaprePosition: 30)); Assert.AreEqual(true, subscribed); }
public void When() { // given _tagger = new StreamPositionTagger("stream1"); _positionTracker = new PositionTracker(_tagger); var newTag = CheckpointTag.FromStreamPosition("stream1", 1, 50); _positionTracker.UpdateByCheckpointTagInitial(newTag); }
public void stream_based_checkpoint_tag() { CheckpointTag tag = CheckpointTag.FromStreamPosition(1, "$ce-account", 12345); byte[] bytes = tag.ToJsonBytes(_version); string instring = Helper.UTF8NoBom.GetString(bytes); Console.WriteLine(instring); CheckpointTag back = instring.ParseCheckpointTagJson(); Assert.AreEqual(tag, back); Assert.IsNull(back.CommitPosition); }
protected override void Given() { _workerId = Guid.NewGuid(); _masterProjectionId = Guid.NewGuid(); _subscriptionId = Guid.NewGuid(); _partition = "partition"; _causedBy = Guid.NewGuid(); _position = CheckpointTag.FromStreamPosition(1, "stream", 1); _result = "{}"; }
public void can_adjust_stream_position_tag() { var t = new MultiStreamPositionTagger(0, new[] { "stream1", "stream2" }); var tag = CheckpointTag.FromStreamPositions(0, new Dictionary <string, int> { { "stream1", 1 }, { "stream2", -1 } }); var original = CheckpointTag.FromStreamPosition(0, "stream1", 1); Assert.AreEqual(tag, t.AdjustTag(original)); }
public void stream_position_should_not_overflow() { var checkpointTag = CheckpointTag.FromStreamPosition(1, "test", 9876543210L); var json = checkpointTag.ToJsonString(); var jsonReader = new JsonTextReader(new StringReader(json)); var checkpointTagFromJson = CheckpointTag.FromJson(jsonReader, new ProjectionVersion(0, 0, 0)); Assert.AreEqual(9876543210L, checkpointTagFromJson.Tag.Streams["test"]); }
public void can_adjust_multi_stream_position_tag() { var t = new StreamPositionTagger("stream1"); var tag = CheckpointTag.FromStreamPosition("stream1", 1); var original = CheckpointTag.FromStreamPositions( new Dictionary <string, int> { { "stream1", 1 }, { "stream2", 2 } }); Assert.AreEqual(tag, t.AdjustTag(original)); }
protected override void When() { _response = MakeJsonPostWithJsonResponse( "/projections/read-events", new { Query = new { Streams = new[] { TestStreamName }, AllEvents = true }, Position = new JRaw(CheckpointTag.FromStreamPosition(TestStreamName, -1).ToJsonString()), MaxEvents = 1 }); }
protected override void Given() { base.Given(); ExistingEvent("test-stream", "type1", "{}", "{Data: 1}"); ExistingEvent("test-stream", "type1", "{}", "{Data: 2}"); ExistingEvent("test-stream", "type2", "{}", "{Data: 3}"); _querySourcesDefinition = new QuerySourcesDefinition { Streams = new[] { "test-stream" }, AllEvents = true }; _fromPosition = CheckpointTag.FromStreamPosition(0, "test-stream", -1); _maxEvents = 2; }
public void stream_based_checkpoint_tag() { CheckpointTag tag = CheckpointTag.FromStreamPosition("$ce-account", 12345); byte[] bytes = tag.ToJsonBytes(); string instring = Encoding.UTF8.GetString(bytes); Console.WriteLine(instring); var back = instring.ParseJson <CheckpointTag>(); Assert.AreEqual(tag, back); Assert.IsNull(back.CommitPosition); }
protected override void When() { base.When(); _exception = null; try { _manager.BeginLoadState(); _manager.Start(CheckpointTag.FromStreamPosition("stream", 10)); } catch (Exception ex) { _exception = ex; } }
protected override void When() { base.When(); _exception = null; try { _checkpointReader.BeginLoadState(); var checkpointLoaded = _consumer.HandledMessages.OfType <CoreProjectionProcessingMessage.CheckpointLoaded>().First(); _checkpointWriter.StartFrom(checkpointLoaded.CheckpointTag, checkpointLoaded.CheckpointEventNumber); _manager.BeginLoadPrerecordedEvents(checkpointLoaded.CheckpointTag); _manager.Start(CheckpointTag.FromStreamPosition(0, "stream", 10), null); } catch (Exception ex) { _exception = ex; } }
public void When() { // given var tagger = new StreamPositionTagger(0, "stream1"); var tracker = new PositionTracker(tagger); var newTag = CheckpointTag.FromStreamPosition(0, "stream1", 1); tracker.UpdateByCheckpointTagInitial(newTag); _tag = tracker.LastTag; _tagger = new StreamPositionTagger(0, "stream1"); _positionTracker = new PositionTracker(_tagger); // when _positionTracker.UpdateByCheckpointTagInitial(_tag); }