Exemplo n.º 1
0
            public void Calls_fallback_when_handler_not_found()
            {
                var actor = new TestActor {
                    Prototype = ActorPrototype.Define(typeof(TestActor))
                };

                var    unknownMessage = new UnknownMessage();
                object bouncedMessage = null;

                Assert.DoesNotThrow(() => actor.Dispatch(unknownMessage, message => bouncedMessage = message));
                Assert.That(bouncedMessage, Is.SameAs(unknownMessage));
            }
Exemplo n.º 2
0
        public static bool Matches(string stream, string target)
        {
            var actor = ActorType.From(typeof(T));
            var proto = ActorPrototype.Define(actor);
            var specs = StreamSubscriptionSpecification.From(actor, proto);

            var matched = specs
                          .Select(s => s.Match(null, stream))
                          .Where(m => m != StreamSubscriptionMatch.None)
                          .ToArray();

            return(matched.Any(x => x.Target == target));
        }
Exemplo n.º 3
0
 public static TActor Define <TActor>(this TActor actor) where TActor : Actor
 {
     Requires.NotNull(actor, nameof(actor));
     actor.Prototype = ActorPrototype.Define(actor.GetType());
     return(actor);
 }