Beispiel #1
0
        public void ConversionServiceUsedByDefault()
        {
            var converter   = new BoolToIntConverter();
            var convService = new GenericConversionService();

            convService.AddConverter(converter);
            var services = new ServiceCollection();
            var config   = new ConfigurationBuilder().Build();

            services.AddSingleton <IConfiguration>(config);
            services.AddSingleton <IApplicationContext, GenericApplicationContext>();
            services.AddSingleton <IIntegrationServices, IntegrationServices>();
            services.AddSingleton <IConversionService>(convService);
            services.AddSingleton <IMessageBuilderFactory, DefaultMessageBuilderFactory>();
            services.AddSingleton <DefaultDatatypeChannelMessageConverter>();
            var provider = services.BuildServiceProvider();
            var channel  = new QueueChannel(provider.GetService <IApplicationContext>(), "testChannel");

            channel.DataTypes = new List <Type>()
            {
                typeof(int), typeof(DateTime)
            };
            Assert.True(channel.Send(Message.Create(true)));
            Assert.Equal(1, channel.Receive().Payload);
        }
Beispiel #2
0
        public void CustomConversion()
        {
            var conversionService = new GenericConversionService();

            conversionService.AddConverter(new SampleBeanConverter());
            var instance = CreateInstance(conversionService);

            var invocableHandlerMethod = CreateInvocableHandlerMethod(instance, "SimpleString", typeof(string));

            invocableHandlerMethod.Invoke(MessageBuilder <SampleBean> .WithPayload(sample).Build());
            AssertMethodInvocation(sample, "SimpleString");
        }