public void Databus_mutators_should_not_be_registered_if_no_databus_property_is_found()
        {
            Configure.With(new[] { typeof(MessageWithoutDataBusProperty) })
                .DefaultBuilder();

            var bootStrapper = new Bootstrapper();

            bootStrapper.Init();

            Assert.False(Configure.Instance.Configurer.HasComponent<DataBusMessageMutator>());
        }
        public void Databus_should_not_be_registered_if_no_databus_property_is_found()
        {
            Configure.With(new[] { typeof(MessageWithoutDataBusProperty) })
                .DefineEndpointName("xyz")
                .DefaultBuilder();

            IWantToRunBeforeConfigurationIsFinalized bootstrapper = new Bootstrapper();

            bootstrapper.Run();

            Assert.False(Configure.Instance.Configurer.HasComponent<IDataBus>());
        }
        public void Databus_mutators_should_be_registered_if_a_databus_property_is_found()
        {
            Configure.With(new[] {typeof (MessageWithDataBusProperty)})
                .DefaultBuilder();

            var bootStrapper = new Bootstrapper();

            Configure.Instance.Configurer.ConfigureComponent<InMemoryDataBus>(DependencyLifecycle.SingleInstance);

            bootStrapper.Init();

            Assert.True(Configure.Instance.Configurer.HasComponent<DataBusMessageMutator>());
        }
        public void Databus_should_be_registered_if_a_databus_property_is_found()
        {
            Configure.With(new[] {typeof (MessageWithDataBusProperty)})
                .DefineEndpointName("xyz")
                .DefaultBuilder();

            IWantToRunBeforeConfigurationIsFinalized bootstrapper = new Bootstrapper();

            Configure.Instance.Configurer.ConfigureComponent<InMemoryDataBus>(DependencyLifecycle.SingleInstance);

            bootstrapper.Run();

            Assert.True(Configure.Instance.Configurer.HasComponent<IDataBus>());
        }
        public void Should_throw_if_propertyType_is_not_serializable()
        {
            if (!System.Diagnostics.Debugger.IsAttached)
            {
                Assert.Ignore("This only work in debug mode.");
            }

            Configure.With(new[] { typeof(MessageWithNonSerializableDataBusProperty) })
                .DefineEndpointName("xyz")
                .DefiningDataBusPropertiesAs(p => p.Name.EndsWith("DataBus"))
                .DefaultBuilder()
                .Configurer.RegisterSingleton<IDataBus>(new InMemoryDataBus());

            IWantToRunBeforeConfigurationIsFinalized bootstrapper = new Bootstrapper();

            Assert.Throws<InvalidOperationException>(bootstrapper.Run);
        }
        public void Should_not_throw_propertyType_is_not_serializable_if_a_IDataBusSerializer_is_already_registered()
        {
            if (!System.Diagnostics.Debugger.IsAttached)
            {
                Assert.Ignore("This only work in debug mode.");
            }

            Configure.With(new[] { typeof(MessageWithNonSerializableDataBusProperty) })
                .DefineEndpointName("xyz")
                .DefiningDataBusPropertiesAs(p => p.Name.EndsWith("DataBus"))
                .DefaultBuilder()
                .Configurer.RegisterSingleton<IDataBus>(new InMemoryDataBus());

            IWantToRunBeforeConfigurationIsFinalized bootstrapper = new Bootstrapper();

            Configure.Instance.Configurer.ConfigureComponent<IDataBusSerializer>(() => new MyDataBusSerializer(),DependencyLifecycle.SingleInstance);

            Assert.DoesNotThrow(bootstrapper.Run);
        }