Example #1
0
        public void CreateAmqpSerializerWithDefaultSerializerIfMessageContentTypeWasNotFilled()
        {
            var serializers = GetAmqpSerializers();
            var message     = A.Fake <IMessage>();
            var sut         = new AmqpSerializerFactory(new ReadOnlyDictionary <string, IAmqpSerializer>(serializers));

            IAmqpSerializer serializer = sut.CreateSerializer(message);

            serializer.Should().BeOfType <SimpleSerializer>(because: "factory should return default serializer");
        }
Example #2
0
        public void DefaultSerializerShouldBeChooIfSerializerByContentTypeWasNowFound()
        {
            var serializers = GetAmqpSerializers();
            var message     = A.Fake <IMessage>();

            A.CallTo(() => message.Headers).Returns(new Dictionary <string, string>
            {
                { "content-type", "application/x-binary" }
            });
            var sut = new AmqpSerializerFactory(new ReadOnlyDictionary <string, IAmqpSerializer>(serializers));

            IAmqpSerializer serializer = sut.CreateSerializer(message);

            serializer.Should().BeOfType <SimpleSerializer>(because: "factory should return default serializer");
        }
Example #3
0
        public void CreateAmqpSerializerWithCustomSerializerDeterminedByContentType()
        {
            var serializers = GetAmqpSerializers();
            var message     = A.Fake <IMessage>();

            A.CallTo(() => message.Headers).Returns(new Dictionary <string, string>
            {
                { "content-type", "application/json" }
            });
            var sut = new AmqpSerializerFactory(new ReadOnlyDictionary <string, IAmqpSerializer>(serializers));

            IAmqpSerializer serializer = sut.CreateSerializer(message);

            serializer.Should().BeOfType <JsonSerializer>(because: "factory should not return default serializer");
        }