Example #1
0
        public void create_MessageSender()
        {
            var path       = Path.Combine(Path.GetTempPath(), "lokad-cqrs-test", Guid.NewGuid().ToString());
            var config     = FileStorage.CreateConfig(new DirectoryInfo(path));
            var serializer = new TestMessageSerializer(new[] { typeof(SerializerTest1), typeof(SerializerTest2) });
            var streamer   = new EnvelopeStreamer(serializer);
            var sender     = config.CreateMessageSender(streamer, "QueueName");

            Assert.IsNotNull(sender);
        }
Example #2
0
        public void when_send_message()
        {
            var serializer  = new TestMessageSerializer(new[] { typeof(SerializerTest1), typeof(SerializerTest2), });
            var streamer    = new EnvelopeStreamer(serializer);
            var queueWriter = new FileQueueWriter(new DirectoryInfo(DirectoryPath), "test");
            var sender      = new MessageSender(streamer, queueWriter);

            sender.Send(new SerializerTest1("Name1"), "EnvId", new[] { new MessageAttribute("key1", "val1"), new MessageAttribute("key2", "val2"), });
            sender.Send(new SerializerTest1("Name1"), "EnvId");

            Assert.AreEqual(2, Directory.GetFiles(DirectoryPath).Length);
        }
Example #3
0
        public virtual void Setup()
        {
            _configuration         = new Mock <IBusConfiguration>();
            _transport             = new TestTransport(_self.EndPoint);
            _directoryMock         = new Mock <IPeerDirectory>();
            _messageDispatcherMock = new Mock <IMessageDispatcher>();
            _messageSerializer     = new TestMessageSerializer();

            _bus = new Bus(_transport, _directoryMock.Object, _messageSerializer, _messageDispatcherMock.Object, new DefaultMessageSendingStrategy(), new DefaultStoppingStrategy(), Mock.Of <IBindingKeyPredicateBuilder>(), _configuration.Object);
            _bus.Configure(_self.Id, _environment);

            _invokers = new List <IMessageHandlerInvoker>();
            _messageDispatcherMock.Setup(x => x.GetMessageHanlerInvokers()).Returns(_invokers);

            _directoryMock.Setup(x => x.GetPeersHandlingMessage(It.IsAny <IMessage>())).Returns(new Peer[0]);
        }
Example #4
0
        public void Setup()
        {
            _transport             = new TestTransport(_self.EndPoint);
            _directoryMock         = new Mock <IPeerDirectory>();
            _messageDispatcherMock = new Mock <IMessageDispatcher>();
            _messageSerializer     = new TestMessageSerializer();

            _bus = new Bus(_transport, _directoryMock.Object, _messageSerializer, _messageDispatcherMock.Object, new DefaultStoppingStrategy());
            _bus.Configure(_self.Id, "test");

            _invokers = new List <IMessageHandlerInvoker>();
            _messageDispatcherMock.Setup(x => x.GetMessageHanlerInvokers()).Returns(_invokers);

            _expectedDumpDirectory = PathUtil.InBaseDirectory(_deserializationFailureDumpsDirectoryName);
            if (System.IO.Directory.Exists(_expectedDumpDirectory))
            {
                System.IO.Directory.Delete(_expectedDumpDirectory, true);
            }

            _directoryMock.Setup(x => x.GetPeersHandlingMessage(It.IsAny <IMessage>())).Returns(new Peer[0]);
        }