Skip to content

Commit

Permalink
better error test
Browse files Browse the repository at this point in the history
  • Loading branch information
Wojciech Turowicz committed Aug 3, 2023
1 parent 6c656a9 commit d8b4f8f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,14 @@ public void It_Should_Deliver_Expected_Data()

public class When_Sending_Broadcast_Message_One_To_Many_Error : BaseOneToManyTest
{
protected Stopwatch timer;
protected TimeSpan wait = TimeSpan.FromSeconds(10);

protected string resultText;
protected Stopwatch timerText;
protected string expectedText = "text";

protected byte[] resultData;
protected Stopwatch timerData;
protected byte[] expectedData = new byte[1024];

public override void Prepare()
Expand All @@ -263,7 +265,9 @@ public override void Prepare()
Processor!.Setup(x => x.Process(It.IsAny<string>()))
.Callback<string>(x =>
{
if (timer.Elapsed < TimeSpan.FromSeconds(4))
timerText = timerText ?? Stopwatch.StartNew();
if (timerText.Elapsed < wait)
{
throw new Exception();
}
Expand All @@ -276,7 +280,9 @@ public override void Prepare()
Processor!.Setup(x => x.Process(It.IsAny<byte[]>()))
.Callback<byte[]>(x =>
{
if (timer.Elapsed < TimeSpan.FromSeconds(4))
timerData = timerData ?? Stopwatch.StartNew();
if (timerData.Elapsed < wait)
{
throw new Exception();
}
Expand All @@ -298,8 +304,6 @@ public override async Task Act()
{
var grain = Subject.GetGrain<IEmitterGrain>(Guid.NewGuid());

timer = Stopwatch.StartNew();

await grain.BroadcastAsync(expectedText, expectedData);
}

Expand Down
4 changes: 4 additions & 0 deletions src/Orleans.Streaming.Grains/Grains/TransactionGrain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ public async Task CompleteAsync(Guid id, bool success)
await _subscriptions.Notify(x => x.CompletedAsync(id, success, this.GetPrimaryKeyString()));
}
}
else
{
throw new InvalidOperationException($"No transaction with id {id} pending.");
}
}

public async Task<Guid?> PopAsync()
Expand Down

0 comments on commit d8b4f8f

Please sign in to comment.