Skip to content

Commit

Permalink
Update test
Browse files Browse the repository at this point in the history
  • Loading branch information
Liam Morrow committed May 25, 2020
1 parent e72a347 commit f99309e
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions test/OrgnalR.Tests/Grains/RewindableMessageGrainTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@ public class RewindableMessageGrainTests : TestKitBase
[Fact]
public async Task GetMessageSinceReturnsAllMessagesIfInBounds()
{
Silo.ServiceProvider.AddService(new OrgnalRSiloConfig
{
MaxMessageRewind = 1
});
Silo.ServiceProvider.AddService(
new OrgnalRSiloConfig
{
MaxMessageRewind = 1,
});
var grain = await Silo.CreateGrainAsync<RewindableMessageGrain<AnonymousMessage>>(Guid.NewGuid().ToString());
var handle = await grain.PushMessageAsync(new AnonymousMessage(new HashSet<string>(), new InvocationMessage("TestTarget1", new object[0])));
var handle = await grain.PushMessageAsync(new AnonymousMessage(new HashSet<string>(), new MethodMessage("TestTarget1", new object[0])));
var since = await grain.GetMessagesSinceAsync(handle);
Assert.Empty(since);
var secondMsg = new AnonymousMessage(new HashSet<string>(), new InvocationMessage("TestTarget2", new object[0]));
var secondMsg = new AnonymousMessage(new HashSet<string>(), new MethodMessage("TestTarget2", new object[0]));
var handle2 = await grain.PushMessageAsync(secondMsg);
since = await grain.GetMessagesSinceAsync(handle2);
Assert.Empty(since);
Expand All @@ -44,7 +45,7 @@ public async Task GetMessageSinceReturnsAllMessagesIfInBoundsLargerSet()
});
var grain = await Silo.CreateGrainAsync<RewindableMessageGrain<AnonymousMessage>>(Guid.NewGuid().ToString());
var handles = Enumerable.Range(0, 20)
.Select(i => grain.PushMessageAsync(new AnonymousMessage(new HashSet<string>(), new InvocationMessage(i.ToString(), new object[0]))))
.Select(i => grain.PushMessageAsync(new AnonymousMessage(new HashSet<string>(), new MethodMessage(i.ToString(), new object[0]))))
.Select(x => x.Result)
.ToList();

Expand Down Expand Up @@ -75,9 +76,9 @@ public async Task GetMessageSinceThrowsWhenOutOfBounds()
MaxMessageRewind = 1
});
var grain = await Silo.CreateGrainAsync<RewindableMessageGrain<AnonymousMessage>>(Guid.NewGuid().ToString());
var handle = await grain.PushMessageAsync(new AnonymousMessage(new HashSet<string>(), new InvocationMessage("TestTarget1", new object[0])));
await grain.PushMessageAsync(new AnonymousMessage(new HashSet<string>(), new InvocationMessage("TestTarget2", new object[0])));
await grain.PushMessageAsync(new AnonymousMessage(new HashSet<string>(), new InvocationMessage("TestTarget3", new object[0])));
var handle = await grain.PushMessageAsync(new AnonymousMessage(new HashSet<string>(), new MethodMessage("TestTarget1", new object[0])));
await grain.PushMessageAsync(new AnonymousMessage(new HashSet<string>(), new MethodMessage("TestTarget2", new object[0])));
await grain.PushMessageAsync(new AnonymousMessage(new HashSet<string>(), new MethodMessage("TestTarget3", new object[0])));
await Assert.ThrowsAsync<ArgumentOutOfRangeException>(async () =>
{
await grain.GetMessagesSinceAsync(handle);
Expand All @@ -92,7 +93,7 @@ public async Task GetMessageSinceReturnsEmptyWhenGroupChanges()
MaxMessageRewind = 1
});
var grain = await Silo.CreateGrainAsync<RewindableMessageGrain<AnonymousMessage>>(Guid.NewGuid().ToString());
var handle = await grain.PushMessageAsync(new AnonymousMessage(new HashSet<string>(), new InvocationMessage("TestTarget1", new object[0])));
var handle = await grain.PushMessageAsync(new AnonymousMessage(new HashSet<string>(), new MethodMessage("TestTarget1", new object[0])));
handle = new MessageHandle(handle.MessageId, Guid.NewGuid());
Assert.Empty(await grain.GetMessagesSinceAsync(handle));
}
Expand All @@ -105,7 +106,7 @@ public async Task GetMessageSinceReturnsEmptyWhenHandleNewer()
MaxMessageRewind = 1
});
var grain = await Silo.CreateGrainAsync<RewindableMessageGrain<AnonymousMessage>>(Guid.NewGuid().ToString());
var handle = await grain.PushMessageAsync(new AnonymousMessage(new HashSet<string>(), new InvocationMessage("TestTarget1", new object[0])));
var handle = await grain.PushMessageAsync(new AnonymousMessage(new HashSet<string>(), new MethodMessage("TestTarget1", new object[0])));
handle = new MessageHandle(handle.MessageId + 1, handle.MessageGroup);
Assert.Empty(await grain.GetMessagesSinceAsync(handle));
}
Expand Down

0 comments on commit f99309e

Please sign in to comment.