Example #1
0
        public void Should_call_the_consumer_method()
        {
            var actor = new SomeActorInstance();

            var message = new MyMessage();

            actor.MessageChannel.Send(message);

            actor.Future.IsAvailable(1.Seconds()).ShouldBeTrue();
            actor.Future.Value.ShouldEqual(message);
        }
Example #2
0
        public void Should_call_the_consumer_anonymous_method()
        {
            var actor = new SomeActorInstance();

            var message = new MyMessage();

            actor.LambdaMessageChannel.Send(message);

            actor.Future.WaitUntilCompleted(1.Seconds()).ShouldBeTrue();
            actor.Future.Value.ShouldEqual(message);
        }
        public void Should_create_a_new_consumer_instance_for_each_message()
        {
            var message = new MyMessage();

            var result = MockRepository.GenerateMock<Channel<MyMessage>>();
            result.Expect(x => x.Send(message)).Repeat.Twice();

            var provider = MockRepository.GenerateMock<ChannelProvider<MyMessage>>();
            provider.Expect(x => x.GetChannel(message)).Return(result).Repeat.Twice();

            var channel = new InstanceChannel<MyMessage>(new SynchronousFiber(), provider);

            channel.Send(message);
            channel.Send(message);

            result.VerifyAllExpectations();
            provider.VerifyAllExpectations();
        }
Example #4
0
        public void Should_pull_the_matching_instance_from_the_cace()
        {
            var message = new MyMessage();

            var result = MockRepository.GenerateMock<Channel<MyMessage>>();
            result.Expect(x => x.Send(message)).Repeat.Twice();

            var provider = MockRepository.GenerateMock<ChannelProvider<MyMessage>>();
            provider.Expect(x => x(message)).Return(result).Repeat.Once();

            KeyAccessor<MyMessage, Guid> messageKeyAccessor = x => x.Id;

            var channel = new InstanceChannel<MyMessage>(new KeyedChannelProvider<MyMessage, Guid>(provider, messageKeyAccessor).GetChannel);

            channel.Send(message);
            channel.Send(message);

            provider.VerifyAllExpectations();
            result.VerifyAllExpectations();
        }
Example #5
0
 private void Consume(MyMessage message)
 {
     _future.Complete(message);
 }