Akka.Tests.Actor.ActorCellSpec.Cell_should_clear_current_message_after_async_receive C# (CSharp) Method

Cell_should_clear_current_message_after_async_receive() private method

        public void Cell_should_clear_current_message_after_async_receive()
        {
            AutoResetEvent autoResetEvent = new AutoResetEvent(false);
            var actor = Sys.ActorOf(Props.Create(() => new DummyAsyncActor(autoResetEvent)));
            actor.Tell("hello");
            //ensure the message was received
            autoResetEvent.WaitOne();
            var refCell = actor as ActorRefWithCell;
            var cell = refCell.Underlying as ActorCell;
            //wait while current message is not null (that is, receive is not yet completed/exited)
            SpinWait.SpinUntil(() => cell.CurrentMessage == null, TimeSpan.FromSeconds(2));

            cell.CurrentMessage.ShouldBe(null);
        }
    }