Skip to content

Commit

Permalink
Fixing broken tests
Browse files Browse the repository at this point in the history
  • Loading branch information
samhjohnson committed Mar 8, 2016
1 parent 5689e4b commit 6709ce1
Showing 1 changed file with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace EventStore.Core.Tests.ClientAPI
[TestFixture]
public class catch_up_subscription_handles_errors
{
private static int TimeoutMs = 2000;
private FakeEventStoreConnection _connection;
private IList<ResolvedEvent> _raisedEvents;
private bool _liveProcessingStarted;
Expand Down Expand Up @@ -83,7 +84,7 @@ public void read_events_til_stops_subscription_when_throws_immediately()

private void AssertStartFailsAndDropsSubscriptionWithException(ApplicationException expectedException)
{
Assert.That(() => _subscription.Start().Wait(), Throws.TypeOf<AggregateException>());
Assert.That(() => _subscription.Start().Wait(TimeoutMs), Throws.TypeOf<AggregateException>());
Assert.That(_isDropped);
Assert.That(_dropReason, Is.EqualTo(SubscriptionDropReason.CatchUpError));
Assert.That(_dropException, Is.SameAs(expectedException));
Expand Down Expand Up @@ -302,7 +303,7 @@ public void start_completes_onces_subscription_is_live()
else if (callCount == 2)
{
taskCompletionSource.SetResult(CreateStreamEventsSlice(fromEvent:1, isEnd: true));
finalEvent.Wait();
Assert.That(finalEvent.Wait(TimeoutMs));
}
return taskCompletionSource.Task;
Expand All @@ -321,7 +322,7 @@ public void start_completes_onces_subscription_is_live()

finalEvent.Set();

task.Wait();
Assert.That(task.Wait(TimeoutMs));
}

[Test]
Expand Down Expand Up @@ -356,13 +357,13 @@ public void when_live_processing_and_disconnected_reconnect_keeps_events_ordered
return taskCompletionSource.Task;
});

_subscription.Start().Wait();
Assert.That(_subscription.Start().Wait(TimeoutMs));
Assert.That(_raisedEvents.Count, Is.EqualTo(0));

Assert.That(innerSubscriptionDrop, Is.Not.Null);
innerSubscriptionDrop(volatileEventStoreSubscription, SubscriptionDropReason.ConnectionClosed, null);

Assert.That(_dropEvent.Wait(10000));
Assert.That(_dropEvent.Wait(TimeoutMs));
_dropEvent.Reset();

var waitForOutOfOrderEvent = new ManualResetEventSlim();
Expand All @@ -378,22 +379,22 @@ public void when_live_processing_and_disconnected_reconnect_keeps_events_ordered
}
else if (callCount == 2)
{
waitForOutOfOrderEvent.Wait();
Assert.That(waitForOutOfOrderEvent.Wait(TimeoutMs));
taskCompletionSource.SetResult(CreateStreamEventsSlice(fromEvent: 0, count: 1, isEnd: true));
}
return taskCompletionSource.Task;
});

var event1 = new ClientMessage.ResolvedEvent(new ClientMessage.EventRecord(StreamId, 1, Guid.NewGuid().ToByteArray(), null, 0, 0, null, null, null, null), null, 0, 0);
VolatileEventStoreSubscription volatileEventStoreSubscription2 = null;

_connection.HandleSubscribeToStreamAsync((stream, raise, drop) =>
{
var taskCompletionSource = new TaskCompletionSource<EventStoreSubscription>();
volatileEventStoreSubscription2 = CreateVolatileSubscription(raise, drop, null);
VolatileEventStoreSubscription volatileEventStoreSubscription2 = CreateVolatileSubscription(raise, drop, null);
taskCompletionSource.SetResult(volatileEventStoreSubscription);
raise(volatileEventStoreSubscription, new ResolvedEvent(event1));
raise(volatileEventStoreSubscription2, new ResolvedEvent(event1));
return taskCompletionSource.Task;
});
Expand All @@ -409,12 +410,12 @@ public void when_live_processing_and_disconnected_reconnect_keeps_events_ordered

waitForOutOfOrderEvent.Set();

Assert.That(_raisedEventEvent.Wait(1000));
Assert.That(_raisedEventEvent.Wait(TimeoutMs));

Assert.That(_raisedEvents[0].OriginalEventNumber, Is.EqualTo(0));
Assert.That(_raisedEvents[1].OriginalEventNumber, Is.EqualTo(1));

reconnectTask.Wait();
Assert.That(reconnectTask.Wait(TimeoutMs));
}

private static VolatileEventStoreSubscription CreateVolatileSubscription(Action<EventStoreSubscription, ResolvedEvent> raise, Action<EventStoreSubscription, SubscriptionDropReason, Exception> drop, int? lastEventNumber)
Expand Down

0 comments on commit 6709ce1

Please sign in to comment.