Esempio n. 1
0
        public void Regex_based_matching(string source, string target, string streamId, string actorId)
        {
            var system = new ActorSystemMock();

            var attribute = new StreamSubscriptionAttribute
            {
                Source = source,
                Target = target
            };

            var type       = typeof(TestActor);
            var dispatcher = new Dispatcher(type);

            var specification = StreamSubscriptionSpecification.From(type, attribute, dispatcher);

            specification.Type = ActorTypeName.Of(typeof(TestActor));

            var match = specification.Match(system, streamId);

            if (match == StreamSubscriptionMatch.None)
            {
                Assert.That(actorId, Is.Null);
                return;
            }

            var message = new object();

            match.Receiver(message);

            Assert.That(system.RequestedRef, Is.Not.Null);
            Assert.That(system.RequestedRef.Path, Is.EqualTo(typeof(TestActor).ToActorPath(actorId)));
            Assert.That(system.RequestedRef.MessagePassedToTell, Is.SameAs(message));
        }
Esempio n. 2
0
        public static ActorPath ToActorPath(this Type type, string id)
        {
            Requires.NotNull(type, nameof(type));
            var key = ActorTypeName.Of(type);

            return(ActorPath.From(key, id));
        }
        StreamSubscriptionSpecification(Type actor, string provider, Func <string, string> matcher, Func <object, string> selector = null, Func <object, bool> filter = null)
        {
            Requires.NotNullOrWhitespace(provider, nameof(provider));
            Requires.NotNull(matcher, nameof(matcher));

            Type          = ActorTypeName.Of(actor);
            Provider      = provider;
            this.matcher  = matcher;
            this.selector = selector;

            this.filter = filter ?? (x => true);
        }
        void RegisterAutoruns()
        {
            var autoruns = new Dictionary <string, string[]>();

            foreach (var actor in assemblies.SelectMany(x => x.ActorTypes()))
            {
                var ids = AutorunAttribute.From(actor);
                if (ids.Length > 0)
                {
                    autoruns.Add(ActorTypeName.Of(actor), ids);
                }
            }

            Bootstrapper <AutorunBootstrapper>(autoruns);
        }
Esempio n. 5
0
        public void Dynamic_target_matching()
        {
            var system = new ActorSystemMock();

            var type       = typeof(DynamicTargetSelectorActor);
            var dispatcher = new Dispatcher(type);

            var specification = StreamSubscriptionSpecification.From(type, dispatcher).ElementAt(0);

            specification.Type = ActorTypeName.Of(typeof(DynamicTargetSelectorActor));

            var match = specification.Match(system, "foo");

            var message = new object();

            match.Receiver(message);

            Assert.That(system.RequestedRef, Is.Not.Null);
            Assert.That(system.RequestedRef.Path, Is.EqualTo(typeof(DynamicTargetSelectorActor).ToActorPath("bar")));
            Assert.That(system.RequestedRef.MessagePassedToTell, Is.SameAs(message));
        }