Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/core/Akka.Tests/Actor/ReceiveTimeoutSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

using System;
using System.Threading;
using System.Threading.Tasks;
using Akka.Actor;
using Akka.Actor.Dsl;
using Akka.Event;
Expand Down Expand Up @@ -161,7 +162,7 @@ public void An_actor_with_receive_timeout_must_not_receive_timeout_message_when_
var timeoutLatch = new TestLatch();
var timeoutActor = Sys.ActorOf(Props.Create(() => new NoTimeoutActor(timeoutLatch)));

Intercept<TimeoutException>(() => timeoutLatch.Ready(TestKitSettings.DefaultTimeout));
Assert.Throws<TimeoutException>(() => timeoutLatch.Ready(TestKitSettings.DefaultTimeout));
Sys.Stop(timeoutActor);
}

Expand All @@ -170,19 +171,18 @@ public void An_actor_with_receive_timeout_must_get_timeout_while_receiving_NotIn
{
var timeoutLatch = new TestLatch();
var timeoutActor = Sys.ActorOf(Props.Create(() => new TimeoutActor(timeoutLatch, TimeSpan.FromSeconds(1))));

var cancellationToken = new CancellationTokenSource();
Sys.Scheduler.Schedule(

var cancelable = Sys.Scheduler.Advanced.ScheduleRepeatedlyCancelable(
TimeSpan.FromMilliseconds(100),
TimeSpan.FromMilliseconds(100),
() =>
{
timeoutActor.Tell(new TransparentTick());
timeoutActor.Tell(new Identify(null));
}, cancellationToken.Token);
});

timeoutLatch.Ready(TestKitSettings.DefaultTimeout);
cancellationToken.Cancel();
cancelable.Cancel();
Sys.Stop(timeoutActor);
}

Expand All @@ -208,7 +208,7 @@ public void An_actor_with_receive_timeout_must_get_timeout_while_receiving_only_
}

[Fact]
public void Issue469_An_actor_with_receive_timeout_must_cancel_receive_timeout_when_terminated()
public async Task Issue469_An_actor_with_receive_timeout_must_cancel_receive_timeout_when_terminated()
{
//This test verifies that bug #469 "ReceiveTimeout isn't cancelled when actor terminates" has been fixed
var timeoutLatch = CreateTestLatch();
Expand All @@ -223,11 +223,11 @@ public void Issue469_An_actor_with_receive_timeout_must_cancel_receive_timeout_w

//Stop and wait for the actor to terminate
Sys.Stop(timeoutActor);
ExpectTerminated(timeoutActor);
await ExpectTerminatedAsync(timeoutActor);

//We should not get any messages now. If we get a message now,
//it's a DeadLetter with ReceiveTimeout, meaning the receivetimeout wasn't cancelled.
ExpectNoMsg(TimeSpan.FromSeconds(1));
await ExpectNoMsgAsync(TimeSpan.FromSeconds(1));
}

[Fact]
Expand Down Expand Up @@ -261,7 +261,7 @@ public void An_actor_with_receive_timeout_must_be_able_to_turn_off_timeout_in_No
var timeoutActor = Sys.ActorOf(Props.Create(() => new Act(actor)));
timeoutActor.Tell(new TransparentTick());

Intercept<TimeoutException>(() => timeoutLatch.Ready(1.Seconds()));
Assert.Throws<TimeoutException>(() => timeoutLatch.Ready(1.Seconds()));
Sys.Stop(timeoutActor);
}
}
Expand Down