Пример #1
0
        public void Given_a_non_stopped_When_sending_Success_Then_promise_success_is_called()
        {
            var promise  = A.Fake <IPromise <object> >();
            var actorRef = new PromiseActorRef(A.Fake <ActorPath>(), promise, A.Fake <ActorRef>(), A.Fake <TestActorSystem>());

            var sender = A.Fake <ActorRef>();

            actorRef.Send(new Status.Success("test"), sender);

            A.CallTo(() => promise.TrySuccess("test")).MustHaveHappened();
        }
Пример #2
0
        public void Given_a_non_stopped_When_sending_Failure_Then_promise_failure_is_called()
        {
            var promise  = A.Fake <IPromise <object> >();
            var actorRef = new PromiseActorRef(A.Fake <ActorPath>(), promise, A.Fake <ActorRef>(), A.Fake <TestActorSystem>());

            var sender    = A.Fake <ActorRef>();
            var exception = new Exception("test");

            actorRef.Send(new Status.Failure(exception), sender);

            A.CallTo(() => promise.TryFailure(exception)).MustHaveHappened();
        }
Пример #3
0
        public void Given_a_stopped_When_sending_message_Then_it_is_forwarded_to_DeadLetter()
        {
            var deadLetters = A.Fake <ActorRef>();
            var actorRef    = new PromiseActorRef(A.Fake <ActorPath>(), A.Fake <IPromise <object> >(), deadLetters, A.Fake <TestActorSystem>());

            actorRef.Stop();

            var sender = A.Fake <ActorRef>();

            actorRef.Send("test", sender);
            A.CallTo(() => deadLetters.Send("test", sender)).MustHaveHappened();
        }
Пример #4
0
        public void Given_a_completed_promise_When_sending_Then_message_is_forwarded_to_deadletters()
        {
            var promise     = A.Fake <IPromise <object> >();
            var deadLetters = A.Fake <ActorRef>();
            var actorRef    = new PromiseActorRef(A.Fake <ActorPath>(), promise, deadLetters, A.Fake <TestActorSystem>());

            A.CallTo(() => promise.TrySuccess("test")).Returns(false);
            var sender = A.Fake <ActorRef>();

            actorRef.Send("test", sender);

            A.CallTo(() => deadLetters.Send("test", sender)).MustHaveHappened();
        }