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>())); }
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))); }
public void GettingHandlerForNonRegisteredMessageIdentifier_ThrowsKeyNotFoundException() { var actorHandlersMap = new ActorHandlerMap(); var actor = new EchoActor(); actorHandlersMap.Add(actor); Assert.Throws <KeyNotFoundException>(() => actorHandlersMap.Get(new MessageIdentifier(KinoMessages.Exception))); }