Permalink
Browse files

Progress: pure TF based reading - $deleted handled

  • Loading branch information...
ysw committed Feb 12, 2014
1 parent 4eac3f1 commit d7acfd21470b374d613b5dbf330142ed8c55318a
@@ -40,6 +40,7 @@
using EventStore.Core.Tests.Helpers;
using EventStore.Projections.Core.Services.Processing;
using NUnit.Framework;
+using ResolvedEvent = EventStore.ClientAPI.ResolvedEvent;
namespace EventStore.Projections.Core.Tests.ClientAPI
{
@@ -154,8 +155,9 @@ protected void AssertStreamTail(string streamId, params string[] events)
Assert.Fail("Stream '{0}' doe snot exist", streamId);
break;
case SliceReadStatus.Success:
- if (result.Events.Length < events.Length)
- DumpFailed("Stream does not contain enough events", streamId, result, events);
+ var resultEventsReversed = result.Events.Reverse().ToArray();
+ if (resultEventsReversed.Length < events.Length)
+ DumpFailed("Stream does not contain enough events", streamId, events, result.Events);
else
{
for (var index = 0; index < events.Length; index++)
@@ -164,11 +166,11 @@ protected void AssertStreamTail(string streamId, params string[] events)
var eventType = parts[0];
var eventData = parts[1];
- if (result.Events[index].Event.EventType != eventType)
- DumpFailed("Invalid event type", streamId, result, events);
+ if (resultEventsReversed[index].Event.EventType != eventType)
+ DumpFailed("Invalid event type", streamId, events, resultEventsReversed);
else
- if (result.Events[index].Event.DebugDataView != eventData)
- DumpFailed("Invalid event body", streamId, result, events);
+ if (resultEventsReversed[index].Event.DebugDataView != eventData)
+ DumpFailed("Invalid event body", streamId, events, resultEventsReversed);
}
}
break;
@@ -177,15 +179,19 @@ protected void AssertStreamTail(string streamId, params string[] events)
}
#if DEBUG
- private void DumpFailed(string message, string streamId, StreamEventsSlice result, string[] events)
+ private void DumpFailed(string message, string streamId, string[] events, ResolvedEvent[] resultEvents)
{
var expected = events.Aggregate("", (a, v) => a + ", " + v);
- var actual = result.Events.Aggregate(
+ var actual = resultEvents.Aggregate(
"", (a, v) => a + ", " + v.Event.EventType + ":" + v.Event.DebugDataView);
+ var actualMeta = resultEvents.Aggregate(
+ "", (a, v) => a + "\r\n" + v.Event.EventType + ":" + v.Event.DebugMetadataView);
+
+
Assert.Fail(
- "Stream: '{0}'\r\n{1}\r\n\r\nExisting events: \r\n{2}\r\n Expected events: \r\n{3}", streamId,
- message, actual, expected);
+ "Stream: '{0}'\r\n{1}\r\n\r\nExisting events: \r\n{2}\r\n Expected events: \r\n{3}\r\n\r\nActual metas:{4}", streamId,
+ message, actual, expected, actualMeta);
}
#endif
@@ -67,7 +67,8 @@ protected override void When()
[Test, Category("Network")]
public void receives_deleted_notification()
{
- AssertStreamTail("$projections-test-projection-stream1-result", "Result:{\"a\":1}", "Result:{\"deleted\":1}");
+ AssertStreamTail(
+ "$projections-test-projection-stream1-result", "Result:{\"a\":1}", "Result:{\"a\":1,\"deleted\":1}");
}
}
}
@@ -53,6 +53,9 @@ public class checkpoint_tag_by_event_type_index_positions
private readonly CheckpointTag _a2b1 = CheckpointTag.FromEventTypeIndexPositions(
1, new TFPos(400, 350), new Dictionary<string, int> {{"a", 2}, {"b", 1}});
+ private readonly CheckpointTag _a2b1_after = CheckpointTag.FromEventTypeIndexPositions(
+ 1, new TFPos(430, 420), new Dictionary<string, int> { { "a", 2 }, { "b", 1 } });
+
private readonly CheckpointTag _a1b2 = CheckpointTag.FromEventTypeIndexPositions(
1, new TFPos(500, 450), new Dictionary<string, int> {{"a", 1}, {"b", 2}});
@@ -83,6 +86,7 @@ public void less_operator()
Assert.IsTrue(_a1 < _a1b1);
Assert.IsTrue(_a1 < _a1b2);
Assert.IsTrue(_a1 < _a2b2);
+ Assert.IsTrue(_a2b1 < _a2b1_after);
Assert.IsFalse(_a1b2 < _a1b2);
Assert.IsFalse(_a1b2 < _a1b1);
Assert.IsFalse(_a1b2 < _a2b1);
@@ -95,6 +99,7 @@ public void less_or_equal_operator()
Assert.IsTrue(_a1 <= _a1b1);
Assert.IsTrue(_a1 <= _a1b2);
Assert.IsTrue(_a1 <= _a2b2);
+ Assert.IsTrue(_a2b1 <= _a2b1_after);
Assert.IsTrue(_a1b2 <= _a1b2);
Assert.IsFalse(_a1b2 <= _a1b1);
Assert.IsFalse(_a1b2 <= _a2b1);
@@ -107,6 +112,8 @@ public void greater_operator()
Assert.IsFalse(_a1 > _a1b1);
Assert.IsFalse(_a1 > _a1b2);
Assert.IsFalse(_a1 > _a2b2);
+ Assert.IsFalse(_a2b1 > _a2b1_after);
+ Assert.IsTrue(_a2b1_after > _a2b1);
Assert.IsFalse(_a1b2 > _a1b2);
Assert.IsTrue(_a1b2 > _a1b1);
Assert.IsTrue(_a1b2 > _a2b1);
@@ -119,6 +126,8 @@ public void greater_or_equal_operator()
Assert.IsFalse(_a1 >= _a1b1);
Assert.IsFalse(_a1 >= _a1b2);
Assert.IsFalse(_a1 >= _a2b2);
+ Assert.IsFalse(_a2b1 >= _a2b1_after);
+ Assert.IsTrue(_a2b1_after >= _a2b1);
Assert.IsTrue(_a1b2 >= _a1b2);
Assert.IsTrue(_a1b2 >= _a1b1);
Assert.IsTrue(_a1b2 >= _a2b1);

0 comments on commit d7acfd2

Please sign in to comment.