public async Task Should_not_blow_up()
        {
            var context = new TestableOutgoingLogicalMessageContext();
            context.Message = new OutgoingLogicalMessage(typeof(MessageWithNullDataBusProperty), new MessageWithNullDataBusProperty());

            var sendBehavior = new DataBusSendBehavior(null, new DefaultDataBusSerializer(), new Conventions());

            using (var stream = new MemoryStream())
            {
                new BinaryFormatter().Serialize(stream, "test");
                stream.Position = 0;

                await sendBehavior.Invoke(context, ctx => TaskEx.CompletedTask);
            }
        }
Example #2
0
        public void SetUp()
        {
            dataBus = MockRepository.GenerateMock<IDataBus>();

            receiveBehavior = new DataBusReceiveBehavior
            {
                DataBus = dataBus,
                DataBusSerializer = new DefaultDataBusSerializer()
            };

            sendBehavior = new DataBusSendBehavior
            {
                DataBus = dataBus,
                DataBusSerializer = new DefaultDataBusSerializer()
            };
        }
        public async Task Should_not_blow_up()
        {
            var context = new TestableOutgoingLogicalMessageContext();

            context.Message = new OutgoingLogicalMessage(typeof(MessageWithNullDataBusProperty), new MessageWithNullDataBusProperty());

            var sendBehavior = new DataBusSendBehavior(null, new DefaultDataBusSerializer(), new Conventions());

            using (var stream = new MemoryStream())
            {
                new BinaryFormatter().Serialize(stream, "test");
                stream.Position = 0;

                await sendBehavior.Invoke(context, ctx => Task.CompletedTask);
            }
        }
Example #4
0
        public void SetUp()
        {
            dataBus = MockRepository.GenerateMock <IDataBus>();

            receiveBehavior = new DataBusReceiveBehavior
            {
                DataBus           = dataBus,
                DataBusSerializer = new DefaultDataBusSerializer()
            };

            sendBehavior = new DataBusSendBehavior
            {
                DataBus           = dataBus,
                DataBusSerializer = new DefaultDataBusSerializer()
            };
        }
        public async Task Outgoing_databus_properties_should_be_dehydrated()
        {
            var context = new TestableOutgoingLogicalMessageContext();
            context.Message = new OutgoingLogicalMessage(typeof(MessageWithDataBusProperty), new MessageWithDataBusProperty
            {
                DataBusProperty = new DataBusProperty<string>("test")
            });

            var fakeDatabus = new FakeDataBus();

            var sendBehavior = new DataBusSendBehavior(fakeDatabus, new DefaultDataBusSerializer(), new Conventions());

            await sendBehavior.Invoke(context, ctx => TaskEx.CompletedTask);

            Assert.AreEqual(TimeSpan.MaxValue, fakeDatabus.TTBRUsed);
        }
        public async Task Outgoing_databus_properties_should_be_dehydrated()
        {
            var context = new TestableOutgoingLogicalMessageContext();

            context.Message = new OutgoingLogicalMessage(typeof(MessageWithDataBusProperty), new MessageWithDataBusProperty
            {
                DataBusProperty = new DataBusProperty <string>("test")
            });

            var fakeDatabus = new FakeDataBus();

            var sendBehavior = new DataBusSendBehavior(fakeDatabus, new DefaultDataBusSerializer(), new Conventions());

            await sendBehavior.Invoke(context, ctx => Task.CompletedTask);

            Assert.AreEqual(TimeSpan.MaxValue, fakeDatabus.TTBRUsed);
        }
Example #7
0
        public async Task Should_not_blow_up()
        {
            var context = new TestableOutgoingLogicalMessageContext
            {
                Message = new OutgoingLogicalMessage(typeof(MessageWithNullDataBusProperty), new MessageWithNullDataBusProperty())
            };

            var sendBehavior = new DataBusSendBehavior(null, new XmlDataBusSerializer <string>(), new Conventions());

            using (var stream = new MemoryStream())
            {
                var serializer = new System.Xml.Serialization.XmlSerializer(typeof(string));
                serializer.Serialize(stream, "test");
                stream.Position = 0;

                await sendBehavior.Invoke(context, ctx => Task.CompletedTask);
            }
        }
        public async Task Time_to_live_should_be_passed_on_the_databus()
        {
            var context = new TestableOutgoingLogicalMessageContext();
            context.Message = new OutgoingLogicalMessage(typeof(MessageWithExplicitTimeToLive), new MessageWithExplicitTimeToLive
            {
                DataBusProperty = new DataBusProperty<string>("test")
            });

            context.Extensions.AddDeliveryConstraint(new DiscardIfNotReceivedBefore(TimeSpan.FromMinutes(1)));

            var fakeDatabus = new FakeDataBus();

            var sendBehavior = new DataBusSendBehavior(fakeDatabus, new DefaultDataBusSerializer(), new Conventions());

            await sendBehavior.Invoke(context, ctx => TaskEx.CompletedTask);

            Assert.AreEqual(TimeSpan.FromMinutes(1), fakeDatabus.TTBRUsed);
        }
        public async Task Time_to_live_should_be_passed_on_the_databus()
        {
            var context = new TestableOutgoingLogicalMessageContext();

            context.Message = new OutgoingLogicalMessage(typeof(MessageWithExplicitTimeToLive), new MessageWithExplicitTimeToLive
            {
                DataBusProperty = new DataBusProperty <string>("test")
            });

            context.Extensions.AddDeliveryConstraint(new DiscardIfNotReceivedBefore(TimeSpan.FromMinutes(1)));

            var fakeDatabus = new FakeDataBus();

            var sendBehavior = new DataBusSendBehavior(fakeDatabus, new DefaultDataBusSerializer(), new Conventions());

            await sendBehavior.Invoke(context, ctx => Task.CompletedTask);

            Assert.AreEqual(TimeSpan.FromMinutes(1), fakeDatabus.TTBRUsed);
        }