private void Handle(StartPomodoro command) { isTicking = true; Context.System.Scheduler.ScheduleTellOnce(command.Duration, Self, new CompletePomodoro("conversation-id", "timer-id"), Sender); Sender.Tell(new PomodoroStarted(command.ConversationId, command.TimerId, command.Duration)); }
private void Handle(StartPomodoro message) { var timer = Context.Child(message.TimerId); if (timer.IsNobody()) { timer = Context.ActorOf <TimerActor>(message.TimerId); } timer.Tell(message); }
public void Should_complete_after_duration() { IgnoreMessages(m => m is PomodoroStarted); var duration = TimeSpan.FromSeconds(1); var command = new StartPomodoro("conversation-id", "timer-id", duration); var timer = Sys.ActorOf(Props.Create <Timer.TimerActor>()); timer.Tell(command); ExpectMsg <PomodoroCompleted>(); }
public void Start_pomodoro_command() { var duration = TimeSpan.FromSeconds(1); var command = new StartPomodoro("conversation-id", "timer-id", duration); var timer = Sys.ActorOf(Props.Create <Timer.TimerActor>()); timer.Tell(command); var message = ExpectMsg <PomodoroStarted>(); Assert.AreEqual(duration, message.Duration); }
public void Start_pomodoro_command() { var probe = CreateTestProbe("probe"); var command = new StartPomodoro("my-conversation-id", "my-timer-id", TimeSpan.FromSeconds(1)); var coordinator = Sys.ActorOf(Props.Create(() => new TimersGateway(probe))); coordinator.Tell(command); var domainEvent = probe.ExpectMsg <PomodoroStarted>(); Assert.AreEqual("my-conversation-id", domainEvent.ConversationId); Assert.AreEqual("my-timer-id", domainEvent.TimerId); Assert.AreEqual(TimeSpan.FromSeconds(1), domainEvent.Duration); }