コード例 #1
0
        public void Should_not_throw_propertyType_is_not_serializable_if_a_IDataBusSerializer_is_already_registered()
        {
            if (!Debugger.IsAttached)
            {
                Assert.Ignore("This only work in debug mode.");
            }

            var builder = new BusConfiguration();

            builder.EndpointName("xyz");
            builder.TypesToScan(new[]
            {
                typeof(MessageWithNonSerializableDataBusProperty)
            });
            builder.Conventions().DefiningDataBusPropertiesAs(p => p.Name.EndsWith("DataBus"));
            builder.RegisterComponents(c =>
            {
                c.RegisterSingleton <IDataBus>(new InMemoryDataBus());
                c.ConfigureComponent <IDataBusSerializer>(() => new MyDataBusSerializer(), DependencyLifecycle.SingleInstance);
            });

            var config  = builder.BuildConfiguration();
            var feature = new DataBus();

            Assert.DoesNotThrow(() => feature.CheckPrerequisites(new FeatureConfigurationContext(config)));
        }
コード例 #2
0
        public void Databus_should_not_be_activated_if_no_databus_property_is_found()
        {
            var builder = new BusConfiguration();

            builder.EndpointName("xyz");
            builder.TypesToScan(new[] { typeof(MessageWithoutDataBusProperty) });

            var feature = new DataBus();

            Assert.False(feature.CheckPrerequisites(new FeatureConfigurationContext(builder.BuildConfiguration())).IsSatisfied);
        }
コード例 #3
0
        public void Should_throw_if_propertyType_is_not_serializable()
        {
            if (!Debugger.IsAttached)
            {
                Assert.Ignore("This only work in debug mode.");
            }

            var builder = new BusConfiguration();

            builder.EndpointName("xyz");
            builder.TypesToScan(new[]
            {
                typeof(MessageWithNonSerializableDataBusProperty)
            });
            builder.Conventions().DefiningDataBusPropertiesAs(p => p.Name.EndsWith("DataBus"));

            var feature = new DataBus();

            Assert.Throws <InvalidOperationException>(() => feature.CheckPrerequisites(new FeatureConfigurationContext(builder.BuildConfiguration())));
        }