Akka.Tests.Actor.PatternSpec.GracefulStop_must_complete_Task_with_TaskCanceledException_when_actor_not_terminated_within_timeout C# (CSharp) Method

GracefulStop_must_complete_Task_with_TaskCanceledException_when_actor_not_terminated_within_timeout() private method

        public void GracefulStop_must_complete_Task_with_TaskCanceledException_when_actor_not_terminated_within_timeout()
        {
            //arrange
            var target = Sys.ActorOf<TargetActor>();
            var latch = new TestLatch();

            //act
            target.Tell(Tuple.Create(latch, TimeSpan.FromSeconds(2)));

            //assert
            XAssert.Throws<TaskCanceledException>(() =>
            {
                var task = target.GracefulStop(TimeSpan.FromMilliseconds(500));
                task.Wait();
                var result = task.Result;
            });
            latch.Open();

        }