public void AssignActor_SendsRegisterationMessage()
        {
            var partition         = Guid.NewGuid().ToByteArray();
            var messageIdentifier = MessageIdentifier.Create <SimpleMessage>(partition);

            try
            {
                StartActorHost(actorHost);
                actorHost.AssignActor(new ConfigurableActor(new[]
                {
                    new MessageHandlerDefinition
                    {
                        Handler = _ => null,
                        Message = new MessageDefinition(messageIdentifier.Identity,
                                                        messageIdentifier.Version,
                                                        partition)
                    }
                }));
                AsyncOp.Sleep();
                Func <InternalRouteRegistration, bool> registrationRequest = (reg) => reg.MessageContracts.Any(id => Unsafe.ArraysEqual(id.Message.Identity, messageIdentifier.Identity) &&
                                                                                                               Unsafe.ArraysEqual(id.Message.Partition, messageIdentifier.Partition) &&
                                                                                                               id.Message.Version == messageIdentifier.Version);
                internalRegistrationSender.Verify(m => m.Send(It.Is <InternalRouteRegistration>(reg => registrationRequest(reg))), Times.Once);
            }
            finally
            {
                actorHost.Stop();
            }
        }
        public void ExceptionMessage_HasDomainSet()
        {
            var kinoDomain = Guid.NewGuid().ToString();

            securityProvider.Setup(m => m.GetDomain(KinoMessages.Exception.Identity)).Returns(kinoDomain);
            try
            {
                actorHost = new ActorHost(actorHandlersMap,
                                          new AsyncQueue <AsyncMessageContext>(),
                                          new AsyncQueue <ActorRegistration>(),
                                          securityProvider.Object,
                                          localRouterSocket.Object,
                                          internalRegistrationSender.Object,
                                          localSocketFactory.Object,
                                          logger.Object);
                actorHost.AssignActor(new ExceptionActor());
                var messageIn = Message.CreateFlowStartMessage(new SimpleMessage());
                receivingSocket.SetupMessageReceived(messageIn);
                //
                StartActorHost(actorHost);
                //
                Func <Message, bool> assertCallbackPropertiesCopied = messageOut => messageOut.Equals(KinoMessages.Exception) &&
                                                                      messageOut.Domain == kinoDomain;
                localRouterSocket.WaitUntilMessageSent(assertCallbackPropertiesCopied);
            }
            finally
            {
                actorHost.Stop();
            }
        }
Exemple #3
0
        public void IfCallbackIsRegistered_AsyncExceptionMessageIsDeliveredToCallbackReceiver()
        {
            try
            {
                actorHost = new ActorHost(actorHandlersMap,
                                          new AsyncQueue <AsyncMessageContext>(),
                                          new AsyncQueue <ActorRegistration>(),
                                          securityProvider.Object,
                                          localRouterSocket.Object,
                                          internalRegistrationSender.Object,
                                          localSocketFactory.Object,
                                          logger.Object);
                actorHost.AssignActor(new ExceptionActor());
                var messageIn = Message.CreateFlowStartMessage(new AsyncExceptionMessage {
                    Delay = AsyncOp
                }).As <Message>();
                var callbackReceiver     = Guid.NewGuid().ToByteArray();
                var callbackReceiverNode = Guid.NewGuid().ToByteArray();
                var callbackPoints       = new[] { MessageIdentifier.Create <SimpleMessage>(), KinoMessages.Exception };
                messageIn.RegisterCallbackPoint(callbackReceiverNode,
                                                callbackReceiver,
                                                callbackPoints,
                                                Randomizer.Int32());
                receivingSocket.SetupMessageReceived(messageIn);
                //
                StartActorHost(actorHost);
                //
                localRouterSocket.WaitUntilMessageSent(AssertCallbackPropertiesCopied);

                bool AssertCallbackPropertiesCopied(Message messageOut)
                => messageOut.Equals(KinoMessages.Exception) &&
                messageIn.CallbackPoint.SequenceEqual(messageOut.CallbackPoint) &&
                Unsafe.ArraysEqual(messageIn.CallbackReceiverIdentity, messageOut.CallbackReceiverIdentity) &&
                Unsafe.ArraysEqual(messageIn.CallbackReceiverNodeIdentity, messageOut.CallbackReceiverNodeIdentity);
            }
            finally
            {
                actorHost.Stop();
            }
        }
Exemple #4
0
        public void CallbackReceiverIdentities_AreCopiedFromIncomingMessageProcessedAsync()
        {
            try
            {
                actorHost = new ActorHost(actorHandlersMap,
                                          new AsyncQueue <AsyncMessageContext>(),
                                          new AsyncQueue <ActorRegistration>(),
                                          securityProvider.Object,
                                          localRouterSocket.Object,
                                          internalRegistrationSender.Object,
                                          localSocketFactory.Object,
                                          logger.Object);
                actorHost.AssignActor(new EchoActor());
                var asyncMessage = new AsyncMessage {
                    Delay = AsyncOp
                };
                var messageIn            = Message.CreateFlowStartMessage(asyncMessage).As <Message>();
                var callbackReceiver     = Guid.NewGuid().ToByteArray();
                var callbackReceiverNode = Guid.NewGuid().ToByteArray();
                messageIn.RegisterCallbackPoint(callbackReceiverNode,
                                                callbackReceiver,
                                                MessageIdentifier.Create <SimpleMessage>(),
                                                Randomizer.Int32());
                receivingSocket.SetupMessageReceived(messageIn);
                //
                StartActorHost(actorHost);
                //
                localRouterSocket.WaitUntilMessageSent(AssertCallbackPropertiesCopied);

                bool AssertCallbackPropertiesCopied(Message messageOut)
                => messageIn.CallbackPoint.SequenceEqual(messageOut.CallbackPoint) &&
                Unsafe.ArraysEqual(messageIn.CallbackReceiverIdentity, messageOut.CallbackReceiverIdentity) &&
                Unsafe.ArraysEqual(messageIn.CallbackReceiverNodeIdentity, messageOut.CallbackReceiverNodeIdentity);
            }
            finally
            {
                actorHost.Stop();
            }
        }