示例#1
0
        public void WhenDuplicatedKeyExceptionThrown_NonOfTheActorHandlersIsAdded()
        {
            var actorHandlersMap = new ActorHandlerMap();

            var simpleMessageActor = new ConfigurableActor(new[]
            {
                new MessageHandlerDefinition
                {
                    Handler = null,
                    Message = MessageDefinition.Create <SimpleMessage>()
                }
            });
            var exceptionMessageActor = new ConfigurableActor(new[]
            {
                new MessageHandlerDefinition
                {
                    Handler = null,
                    Message = MessageDefinition.Create <ExceptionMessage>()
                },
                new MessageHandlerDefinition
                {
                    Handler = null,
                    Message = MessageDefinition.Create <SimpleMessage>()
                }
            });

            actorHandlersMap.Add(simpleMessageActor);
            actorHandlersMap.Get(MessageIdentifier.Create <SimpleMessage>());

            Assert.Throws <DuplicatedKeyException>(() => { actorHandlersMap.Add(exceptionMessageActor); });

            actorHandlersMap.Get(MessageIdentifier.Create <SimpleMessage>());
            Assert.Throws <KeyNotFoundException>(() => actorHandlersMap.Get(MessageIdentifier.Create <ExceptionMessage>()));
        }
示例#2
0
        public void ActorHandlersMap_CanAddTwoActorsHandlingSameMessageTypeInDifferentPartitions()
        {
            var actorHandlersMap      = new ActorHandlerMap();
            var partition             = Guid.NewGuid().ToByteArray();
            var actorWithoutPartition = new ConfigurableActor(new[]
            {
                new MessageHandlerDefinition
                {
                    Handler = null,
                    Message = MessageDefinition.Create <SimpleMessage>()
                }
            });

            var actorWithPartition = new ConfigurableActor(new[]
            {
                new MessageHandlerDefinition
                {
                    Handler = null,
                    Message = MessageDefinition.Create <SimpleMessage>(partition)
                }
            });

            actorHandlersMap.Add(actorWithoutPartition);
            actorHandlersMap.Add(actorWithPartition);

            actorHandlersMap.Get(MessageIdentifier.Create(typeof(SimpleMessage), partition));
            actorHandlersMap.Get(MessageIdentifier.Create(typeof(SimpleMessage)));
        }
示例#3
0
        public void AddingActorWithoutRegisteredMessageHandlers_ThrowsNoException()
        {
            var actorHandlersMap = new ActorHandlerMap();
            var voidActor        = new ConfigurableActor(Enumerable.Empty <MessageHandlerDefinition>());

            actorHandlersMap.Add(voidActor);
        }